[LinuxFocus-icon]
LinuxFocus article number 319
http://linuxfocus.org

[Photo of the Author]
by Guido Socher (homepage)

About the author:

My first RPN calculator was a HP15c and it was love at first sight.

RPN calculators for Linux

hp-calc and tux

Abstract:

RPN stands for Reverse Polish Notation. Reverse Polish Notation was developed in 1920 by Jan Lukasiewicz as a way to write a mathematical expression without using parentheses and brackets. It takes a few minutes to learn RPN but you will soon see that this entry method is superior to the algbraic format.

_________________ _________________ _________________

 

Introduction

RPN pocket calculators became popolar with the HP calculators. HP used this entry method already for it's first calculator in 1968. If you search the internet you will find that there is a whole fan club behind those HP calculators. I have made a number of very good links available at the end of this article. Most of those HP calculators are today collectors items and sell now for much more than their original price.

In this article will present some of the RPN desktop calculators available for Linux. We will not only look at the HP emulators which are available but also other RPN calculators which are totally independent of HP.  

What is RPN? Why RPN?

RPN calculators use a stack and all mathematical operations are executed immediately on the lower level of the stack. The stack is used as a memory to save results which you need to further evaluate your formula. Therefore you do not need any brackets on an RPN calculator. You first enter the numbers, push them up the stack, and then you say what you want to do with those numbers. Let's say you want to calculate:
(( 3 + 1 )^2 + 1) * 4 To do this you would type the following:
3 enter
1 +      (immediately you see the result of this operation: 4)

x^2      (immediately you see the result of this operation: 16)
1+       (immediately you see the result of this operation: 17)
4*       (final result: 68)
So to enter this formula you needed 9 key strokes and you could see all the intermediate results. It is basically how you would evaluate a formula when you evaluate it without calculator in your brain. In other words the calculator is much more "natural". It works the same way that your "brain works".

If you compare this to an algebraic calculator where you punch in the formula as written you would need 12 key strokes and you would not see all the intermediate results. The advantages are in other words:  

The calculators

Let's start with some simple calculators which you can just test in your webbrowser while you are reading this article and then further down I will present more powerful "machines".
 

rpnjcalc

This calculator uses Javascript. It is my own design and runs in any modern (!) webbrowser (does not work properly with opera 5/6, netscape 4, konquerer). It is different from many other javascript calculators because you can use also the keyboard to type in numbers and basic mathematical operators. Just click here to play with rpnjcalc

Name:rpnjcalc
Homepage:http://main.linuxfocus.org/~guido/javascript/rpnjcalcallver.html
License:GPL

 

hp-35

This calculator uses Javascript too but it puts more emphasis on looking like a real (old) HP-35 pocket calculator. You can test it online by following this link
If you really want to use it then I recommend to download the zip file below because it uses gif images and the response is much faster when you install it locally. Note also that this calculator does not offer the same functionallity as a real HP35. It can e.g do trigonnometry only in degrees (0-360).

Name:hp-35
Homepage:Unknown, taken from www.hpmuseum.org. Download here:hp-35.zip
License:GPL

 

dc

This calculator is an standard Unix command. You find it on even the oldest unix systems. It can do only basic arithmetic but it can handle very very long numbers. To start it just type dc and then a number followed by "k" (e.g: 6k and press return). This sets the precision. Now you can do calculations (+-*/) and you print the lowest level of the stack with "p". You end it with crtl-d.

Name:dc (desk calculator)
Homepage:Part of every unix system. Under Linux the package name for dc is called bc
License:normally the same as your Unix system

 

vc.pl

This calculator is written in Perl. It is an interessting implementation because it is actually a vector calculator. You can of course use it also for normal arithmetic as a single number is just a one dimmensional vector. It has an integrated help system (just type help). Installation is easy because it uses only standard perl modules.

Name:vc (vector calculator)
Homepage:http://vc-calc.sourceforge.net/
License:GPL

 

x48

This calculator is a HP-48 emulator. That is: you can run the real code from HP on it. The calculator just implements an emulator. You need to load the real HP-48 ROM code. x48 has a GPL license but the the ROM is of course copyright HP. The original hp48 calculator is no longer manufactured by HP and HP allows now downloads of ROM images since year 2000. Side note: It is nice to have such a calculator on the computer screen but it is still no real replacment for a original HP-48 because the x48 has not a very good keyboard interface. Therefore you find your self using mouse clicks most of the time and this is rather slow.

Because x48 is an emulator it can do all the operations exactly as the original HP-48. The latest version that I could find is 0.4 which is already a few years old. It works however without any problems. Version 0.4 needs a small patch to compile on a modern Linux system. You find an original Manual, some ROM images, the patch and further instructions on the "x48 details page" below.

