Two Wrongs

Emacs Calc – Evaluate Expression For Multiple Values

Emacs Calc – Evaluate Expression For Multiple Values

I wanted to get a sense of the value of

\[\frac{1}{\frac{1}{\Gamma(x)} + 1}\]

for various input values \(x\). Instead of evaluating this in F# or R, I decided it was a good opportunity to learn more abuot Emacs calc.11 Emacs calc is a very powerful desktop calculator, and I know I could be much more productive if I knew how to use it well.

It took some time to dig out the interesting parts of the manual, but in the end I figured out what to do. I needed to enter a vector of the values I wanted to try:

[ 1 2 9 99 ]
1:  [1, 2, 9, 99]

and, of course, the formula I wanted to try these with:

' 1/(1/gamma(x)+1)
2:  [1, 2, 9, 99]
1:  1 / (1 / gamma(x) + 1)

And then I wanted to map a function pointwise to the elements of a vector, as described in section 9.8.2 of the manual. However, it wasn’t a plain built-in function I wanted to apply, so I had to read the 9.8.1 section on specifying operators in detail, until I figured it out how it all fit together. In the end, though, it was quite simple: by specifying the function $, I’m telling Emacs to use the algebraic equation at the top of the stack.

V M $ RET
1:  [0.5, 0.5, 0.9999, 1.]

This is very nice!