MathU Pro™ 4.2

Programming and Function

Reference

IMPORTANT: If you do not see any images and are running Windows XP you need to extract the files from the .zip archive before viewing. Open the .zip file and select "Extract All Files".


What is in this reference?

This guide contains detailed descriptions of the functions and program steps available with MathU Pro. See the MathU Pro Users Guide for information on how to use MathU Pro. See the MathU Pro Solver Guide for information on how to use the Solver.


Contents

MathU Pro

Best Pocket Calculator
three years in a row!

MathU Pro has been selected for the ITM praktiker Bestenliste a listing of best hardware and software products for Palm OS and Windows Mobile
2005, 2006 and 2007.

Stack and Register Functions

[Back to Top]

MathU Pro has 20 registers and a 16 high stack. The two are separate so there are a total of 36 memory locations. Programs have access to these 36 locations as well as an additional 1024 registers that are private to each program (see Local Registers below).

The 20 registers are organized into two banks of ten each. They are numbered from 0 to 19. Registers 0 to 9 are accessible directly from the keyboard (e.g., RCL 2). The registers 10 through 19 are accessible from the keyboard via RCL . n (e.g., RCL . 2). The secondary registers are used by the statistical and financial functions to store their results.

When you perform a swap via p<>s (available from the popup XEQ menu), the contents of the first bank (registers 0-9) are swapped with the second bank (registers 10-19). Another p<>s puts them back where they were. You will probably want to swap them back before continuing with any statistical or financial calculations. The secondary registers can be used to store values in your own programs but you must be careful not to use any financial or statistical functions if you do so.

The function allows you to view the values in the registers and stack without having to swap them.

The stack is 16 high which can wrap around if you do a roll up or roll down (these functions are mapped to the hardware scroll buttons on the Palm). During number entry the top value (stack position 15) is just lost off of the top.

The stack positions are numbered from 0 to 15 with the first four named x,y,z,t as is the custom for RPN calculators.

The value of the x register is what is displayed.

Executing the CLREG function, clears the 20 registers but not the stack. The CLSTK function clears the stack but not the registers. The CLSTATS function clears only the statistics registers. The CLFIN function clears only the financial registers. Finally, CLX clears only the x stack register.

Key Function Description Stack effect
n sto Store into register n. Specify n to access the secondary register (register 10+n)  
fn sto Store into financial function. fn can be , ,,, or a capable user-written function. See Supporting STO and RCL in your own programs.
n sto Add contents of x register to register n. Specify n to access the secondary register (register 10+n)  
n sto Subtract contents of x register from register n. Specify n to access the secondary register (register 10+n)  
n sto Multiply register n with contents of x register. Specify n to access the secondary register (register 10+n)  
n sto Divide register n by contents of x register. Specify n to access the secondary register (register 10+n)  
n rcl Recall from register n. Specify n to access the secondary register (register 10+n)
fn rcl Recall financial register. fn can be , , , , , or
rcl Recall statistics sums
  Display the register, stack, and variables screen  
p<>s Swap primary and secondary banks of registers  
x<>y Exchange x and y registers
lastx Recall last x value
clx Clear x register  
clstk Clear stack  
clreg Clear all registers  
  clfin Clear financial registers (registers 10 through 14)  
  clstats Clear statistical registers (registers 9 and 15 through 19)  
  clvars Clear all local variables. Reclaims the space taken by the local variables (registers 20 through 1043).  
scroll up button on Palm rollup Rotate stack contents up
or scroll down button on Palm rolldown Rotate stack contents down
enter Push current value onto stack. Set overwrite flag.
  drop Pop value off of stack
undo When entering a number undo the last character, otherwise clear the x register the same as clx.  

Within a program, the sto, rcl, decr, and incr functions have direct access to the 20 global registers, the first 26 variables (those with names A-Z), as well as the stack. All other registers must be accessed indirectly (described in the next section).

Supporting and within your own functions

