A few weeks back I wrote a post on calculators, expressing my desire for something that was more than a push-button emulator, and less than a full programming language. Something where you just have a window where you can type 2.3*Msun*c**2, define short expressions for re-use, etc. Python seems to be the obvious thing but it has some annoying quirks; I also recommended Plaincalc. The comment stream was fascinating and very educational, with pointers to Wolfram Alpha, the Statusbar calculator for Firefox, and iCosmo, as well as some Python tutorial from Ross C.

I have been thinking about a similar post on graph plotters. While playing with these, I suddenly realised that the plotting package I use most often, gnuplot, does exactly whats needed ! Doh ! You can do calculations – eg print 18.3 * 27.6. You can define and use variables – eg a=pi/6, b=18.3, and then c=b**2*sin(1.3*a). You can define and use single expression functions – e.g. f1(a,b,x)=a*x**2+b*sin(x)/x; then with a and b already set you can calculate g=f1(a,b,2.3)/f1(a,b,3.2). Finally of course you can plot f1(a,b,x) – gnuplot assumes x is the variable and other variables are parameters. Then you can change the values of a and b and replot.

So now I have a file of physics and astro constants which is loaded by my .gnuplot initialisation file, so I can type 2.3*Msun*c**2. Next up, some standard functions, eg RBB(nu,T) = (2.*pi/c**2) * nu**3 / (exp(h*nu/(k*T)) – 1.).

So gnuplot is now my standard calculator, rather than Python interactive mode. The Python fans will now tell me that there is a Python version of gnuplot. Indeedy… but thats straying into the graph plotter shoot-out territory…. Watch this space.

This entry was posted on Monday, July 27th, 2009 at 6:37 am and is filed under Science and Technology. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

So, with ipython at least it appears to be possible to get this behavior. (The workaround in the standard python interpreter is still rather cumbersome.)

It’s great for making ‘real’ plots, but I played around with trying to make it a bit more interactive (at least in the Python interpreter) by adding a further layer on top of it that sequences underlying PGPLOT routines in more of user-friendly way. For example you can do stuff like:

for simple (lambda style) functions, and even generic funcs(x,p) if you want… and there’s other stuff in there too, mainly for plotting data, images, etc.

I can make it available if anyone’s interested – I’ve always meant to.

If you just want numerical results, ie you don’t need a graphical output, then have a look at either of the two ‘Generic’ calculators at http://www.calcResult.com
They both give you a full arithmetic parser/calculator in a single text box.

[…] am going to do it in installments … Just over a year ago I wrote a couple of posts (here and here) about looking for calculators that hit a sweet spot between laborious button-pushing GUI and full […]

There is an ancient UNIX terminal calculator called “desk calculator” for this exact purpose. It can be summoned by the command `dc` or `bc`. It will handle almost all basic calculations and features variable substitutions. One can set the default precision. There are built in functions for sqrt, sin, and arctan, and a few others. However, it won’t handle functions as far as I know.

Can I recently say what relief to locate somebody that actually knows what theyre dealing with on the internet. You definitely learn how to bring an issue to light and earn it important. Workout . need to see this and understand why side from the story. I cant think youre less common since you absolutely contain the gift.

This blog has an open comment policy. Please respect this by keeping comments the pleasant side of insult and libel ... and do be aware that the comments don't necessarily reflect my own opinions.

I just asked how to do a similar thing in the python interpreter and got an answer here:

http://stackoverflow.com/questions/1187000/how-do-i-control-number-formatting-in-the-python-interpreter/1187067#1187067

So, with ipython at least it appears to be possible to get this behavior. (The workaround in the standard python interpreter is still rather cumbersome.)

I guess the most up-to-date, semi-interactive plotting environment for Python is matplotlib http://matplotlib.sourceforge.net/… however I still like the flexibility of the Python binding to PGPLOT (http://www.astro.rug.nl/~breddels/python/ppgplot/).

It’s great for making ‘real’ plots, but I played around with trying to make it a bit more interactive (at least in the Python interpreter) by adding a further layer on top of it that sequences underlying PGPLOT routines in more of user-friendly way. For example you can do stuff like:

plot.lambda_function(lambda x: sin(x),colour=’red’,weight=3)

for simple (lambda style) functions, and even generic funcs(x,p) if you want… and there’s other stuff in there too, mainly for plotting data, images, etc.

I can make it available if anyone’s interested – I’ve always meant to.

If you just want numerical results, ie you don’t need a graphical output, then have a look at either of the two ‘Generic’ calculators at http://www.calcResult.com

They both give you a full arithmetic parser/calculator in a single text box.

[…] am going to do it in installments … Just over a year ago I wrote a couple of posts (here and here) about looking for calculators that hit a sweet spot between laborious button-pushing GUI and full […]

There is an ancient UNIX terminal calculator called “desk calculator” for this exact purpose. It can be summoned by the command `dc` or `bc`. It will handle almost all basic calculations and features variable substitutions. One can set the default precision. There are built in functions for sqrt, sin, and arctan, and a few others. However, it won’t handle functions as far as I know.

Dear Molzonide : I guess you missed the first part of this article where I did mention bc.

Can I recently say what relief to locate somebody that actually knows what theyre dealing with on the internet. You definitely learn how to bring an issue to light and earn it important. Workout . need to see this and understand why side from the story. I cant think youre less common since you absolutely contain the gift.