Or, if you're on OS X, you can just use Spotlight. It includes trig functions, factorials, exponents, etc, and it's only a command-space away. The only downside is that it doesn't automatically copy the result into your clipboard.
I'm surprised that pressing enter on the result in Spotlight doesn't copy it to the clipboard. Amusingly, it opens up the Calculator which I never need after getting the answer.
‘qalc’ is the command-line version of Qalculate![0] and runs both directly from the command line as well as interactively with tab-completion of variables (Planck mass, for example) and arbitrary unit conversion:
That is true, but I have found if I am doing calculations that need something like the full math library of python, it's not a one-off calculation, and I am typically on octave anyway.
In any case, since I have emacs open all time, I usually do
A probable improvement on this would be to leave bash out, and just put a python hash bang in the script directly.
I'll leave implementing it as an exercise to the reader. Personally I have found using Guake (http://guake.org/) with IPython as the shell a very nice way of solving this problem.
For anyone who would like this in an Alfred workflow, make a Script Filter with the following python code (and uncheck all the escape character options):
from math import *
print '<?xml version="1.0"?><items>'
print '<item uid="qcresult" valid="yes" autocomplete="">'
print '<title>'+str({query})+'</title>'
print '</item></items>'
An example: http://i.imgur.com/vaN7HfS.png