On Line RPN Calculator
On Line RPN Calculator
Contents
Intro
Screen Display Control
Basic Math
Transendental Functions
Loan and Payment Functions
Statistical Functions
Repeat Commands
Unit Conversions
Stack Control
Variables
User Defined Functions
RPN Calculator Examples
Intro
The RPN calculator is a powerful tool for doing things you might normally
do with a calculator, and more. It uses Reverse Polish Nomenclature (RPN)
in its expressions, numbers first, followed by operators, similar in concept
to my trusty HP HP48GX RPN Expandable Graphic Calculator.
For example,
to add two numbers: 25 19 + places the two numbers on the stack, and
performs the add operation, leaving the result on the stack.
The RPN calculator gives users the ability to create their own functions,
and with a single function they could make calculations that fill all 26
variables. This minimal programming ability is what amplifies the calculator's
usability above most all traditional calculators. It's handily available
for anyone with an internet connection, ready for any college or university
student, or anyone else needing math, financial, statistical or other
general calculater functions.
All operators work with the stack. Math operators work with the top
value(s) on the stack and leave results on the stack. Memory operators
move values either from the stack to the variables a thru z , or
from the variables to the stack.
The program is different from most calculators in that one can either enter
commands into the command window, or click on function buttons. It's also
different in that with a typical calculator, clicking on a button performs the
indicated operation. With this calculator, clicking on a button other than
Enter places the command in the command window. Multiple calculations
can be entered, then pressing the keyboard enter key or clicking on the
Enter button executes the command(s).
Because some of the more powerful aspects are best implemented with a
keyboard, the calculator works very well with Desktops,
Laptops,
and Chromebooks.
However, the keypad utilty does make it work pretty well with Tablets
as well. The RPN calculator has been successfully tested with Google Chrome,
Firefox, Seamonkey, Opera, and an Android tablet and Android phone.
The command box concept may seem awkward at first, but offers some real
power as you learn the calculator. For example, one can enter the command:
10 20 30 40 50 60 all nput a to put the values 10 thru 60 into variables
a thru f , all as one statement. Commands are saved in a history
and can be recalled for editing and reuse by clicking on the History
button. More power is available when you learn how to define your own
operations
Menu
Display Control Operators
Screen control operators select the keypad mode to display, and the numeric
display format The keypad selections are only available through button clicks.
The numeric display functions can be keyboard or keypad selected.
Example  Result 
ee  Switch numeric display to/from exponential format 
3 nd  Switch numeric display to 3 decimal places 
cls  Clear all values from stack 
clm  Clear all variables 
Math Ops  Sets keypad to basic math operators 
Stats Ops  Sets keypad to statistical operators 
Units Ops  Sets keypad to unit conversion operators 
User Keys  Sets keypad to user defined operators 
User Defs  Sets keypad to user definition display 
Menu
Basic Commands
The basic math operators, like +, , *, / (for add, subtract, multiply, and
divide), all work with pairs of numbers on the stack.
Example  Result 
30 neg  Negate 30, leaves 30 
30 +/  Keypad negate 30, leaves 30 
10 20 +  Puts 10 and 20 on the stack and adds them, leaving the sum. 
30 14   Subtracts 14 from 30 (top is subtracted from next level). 
3 8 *  Multiplies 3 times 8, leaving result on stack. 
33 12 /  Divides 33 by 12, leaving result on stack. 
10 sqr  Square the number 10 
13 sqrt  Compute square root of 13 
2 1/x  Compute reciprocal of 2, result is 0.5 
int  Leave integer portion of top stack value 
frac  Leave fractional portion of top stack value 
min  Leave mininum of top two stack on stack 
max  Leave maximum of top two stack on stack 
Menu
Transcendental Operators
Note, all of the trig functions work with radians. Use the rad
operator to turn the top stack value into radians, and deg operator
to go back to degrees. For example, to get sine of 30 degrees:
30 rad sin. To get arcsine of .5 as degrees: .5 asin deg.
Example  Result 
pi  Put value of PI on the stack 
30 rad sin  Returns sine of 30 degrees (converts to radians first) 
25 rad cos  Returns cosine of 25 degrees. 
45 rad tan  Returns tangent of 45 degrees. 
.5 asin deg  Returns arcsine of .5 as degrees. 
.5 acos deg  Returns arccosine of .5 as degrees. 
.5 atan  Returns arctangent of .5 as radians. 
300 log  Returns the base 10 log of 300. 
300 ln  Returns the base e log of 300. 
3 exp10  Raises 10 to the power of 3. 
3 exp  Raises e to the power of 3. 
12 3 ^  Raises 12 to the 3rd power. 
Menu
Loan, Payment, and Date Functions
The calculator can calculate loan values for given payment, interest, and
number of period values, or calculate payment values for given loan, interest,
and number of period values. Each operation expects the values on the stack in
a specific order: loan interest nperiods or payment interest nperiods. Interest is percent per year, and periods are months.
Example  Result 
5000 6 36 pmt  Calculates payment for a $5000 loan at 6 percent for 36 months 
200 6 36 loan  Calculates loan value for a $200 payment at 6 percent for 36 months 
200 6 36 12 ppaid  Calculates principal paid on $200 loan, 6 pct, 36 months, after month 12