Name:x48
Homepage:ftp://www.sunsite.unc.edu/pub/linux/system/emulators/
Details about the x48: "x48 details page", installation, documentation, rom images (see also the links at the end of this article for more rom images)
License:GPL, but you need a HP ROM image

 

hp67

This calculator has all the functionallity of a real hp67 but it is completley re-written and independent of the hp67 code. It is not an emulator. The interface looks a bit basic (ncurses) but the functionallity is very good. It comes als with excellent documentation in the form of a man-page (see link below). You can even program it like a real hp67. To start programming you press "prog" then you enter your program, starting with a lable name and you get out of programming mode with "immed". To execute a program you use "run labelname". Here is an example. My example is a bit useless as it implements just the square function but it gives you an idea how to program the hp67:
prog (enter programming mode)

label myprg
ENTER
*
rtn
immed (end of programming mode)
Now you can use "run myprg" to execute x^2.

Name:hp67
Manual:The hp67 man-page in html format
Homepage:http://www.ibiblio.org/pub/Linux/apps/math/calc/
License:GPL

 

kalc

kalc runs also from the command line. It uses the readline library and has some "command completion" features. It works with real and complex numbers, unlimited size integers, arbitrary-precision real numbers. Very good is also the documentation (see pdf file below).

Name:kalc
Manual:kalc.pdf 230K
Homepage:http://sourceforge.net/projects/kalc/
License:GPL

 

dcalc

This is also a ncurses based calculator to run in a terminal window. It is not programmable like the hp67 but it is good to convert numbers from hex to bin to decimal.

Name:dcalc
Homepage:http://www.ibiblio.org/pub/Linux/apps/math/calc/
License:GPL

 

rpncalc

This is also a rpn calculator to run in a terminal window but it is not ncurses based. Therefore it is very similar to the "dc" command. It implements the functionallity of the HP28s. rpncalc is therefore much more advanced than "dc". It can handle complex numbers, vector and matrices. rpncalc is part of Debian.
Name:rpncalc
Homepage:http://www.gnu.org/directory/science/math/rpncalc.html
License:GPL

 

gdcalc

This is a nice calculator with gtk graphical user interface. You can configure it to use either RPN or algebraic entry method. It offers 4 modes: scientific, financial, statistics and a number conversion mode called programming mode. This mode has however nothing to do with programming of the calculator (like the x48 or hp67). It offers everything that you would expect from a desktop calculator.

To use the units conversion menue you need to install the units(1) command (from ftp://ftp.gnu.org/gnu/units/, already part of most Linux distributions).
Name:gdcalc
Homepage:http://bhepple.freeshell.org/dcalc/unix/
License:GPL

 

grpn

This is a an RPN calculator also based on a gtk user interface. It offers basic algebra and trigonnometric functions.
Name:grpn
Homepage:http://lashwhip.com/grpn.html
License:GPL

 

galculator

This calculator is in its functionallity very similar to gdcalc. You can configure it to use RPN or algebraic entry method. It supports number conversion bin/hex/dec and has all basic scientific functions.
It uses however the very latest gtk libraries (gtk 2.2). You will therefore have trouble to install it on older Linux systems. It is however well designed and has a plesant user interface.
Name:galculator
Homepage:http://galculator.sourceforge.net/
License:GPL

 

calcoo

This is an old calculator. You can configure it for either RPN or algebraic mode. It is good for basic algebra and trigonometry.
Name:calcoo
Homepage:http://calcoo.sourceforge.net
License:GPL

 

Kalk

This is a basic (but free) RPN calculator for the palm pilot. The palm does not run Linux but I present this one here because it is available under a GPL license (a rare thing for palm software).
Name:kalk
Homepage:http://www.klawitter.de/palm/kalk.html
License:GPL

 

GCalc

This is not an RPN calculator at all but it is still very very useful. It is a java based online graphing calculator. To use it you need the java plugin for mozilla or netscape, part of the jre package from blackdown.org. You can instantly draw graphs in a java capable webbrowser.
Name:GCalc
Homepage:http://humblestar.net/GCalc/
License:GPL
 

Conclusion

As you can see there are RPN calculators for every taste. There are probably even more RPN calculators but the above ones are all GPL licensed.  

References



Webpages maintained by the LinuxFocus Editor team
© Guido Socher
"some rights reserved" see linuxfocus.org/license/
http://www.LinuxFocus.org
Translation information:
en --> -- : Guido Socher (homepage)

2005-01-14, generated by lfparser_pdf version 2.51