MathU Pro 4.2
for Windows Mobile
Programming and Function
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.
- Stack and Register Functions
- Number Entry Functions
- Control Flow Functions
- Special Characters
- Preference Functions
- Trigonometric Functions
- Scientific Functions
- Time Functions
- Polar Coordinates
- Number Base Functions
- Modular Functions
- Financial Functions
- Statistical Functions
- Program limitations
- Alphabetical list of Functions
- Buy MathU Pro
- Contacting Creative Creek
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:
- Set the "Sto/Rcl OK" checkbox on any function label that can handle sto and rcl.
- 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.
- 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:
label BETA (g 5) +r
sto op A
<code to compute beta>
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
numeric constant (pushes constant onto the stack)
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 ..
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.
[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.
- Entry Flag. This is true whenever MathU Pro is in the middle of number entry. It is set automatically after executing one of commands that is used to create numbers (i.e., 0-9 , decimal, eex, or A-F). It is automatically cleared when the number is used in any way. In addition, the entry flag is cleared by the LABEL and RETURN functions. This flag cannot be set or cleared but it can be tested.
- Overwrite flag. This is set whenever the X register is to be overwritten. Set automatically after an enter or clx. It is cleared automatically after the x register has been changed.
- Input flag. This is set if one or more of the data entry keys on the keyboard have been pressed since the flag was cleared. It is used by the financial functions to distinguish between input mode and calculation mode. You can use it in the same way to emulate their behavior. Here is how it is typically used001 label times 2 002 if input 003 sto 5 004 else 005 rcl 5 006 2 007 * 008 endif 009 clrf input 010 return
In place of the rcl 5, 2, * steps, put the calculation of your desired result. The step to clear the flag is very important and is required for proper behavior. MathU Pro will automatically set the flag but it won't clear it. Keep in mind that the input flag is cleared by the financial functions (i.e. clfin, N, interest, pmt, pv, fv).
- Sto flag. This flag is set when the user has tapped , , , , or before executing the current function. The current operation selected by the user can be accessed via the "op" operation on the "sto" step.
- Rcl flag. This flag is set when the user has tapped before executing the current function.
- User1-5 flags. These flags are for your own use. They are initially cleared when MathU Pro starts. The flags are named user1, user2, etc. and appear in pop-up lists when appropriate in the editor.
[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
pi \C Delta
Summation symbol (capital sigma)
x superscript (power)
inverse or reciprocal
4th power superscript
standard deviation (lowercase sigma)
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'.
[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).
[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).
- When in degree mode, inputs to sin, cos, and tan are assumed to be in degrees and the results from sin-1, cos-1, and tan-1 are in degrees.
- When in radian mode, the inputs and outputs are assumed to be in radians.
- When in grads mode, the inputs and outputs are assumed to be in 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
two argument arctangent: same as atan(y/x) but in the correct quadrant
pushes the value of pi (3.14159...) onto the stack.
Radians to degrees conversion
Degrees to radians conversion
[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
round value to display precision
modulo remainder of y/x: (y - x * floor(y/x))
base 10 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
closest integer to x
largest integer smaller than or equal to x
smallest integer larger than or equal to x
fracfunctions round to 9 decimal digits before determining the integer and fractional parts. Under this definition
fracis computed using the formulafrac(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 propertiesx - floor(x) >= 0 ceil(x) - x >= 0 round(x) is ceil(x) when x >= 0.5 otherwise round(x) is floor(x)
MathU Pro has three time functions
- seconds: Pushes the current number of seconds since January 1, 1904 onto the stack.
- H.MS: Converts x stack value from fractional hours to H.MS format. In H.MS format, the integer part of the value is the number of hours while the fractional part is broken into two fields: M, the minutes, and S, the seconds. Each field comprises two digits of the fraction. For example, the number 2.03165 is interpreted as 2 hours, 3 minutes, 16.5 seconds or 2°3'16.5" using standard degrees, minutes, seconds notation. Thus, the H.MS interpretation is also valid for D.MS as well. When using the H.MS and hours functions is usually helpful to set the number of digits displayed to be 4 or greater.
- hours: Converts x stack value from H.MS format to fractional hours. Digits after the fourth fractional digit are interpreted as fractions of a second.
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.
[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.
[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).
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
- 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).
- to set the number of periods (in months)
- since the interest per month is 7.25/12 %
- to set the principal or present value of the loan
- 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?
- Set the value $-2,000 as the FV (balloon) for the loan. The value is negative because this is money you will pay out.
- to compute the new payment per period (ans: $-340.75)
Example 3: How much interest do you end up paying with the balloon payment?
- 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.
- to reset the financial registers
- to set the number of periods (in years)
- to set the starting value of the account. The value is negative since you added this value to the account with the rollover.
- to set the annual contribution.
- 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.
- to compute the effective annual rate of return in the account (ans: 6.39%)
[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
MathU Pro programs have the following limitations
- 16 level stack
- 20 global registers
- 1024 local registers
- 32,000 program steps
- 255 labels in a program
- 255 annotation and constant strings (combined)
- 100 programs installed at one time
Alphabetical List of Functions
[Back to Top]
0 through 9
A through F
exch x y
N (number of periods)
swap p s
X, Y, Z
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: 3-Sep-2010