200 6 36 12 pleft  Calculates principal left on $200 loan, 6 pct, 36 months, after month 12

date  Places month, day, and year on stack

Menu
Statistical Functions
The RPN calculator has a number of statistical and probability functions.
These often work on several values at once, either on the stack or in a
consecutive range of variables. For example, the fit function will
compute the slope and offset of a range of values assuming that the X values of
a Y=mX+b equation is a simple count, 1, 2, 3, ... . This will work for any data
that's obtained at equal increments in time for example, like daily, or
monthly.
The res function, given the same range used in the fit
function, will compare the range variable values against the computed
line and leave a corresponding list of fit errors on the stack. For
example: fit a g computes a slope and offset from values in
a thru z , and res a g will compare the computed line
values with the values in a thru g, leaving the errors on the stack. The
computed slope and offset are left on the stack, and saved internally for
options that need them.
The x2y function uses the most recent fit results to compute
corresponding Y values for any given range of X values on the stack, again
assuming Xs of the fit interval were 1 thru number_of_points. This can be used
to compute Y values for any X values, within or outside of the original fit
range. For example, for fit a e, variables a thru e amount
to 5 points, which assume X values from 1 to 5. To extrapolate the next few Y
values from the fit, put the desired X values on the stack and use the
x2y operator. 6 13 x2y will extrapolate the 5 point line to
give Y values for X values 6 thru 13. X
The do operator iterates an operation, placing each value of a
variable range on the stack prior to calling the desired function. The operator
looped upon must be a single operator, but using a user defined operation, this
can lead to significant power.
As a simple example, do a f log computes the log of each value from
variables a thru f, leaving the results on the stack. 5 nput n would
place the log values in the display's second column beside the original values
in the expected order.
But suppose you wanted the log of each number in base 2? Since do can
only repeatedly execute a single operation, just define your own operator as
follows: def log2 log 2 log /, which takes the log of a passed in (on
the stack) value, and divides by the log of two, which leaves the log in base
2. Then do a f log2 would execute your definition, which has been
reduced to a single name using def.
Example  Result 
6 !  Computes 6 factorial, or 720 
13 3 nCr  Computes the number of combinations of 3 in 13 
13 3 nPr  Computes the number of permutations of 3 in 13 
0 12 2 seq  Generates sequence from 0 to 12 with increment 2 
sum a f  Computes the sum of variables a thru f 
avg a f  Computes the average of variables a thru f 
var a f  Computes the variance of variables a thru f 
std a f  Computes the std deviation of variables a thru f 
ssum  Computes the sum of all stack values 
savg  Computes the average of all stack values 
svar  Computes the variance of all stack values 
sstd  computes the std deviation of all stack values 
fit a f  Fits a line thru variables a to f and leaves offset and slope on stack 
res a f  Computes the residuals of the last line fit 
7 10 x2y  Extrapolates the line fit at X values 7 to 10 
do a c sqrt  Computes sqrt of values in a thru c, leaving 3 values on stack 
Menu
Unit Conversion Operators
The calculator has a number of built in unit conversions. These can
be used in sequence to get conversions not already defined. For example,
to get a conversion from kilometers to inches: 3 km2mi mi2yd yd2ft ft2in.
Of course, if you needed such a conversion often, you could define it as
a new operation thus: def km2in km2mi mi2yd yd2ft ft2in. Then you
could use the new operation as follows: 10 km2in.
Example  Result 
30.5 d2hms  converts degrees to hms format: 303000 
304500 hms2d  converts hms format to degrees: 30.75 
3 ft2in  Converts 3 feet to 36 inches 
42 in2ft  Converts 42 inches to 3.5 feet 
4 yd2ft  Converts 4 yards to 12 feet 
30 ft2yd  Converts 30 ft to 10 yards 
2640 yd2mi  Converts 2640 yards to 1.5 miles 
1.5 mi2yd  Converts 1.5 miles to 2640 yards 
3 in2cm  Converts 3 inches to 7.62 cm 
7.62 cm2in  Converts 7.62 cm to 3 inches 
6 ft2m  Converts 6 feet to 1.8288 meters 
1.8288 m2ft  Converts 1.8288 meters to 6 feet 
3 yd2m  Converts 3 yards to 2.7432 meters 
2.7432 m2yd  Converts 2.7432 meters to 3 yards 
3 mi2km  Converts 3 miles to 4.82... km 
10 km2mi  Converts 10 km to 6.2... miles 
300 ci2cc  Converts 300 cubic inches to 4916... cc 
5200 cc2ci  Converts 5200 cc to 317... cubic inches 
6 qt2lt  Converts 6 quarts to 5.6... liters 
10 lt2qt  Converts 10 liters to 10.5... quarts 
10 gal2lt  Converts 10 gallons to 37.8... liters 
10 lt2gal  Converts 10 liters to 2.6... gallons 
6 gal2cf  Converts 6 gallons to 0.8... cubic feet 
3 cf2gal  Converts 3 cubic feet to 22.4... gallons 
30 lb2kg  Converts 30 pounds to 13.6... kilograms 
30 kg2lb  Converts 30 kilograms to 66.1... pounds 
95 f2c  Converts 95 deg Fahrenheit to 35 deg Celsius 
40 c2f  Converts 40 deg Celsius to 104 deg Fahrenheit 
Menu
Stack Control
Don't be confused by the stack. It's easy to view it as an array, but it's
actually just a history and temporary repository for values used by operations.
The newest entry is on top, and the older ones below. Operators that work on
stack numbers use the newest ones (top values).
If you enter 10, 20, and 30, for example, the stack shows:
30
20
10
The 10 was entered first, and is thus on the bottom of the stack. However,
if you use 3 nput a to put the 3 numbers into a, b, and c, you'll
see:
a 10
b 20
c 30
The oldest entry is in a, and so on. Why? Because you'll often want to
preset variables for computations, and the natural inclination is to put the
values in consecutive variable order, like a series of interest values in
a thru e . For example: 2 4 5 8 10 all nput a would show
a with 2, b with 4, and so on. It seems right. So the variables
can be thought of as an array, but remember that the stack is just a history.
That can make it appear upside down for the bulk memory operations.
It's often handy to be able to manipulate values on the stack, especially
when making user definitions. Most of these move values from the stack to
variables, or vice versa. Some manipulate the top few values, and are simple
but often indispensable operators.
Example  Result 
dup  Duplicate the top value on the stack 
swap  Swap the top two values on the stack 
drop  Drop the top value from the stack 
cls  Clear all stack values 
> z  Store top stack value into z 
a  Place value in variable a on top of stack 
put x z  Put top 3 stack values into z, y, and x 
3 nput a  Put top 3 stack values into c, b, and a 
get a d  Copy variabls a thru d onto stack (a oldest) 
3 nget a  Copy 3 variables starting with a onto stack 
Menu
How To Use Variables
The calculator has 26 variables, labeled a thru z . You can
store the top value to a variable or place the contents of a variable on the
stack. You can also store a number of stack values (or all) to a contiguous
range of variables with a single command, and likewise place a range of
variable values back onto the stack.
Example  Result 
all  Put stack depth on top of stack 
> x  Store top stack to variable x 
= x  Store top stack to variable x 
a  Put value in variable a onto stack 
put a c  Put top 3 stack values into a thru c 
4 nput w  Put 4 stack values in w thru z 
all nput a  Put all stack values starting at a 
get c e  Get values in c thru e and put onto stack 
3 nget x  Get 3 values starting at x and put onto stack 
Menu
User Defined Functions
One of the most powerful features of the calculator is the ability of a
user to create his/her own function definitions. Each definition can use
any constants, variable references, and existing functions. User definitions
can also refer to other user definitions.
The User Keys button on the keypads brings up a keypad that
lists user defined functions as clickable functions. The User Defs
keypad shows the actual definitions of each user defined function. Note
that any functions that used the do operator have been expanded with
the do replaced with the respective variable references and repeated
function reference.
A simple example might be to define a word to aid in the calculation of
payment values for long term loans, where months is cumbersome. You
could do: def years 12 * as a new function, which multiplies a year
value on the stack by 12, converting it into months. Using it with the
pmt function would be: 75000 6 30 years pmt. You see that
prior to the execution of the pmt operator, loan value, interest,
and months would be on the stack.
If you've allowed cookies, the save command will save the
calculator state (variables, numeric display format, and user defs) in
year long cookies. If you want to get rid of all browser cookies, you can
load the RPN calculator web page first, clear cookies, then save, to
allow clearing of all other cookies, but still keeping your user defs.
The ed function, such as: ed years to edit definition years,
will put the definition of an operation in the command window. After editing,
the keyboard enter or Enter button will resave the new definition.
clearing the command window before Enter will simply remove the
definition.
As new and more useful definitions of your own occur to you, you may find
that you wish you could rearrange your userdefined buttons. With the
move command, you can do that. The move function is available on
the User Keys and User Defs keypads. To use it, just click on
move, then the user definition you'd like to move, then the user
definition that you wish to have preceding the moved definition. move
places the first definition after the second one.
It's possible to have 75 or more user defs in a cookie. The User Keys
keypad displays up to 25 at a time. The Next and Prev buttons
allow you to move through your user defs if you have more than 25 defined. If
you are at the first row, the Prev button doesn't show. Likewise, if
your are at the end of your defs, the Next button doesn't show.
For example, assume you have a sum1 command, and some time later you
create a sum2 command. But they are just in the user definition list in
the order you created them, and may not be together. So you could in order
clickmove sum2 sum1 to have button sum2 placed just after
sum1. Use the move function to arrange your user buttons in the most
comfortable order.
Example  Result 
def years 12 *  Defines an op that would convert years to months 
def mypmt 5000 swap 36 pmt  Defines an op that would assume a 5000 loan for 36 months, but take interest from the stack. Like 12 mypmt. See how swap puts arguments in proper order? 
undef  Removes most recent def, but puts the def command in history 
sdefs  List defs to screen so user can copy and save them locally. Pasting the saved text in command window and Enter will restore them. 
cldefs  Remove all user definitions, but place in history 
ed years  Places definition of user def years in command window for editing 
move user1 user2  Moves the user command user1 just after
user command user2 
Next  If shown, moves forward one row of user defs 
Prev  If shown, moves back one row of user defs 
save  Save current calculator state in year long cookies. Saves variables, numeric display mode, and user definitions 
Menu