Supporting sto and rcl within your function is easy to do:

  1. Set the "Sto/Rcl OK" checkbox on any function label that can handle sto and rcl.

  2. Use "if sto" or "if rcl" to query the sto/rcl state. The sto flag will be set when the user has tapped just before executing your function. Likewise the rcl flag will be set when the user has tapped just before executing your function.
  3. If you wish to support register arithmetic, select "op" from the operation pop-up for any sto function you wish to perform the requested register arithmetic.

Here's an example program that performs these steps:

When executed from the keypad, BETA adds the current x stack value to register A. Similarly BETA divides register A by the current x stack value. BETA pushes the current value of register A onto the stack and executing BETA computes its value.

Local Registers (variables)

[Back to Top]

Each program can access up to 1044 registers. The first 20 of these are the global primary and secondary registers discussed above. The next set of 26 registers (registers 20 though 46) correspond to the variables A-Z in the register pop-up for the sto, rcl, decr, and incr functions. The remaining 998 registers are accessible only via an indirect access. An indirect access uses the value in the specified register as the address of the register to access. To perform an indirect access, just select the "Indirect" checkbox when setting the target register.

The absolute value of the integer part of the value in the specified register is used as the address. For example, both -105 and 105.9 address register number 105. If the value in the register is outside the range from -1043 to 1043 an error is thrown.

Unlike the 20 global registers (registers 0 through 19), the registers 20 through 1043 are stored locally to each program and are persistent. These values are transferred with each program during a HotSync or beaming. This means that you can use them to safely store constants that are needed by your program. The registers are allocated in banks of 32 up to the maximum register used in your program so keep your register addresses small to conserve space.

Use the function clvars in your program to clear the local register area (registers 20 through 1043) and reclaim the space taken up by them. You might want to use this function if your program doesn't require the local registers to be persistent.

Limitation: When the program database is stored in read only memory (say in flash memory), MathU Pro will not be able to change the values in local registers and will throw an error.

Number Entry Functions

[Back to Top]

Function Description
0 through 9
A through F
const
.
eex
chs
nop
numerals
hexadecimal numerals
numeric constant (pushes constant onto the stack)
decimal
start entering exponent
change sign of mantissa or exponent
no operation (do nothing)

Control Flow Functions

[Back to Top]

Function Description
beep Beep. Make a simple sound.
clrf Clear flag. See Flags section for descriptions of the flags.
continue Jump to the beginning of the enclosing loop if the condition is true.
decr Subtract one from the value in a register and optionally exit, continue, or skip if the value crosses zero.
error Throw an error (jumping to the error handler if one has been defined).
exit if Exit from enclosing loop if the condition is true.
goto Jump to a specified label.
gosub Remember current step and jump to the specified label. When a return step is executed, the subroutine returns and execution continues with the step following the gosub.
if ..
elseif ..
else ..
endif
Structured If statement. All the steps between the If and the next elseif, else, or endif are executed if the condition is true. The steps between the else and endif are executed if the condition is false. If's can be nested and the elseif or else is optional.
incr Add one to the value in register and optionally exit, continue, or skip if the value crosses zero.
label Used to mark a location in the program. You can jump to a label via goto, start to execute a subroutine there via gosub and assign labels to keys on the keyboard. When executed, labels have no effect. labels are shown in bold when they are assigned to a button. When the Sto/Rcl OK checkbox is checked, this label will allow store and recall operations. When unchecked, the sto/rcl state is just reset when the label is executed.
loop ... endloop Infinite loop. The statements between the loop and endloop are executed repeatedly until either an error occurs or a goto, gosub, exit, continue, decr, or incr step is executed. loop's can be nested.
nargin Number of input arguments. The number of ENTER separated values keyed into the calculator before running a function.
on error Define error handler. Execution will jump to the specified label when an error occurs. Set this to <not set> to use the default error handler (i.e., stop execution and display error indicator).
pause Stop for a moment (2 seconds) to display the current value in the x register and then continue.
prompt Display prompt string and wait for numeric input. The prompt dialog

is displayed when the prompt function is executed. The program blocks until the user hits the Enter or Cancel button. The initial value is taken from the x register, The value input overwrites the x register when the user hits Enter. An error occurs if the cancel button is pressed. This function is useful for gathering parameter values in your programs.

return Return from gosub or stop if no gosub's are active.
setf Set flag. See Flags section for descriptions of the flags.
show Show a string in the display. The string will be shown until the next time the display changes. This is used by the financial functions to show the name of each finance result.
stop Stop execution temporarily. The statistics plus key changes to the R/S key.

When the R/S key is pressed execution resumes with the step following the stop step. This function is useful for displaying intermediate results. If another function within the same program is executed, the stopped state is lost and the R/S key will revert back to the statistics button. The R/S key will also be displayed if the debugger is active and stopped.

skipif Single line If. Skips over the next program line if the condition is true.

Flags

[Back to Top]

MathU Pro has ten flags. Five of these are changed by MathU Pro or some of the built-in functions, the others are freely available for your own use. The entry flag can only be tested. It cannot be set or cleared by a program.

Special Characters

[Back to Top]

MathU Pro can display several special characters on key labels and other strings that are displayed in MathU Pro's small font. These characters are specified via special '\' shift sequences. The backslash itself is specified by '\\'.

Sequence
Character Description
\>
exchange or swap
\x
x register
\y
y register
\e
base e
\X
script x
\P
pi
\C
Delta
\1
inverse
\/
divide
\\
backslash
\S
Summation symbol (capital sigma)
\p
x superscript (power)
\q
square root
\i
inverse or reciprocal
\t
small ten
\2
squared superscript
\3
cubed superscript
\4
4th power superscript
\-
minus superscript
\+
plus superscript
\s
standard deviation (lowercase sigma)
\m
mean
\l
left arrow
\r
right arrow
\d
down arrow
\u
up arrow
\D
down triangle
\U
up triangle
\L
left triangle
\R
right triangle
\T
popup triangle
\*
degrees symbol

To use these in your key labels or SHOW strings, insert the appropriate shift sequence where you want the special character to appear. For example, to recreate the string used for the register swap (i.e. ) use 'p\>s'.

Preference Functions

[Back to Top]

These functions are used to set and get various preferences. They all use the value in the x register to set the preference and replace the x register with the old value.

Function Description
dsp Display format. Possibilities are 1 - fix, 2 - sci, 3 - eng. All others set fix.
digits Number of display digits. 0-9 sets that number of digits. Anything else (like -1) sets ALL.
angle Angle mode. Possibilities are 1 - deg, 2 - rad, 3 - grd. All others set deg.
base Number base. Possibilities are 10 - decimal, 2 - binary, 8 - octal, 16 - hexadecimal. All others set dec.
annuity Financial annuity mode. Possibilities are 0 - annuity due (payments due at the beginning of the period) and 1 - ordinary annuity (payments due at the end of the period). All others set it to ordinary annuity.
wordsize Number of bits to use for base conversion functions. Possibility are numbers between 1 and 48. All other values set it to 32 (the default).

Trigonometric Functions

[Back to Top]

The trigonometric functions are sensitive to the angle mode: degrees, radians, or grads (deg, rad, or grd in the display where 360 degrees = 2 pi radians = 400 grads).

Set the angle mode using the Preferences dialog (available from the Display menu) or via the angle function. Except for atan2, these functions operate on the value in the x register and replace it with the function result (f(x)).

Function Description
sin
cos
tan
asin
acos
atan
atan2
sinh
cosh
tanh
asinh
acosh
atanh
pi
deg
rad
sine
cosine
tangent
arcsine
arccosine
arctangent
two argument arctangent: same as atan(y/x) but in the correct quadrant
hyperbolic sine
hyperbolic cosine
hyperbolic tangent
hyperbolic arcsine
hyperbolic arccosine
hyperbolic arctangent
pushes the value of pi (3.14159...) onto the stack.
Radians to degrees conversion
Degrees to radians conversion

Scientific Functions

[Back to Top]

The unary functions operate on the value in the x register and replace it with the function result (f(x))

while the binary functions use the values in both the x and y registers and place the result in the x register.

Function Description Type
abs
cbrt
chop
mod
log
ln
ln1p
exp
expm1
pow10
ytox
inv
sq
sqrt
round
floor
ceil
int
frac
+
-
*
/
absolute value
cube root
round value to display precision
modulo remainder of y/x: (y - x * floor(y/x))
base 10 logarithm
natural logarithm
ln(1 + x) more accurate for x near zero
exponential function (natural antilogarithm)
exp(x) - 1 more accurate for x near zero
ten to the power of x
y to the power of x
reciprocal 1/x
x squared
square root
closest integer to x
largest integer smaller than or equal to x
smallest integer larger than or equal to x
integer part
fractional part
addition
subtraction
multiplication
division
unary
unary
unary
binary
unary
unary
unary
unary
unary
unary
binary
unary
unary
unary
unary
unary
unary
unary
unary
binary
binary
binary
binary
 

The int and frac functions round to 9 decimal digits before determining the integer and fractional parts. Under this definition frac is computed using the formula

frac(x) = x - int(x)

Most of the time this produces the desired results but does treat the input as if it only had 10 digits of accuracy. One of the ramifications of this is that the fractional part doesn't always have the same sign as x. Take for example the number 1.99999999964 (i.e. 2 - 36e-11). When displayed in MathU Pro this number looks like it is 2.0. Because of the rounding int(x) is 2 (as expected) while frac(x) is -36e-10.

The ceil, round, and floor functions do not do this rounding and may be more appropriate to use if you need to take advantage of all 16 digits of accuracy that MathU Pro maintains. These functions have the following properties

x - floor(x) >= 0 ceil(x) - x >= 0 round(x) is ceil(x) when x >= 0.5 otherwise round(x) is floor(x)

Time Functions

MathU Pro has three time functions

Polar Coordinates

MathU Pro provides two functions to convert back and forth between Cartesian (rectangular) coordinates and polar coordinates. The relationship between polar coordinates and Cartesian coordinates is defined by the following picture and formula

x = R cos(theta)
y = R sin(theta)
R = sqrt(x2 + y2)
theta = atan2(y,x)
Key Function Description Effect on stack
R->P Convert from Cartesian coordinates to polar coordinates
P->R Convert from polar coordinates to Cartesian coordinates

Number Base Functions

[Back to Top]

MathU Pro can display and compute with numbers in hexadecimal (base 16), octal (base 8), and binary (base 2) format as well as the default decimal (base 10) format. Non-decimal values are displayed with a subscript following them indicating the number base. The number base functions honor the wordsize set in the preference screen.

hexadecimal display
octal display
binary display

The functions hex, oct, bin, and dec convert values between bases and set the number base for further calculations and input. Use any combination of the numeric buttons and Graffiti to input non-decimal numbers. You must use graffiti to input the hexadecimal characters A through F since no buttons exist on the calculator for them. They do exist as program steps however.

Function Description
hex Convert x register to hexadecimal number base.
oct Convert x register to octal number base.
bin Convert x register to binary number base.
dec Convert x register to decimal number base.
and Bitwise AND of x and y
or Bitwise OR of x and y
xor Bitwise XOR of x and y
wordsize Number of bits to use for base conversion functions. Possibilities are numbers between 1 and 48. All other values set it to 32 (the default). Replaces the value in x with the current wordsize.

Values outside the wordsize are wrapped (that is, the excess most significant bits are dropped) and are converted to an integer. The display will automatically switch to a smaller font when large numbers are viewed in oct or bin format. Large binary numbers may wrap on the display as well.

Modular Functions

[Back to Top]

A few functions behave differently when a non-decimal number base is chosen:

Key Function Description
Two's complement. Replace x register with its two's complement (all bits inverted and 1 added)
+
Modular addition. Same as regular addition except that results that exceed the wordsize are wrapped.
-
Modular subtraction. Same as regular subtraction except that negative results are returned as two's complement numbers.
*
Modular multiplication. Same as regular multiplication except that results that exceed the wordsize are wrapped.
/
Modular division. Same as regular division except that results that exceed the wordsize are wrapped and any fractional remainder is discarded.

The other functions on the calculator can be applied to non-decimal numbers. However, if the result is not an integer that is in range, an error is displayed and the number base reverts to decimal. The value in the x register will be the result of the computation. Simply reapply the conversion routine to wrap and truncate the value to be in range.

Financial Functions

[Back to Top]

The financial functions are governed by the equation,

PV*(1+i)N + PMT/i*((1+i)N-1) + FV = 0

This equation is used when the annuity mode (BEGIN/END preference) is set to ordinary annuity (payments due at the end of the period ). When the annuity mode is annuity due (payments due at the beginning of the period ) then PMT in this equation is modified to be PMT * (1 + i).

The financial functions have two modes: input mode and calculation mode. MathU Pro is in input mode if a number has been keyed into the calculator or any non-financial functions have been executed. Executing one of the main financial functions (, , , , or ) stores the displayed value in the associated financial register. MathU Pro is in calculation mode after any financial functions have been executed and before any other functions that change the stack are executed. The result of a financial computation is pushed onto the stack:

Most of the time this should behave as you would expect. However, if for some reason MathU Pro stores a value when you intended to compute one, simply execute the financial function again to obtain the desired result.

Key Function Description Details
N Number of periods Input mode: Store displayed value as N.

Calculation mode: Compute N.

interest Interest rate per period Input mode: Store displayed value as i (in percent).

Calculation mode: Solve for i. If the solver doesn't converge an error '-e-' will be displayed.

pmt Payment per period Input mode: Store displayed value as PMT.

Calculation mode: Compute PMT.

pv Present value Input mode: Store displayed value as PV.

Calculation mode: Compute PV.

fv Future value (or balloon) Input mode: Store displayed value as FV.

Calculation mode: Compute FV.

  annuity Set annuity mode preference. Uses value in x register to set preference. Replaces x register with current preference value. Possibilities are 0 - annuity due (payments due at the beginning of the period) and 1 - ordinary annuity (payments due at the end of the period). All others set it to ordinary annuity.
clfin Clear financial registers and set payment period to the end (ordinary annuity).  
rcl Recall financial register. Any of the financial functions (, , , , ) can be used in place of to recall the corresponding register. Recalls the value in the register without calculation. The value returned may not be consistent with the other financial values.
sto Store value into financial register. Any of the financial functions (, , , , ) can be used in place of to store into the corresponding register. Always stores the value into the register regardless of the input or calculation mode.

The sign of PMT and FV is dependent on the state of the cash flow convention preference. When you are not using the cash flow convention, the label for PMT and FV are followed by a asterisk: PMT*, FV*.

Cash Flow Convention

Financial problems can be thought of as a series of cash flows. For example a mortgage consists of a large positive cash flow (the loan amount) followed by a series of monthly negative cash flows (the payments) with possibly a final negative cash flow at the end (the balloon payment). The diagram below illustrates this situation.

Positive cash flows (amounts you receive) are shown as upward pointing arrows. Negative cash flows (amounts you pay) are shown as downward pointing arrows. The horizontal axis of the diagram is time, with time increasing to the right. The time between the equally spaced payments is called the period.

For the problem to be solvable with MathU Pro, there must be at least one cash flow in each direction. It is always possible to add a present value or future value cash flow to meet this requirement. Think about your problem to determine which is more appropriate (see example 4 below).

Examples

Example 1: Suppose you are interested in determining the payment for a car loan of $18,500 at 7.25% interest for 5 years. The key strokes to solve this problem using MathU Pro are

  1. to reset the financial registers (since the values in the registers are maintained between sessions with MathU Pro it is a good idea to reset the financial registers before each use of the financial functions).
  2. to set the number of periods (in months)
  3. since the interest per month is 7.25/12 %
  4. to set the principal or present value of the loan
  5. to compute the payment per period (ans: $-368.51). The value is negative because the payments are made in the opposite cash flow direction from the principle cash flow. [If it makes more sense to you for the payment to be positive, unselect the "Use cash flow convention" preference.]

