Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able to press a keyboard combination, start typing a mathematical expression that includes units and slightly advanced math (not just a four-function calculator), and get a result immediately, in units that I specify, that I can copy and paste.

  • Currently I open Firefox and press Ctrl+K, type in the search box, and it usually gives me a result in the drop-down from Google Calculator. It doesn't always, though, so I press "=" at the end, wait for a result, remove the equals, wait for a result, realize it doesn't understand the way I typed a unit, open the result in a new tab, etc. it sucks.
  • Wolfram Alpha is smarter, but very much slower, and the output is all images, not text, and I don't have a quick widget for it, if such a thing could even exist.
  • GNU units has a ton of units, which is great, and I can define my own units, which is great, but they have to be written in specific, unintuitive ways, it doesn't handle much advanced math, and I'd need to open a terminal, start units, etc. I hate the command line.

I wasted a lot of time trying to make front-ends for units in Deskbar and Launchy, but I'm not a real coder and I don't use either of those anymore.

Any other solutions or enhancements of these?

(Of course, something cross-platform would be even better, but Linux-only is fine.)

share|improve this question
What is the level of complexity of the problems you are trying to solve? – spowers Apr 26 '10 at 0:33
What did you try to script that a combination of bc -l and units couldn't do? – Benjamin Bannier Apr 26 '10 at 0:38
Can you give an example of using bc -l and units together? I didn't know that was possible. – endolith Apr 26 '10 at 15:04
@honk: sounds like something you should post in an answer (y'know, with an example). @endolith: use @ for comment notifications so the user gets notified when you reply to them. – quack quixote Apr 26 '10 at 15:29
@endolith: Actually my comment was too fast, bc doesn't gain you anything if you do not plan to define your own functions . The trigonometric, exponential and logarithmic function are all already defined in units (only Bessel functions are missing). – Benjamin Bannier Apr 26 '10 at 19:48
up vote 5 down vote accepted

I'm very impressed with Qalculate!.

Qalculate! screenshot

share|improve this answer
+1 So am I, although my user interface (the Qalculate plasmoid for KDE) doesn't offer a way to express a result in specified units. I work around it by dividing my result by the units I want. I forget whether the full interface, if it even still exists, can do that. (Just so it's clear: even with the UI limitations, it's still my favorite calculator for anything I don't need Mathematica for) – David Z Apr 26 '10 at 2:26
I don't see standard temperature, speed of sound, and I don't understand how it handles dB, but I am also very impressed. I wish the answers appeared after a short delay without pressing Enter, too. But these are all things I can complain about. :) – endolith Apr 27 '10 at 23:05
@endolith: You can go into Edit>Manage Variables>Physical Constants and Edit>Manage Units and add your own or edit existing entries. I've never seen a calculator complete a calculation after a timeout. One thing I would like to see in this program is history navigation using arrow keys or scroll-and-click with the mouse instead of having to copy-paste from the history. – Dennis Williamson Apr 28 '10 at 4:28
Google Calculator in the Firefox search bar completes as I type, though I have to prod it sometimes by typing an equals sign. The thing I wrote for Launchy also displays the result as you type, though it was slow because of the way it accesses Units. – endolith Apr 30 '10 at 18:54

For a easily scriptable solution you might want to have a look a the sympy python module.

$ cat

#!/usr/bin/env python
import sys
from sympy.physics.units import *
from sympy.printing.pretty.pretty import pprint
from import x, y, z
from sympy import *

# adding extra units is easy
parsec = 3.26163626*ly

if __name__ == '__main__':
  s_input = sys.argv[1]
  s_unit  = sys.argv[2]
  input = eval(s_input)  # input string
  unit  = eval(s_unit)   # output unit

  print 'Converting:'
  print str((input/unit).evalf()) +' '+ s_unit

which gives e.g. for some moderately ugly expression converted to mm:

$./ 'tanh(3*m/(2*m))*sinh(60*deg)*1*parsec' 'mm'

                           \3 /

3.48955431541888e+19 mm

Of course this is really studpid code that does no checking thet unit compatibility of the input and output, so you might end up extra units in the result.

$./ 'c' 'parsec'


9.71539598165644e-9/s parsec
share|improve this answer
Also see – endolith Apr 27 '10 at 11:56
@endolith: It all really only depends on what kind of math you want. The basics are in units, but obviously it doesn't have symbolic algebra or higher math. – Benjamin Bannier Apr 27 '10 at 13:41

Wolfram Alpha is capable of crunching math and doesn't require you to download or install anything.

Check here for how to use its math functions.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .