# A Handy Calc Tip

As I wrote three weeks ago in these two posts, I’ve renewed my efforts to become semi-proficient with Calc. On the one hand, it’s not that hard. By default, it’s simply a stack based RPN calculator of the sort that I’m very familiar with from my HP calculator days. Some of the symbolic mathematics parts are a bit trickier but not very much so.

What really makes Calc hard is the huge number of commands it implements and the assignment, seemingly higgledy-piggledy, of those commands to one or two letter shortcuts. Unlike a calculator, there’s no convenient SQRT button to press: you’ve got to remember its shortcut, Q, instead. Suppose, for example, I want to factor the integer 3469394 into its prime factors 2, 17, 67, 1523. I know there’s a command to do that but I don’t use it enough to remember the shortcut—it’s k f but I only know that because I’m peeking at the cheat sheet.

Of course, all those shortcuts are bound to Elisp functions in exactly the same way that Ctrl+x Ctrl+f is bound to find-file so you can call them directly with Meta+x in the usual way. Now all you have to remember is that the command involves “prime factors” and Avy, Ido, or whatever you use will help you find calc-prime-factors. But it gets even better. The shortcut x will start the process for you by calling Meta+x and filling in the calc- part that starts every Calc command. Now to factor 3469394, you simply push it onto the stack, type x and enough of prime factors for command completion to do its thing.

The power in this is not that it saves some keystrokes but that you can easily find a function whose obscure shortcut you don’t remember. Theoretically, which-key or something similar will do this too but then you have to remember that the factoring command starts with a k. That’s precisely the hard part; I can probably remember the f on my own.

If you’re always factoring numbers (or whatever) you’ll learn the shortcut of course but what about the Bessel $J_{\nu}$ function? Since I learned and internalized the x shortcut, I’m finding it much easier to get a grip on Calc.

Update [2018-01-06 Sat 17:53]: I → you (a couple of times)

This entry was posted in General and tagged , . Bookmark the permalink.
• András Simonyi

Thanks! -- this is indeed a very useful shortcut I didn't know of.

• Theldoria

You can also go by this:

#+BEGIN_SRC calc
124
'kf'
#+END_SRC

• András Simonyi

strange -- this doesn't work for me. I get kf as the result

• Phil

That "x" binding is genius. Excellent tip!