Example 2: What is the payment if you are willing to pay a balloon payment of $2,000 at the end of the loan?

  1. Set the value $-2,000 as the FV (balloon) for the loan. The value is negative because this is money you will pay out.
  2. to compute the new payment per period (ans: $-340.75)

Example 3: How much interest do you end up paying with the balloon payment?

  1. to compute the total payments minus the loan value
    (ans: $-3,945.17). Note that and had to be pressed twice since the first time stored the total payments into FV and PV.

Example 4: To compute the effective interest rate in an IRA account that you put $2000 into each year, you will need to enter the current value of the account as a positive future value (FV) even though you haven't sold the assets in the account. To make the example concrete, suppose that you started your IRA in 1985 with a $10,000 rollover and that the value in the account is $80,000 in the year 2001.

  1. to reset the financial registers
  2. to set the number of periods (in years)
  3. to set the starting value of the account. The value is negative since you added this value to the account with the rollover.
  4. to set the annual contribution.
  5. to set the current value of the account. The value is positive since this is the money you would receive if you sold all the assets in the account.
  6. to compute the effective annual rate of return in the account (ans: 6.39%)

Statistical Functions

[Back to Top]

The statistical functions accumulate sums based on the values in the x and y stack registers. These sums are used to compute the mean and standard deviation or can be accessed directly via and . Use to reset all the statistical registers to zero before accumulating sums. If you make a mistake keying in the x,y values and after pressing , re-key the errant values and press to remove them from the sums. The mean and standard deviation are computed as

with similar equations holding for the y component as well.

If you check the Accumulate sum xy in reg 9 preference, then MathU Pro will also accumulate the xy cross term in register 9. This sum is important if you want to do linear regression.

Key Function Description Effect on stack
stats+ Accumulate x,y

n is the number of sums accumulated so far.

stats- Remove x,y

n is the number of sums accumulated so far.

mean Mean
std Standard deviation
rcl Recall statistics sums
clstats Clear statistical registers  
fact Factorial  
  rand Random number from 0 to 1.0 (uniformly distributed)  
% Percent
% ch Percent change

Program Limitations

MathU Pro programs have the following limitations

Alphabetical List of Functions

[Back to Top]

Symbols
+
-
*
/
%
% ch
0 through 9
A through F

A
abs
acos
acosh
and
angle
annuity
asin
asinh
atan
atan2
atanh

B
base
base conversions
beep
bin
B/E

C
cart
cbrt
ceil
chop
chs
clfin
clreg
clrf
clstats
clrstk
clvars
clx
const
continue
cos
cosh
D
dec
deg
decr
digits
divide
dsp
drop

E
else
elseif
endif
end loop
enter
entry flag
error
exch x y
exit if
exp
expm1
exp(x)-1

F
fact
floor
financial functions
frac
fsolve
FV

G
gosub
goto

H
hex
H.MS
hours

I
if
incr
indirect recall
indirect store
int
interest
input flag
inv

L
label
lastx
ln
ln1p
ln(1+x)
local registers
log
loop

M
mean
minus
mod
modular plus
modular minus
modular times
modular divide
multiply

N
nargin
nop
N (number of periods)

O
oct
on error
or
overwrite flag

P
P->R
p<>s
pause
percent
percent change
pi
plus
PMT
polar
pow10
prompt
PV

R
R->P
rad
rand
rcl
rcl flag
registers
return
rolldown
rollup
round
S
seconds
setf
show
sin
sinh
skip if
sq
sqrt
stack
statistics
stats-
stats+
std
sto
sto flag
stop
swap p s

T
tan
tanh
times
t register
twos complement
U
undo
user flags

V
variables

W
wordsize

X, Y, Z

x<>y
x register
y register
xor
ytox
z register

Contacting Creative Creek

[Back to Top]

See the Creative Creek web site for up-to-date information about MathU Pro. If you have questions, suggestions, bug reports, or you just want to tell us how you much you like MathU Pro you can contact us at or on the web at www.creativecreek.com.

 

Copyright © 1998-2010 by Creative Creek and Clay M. Thompson -- All rights reserved.

Last updated: 10-May-2010