orpie(1) is a console-based RPN calculator with an interactive visual stack.

SYNOPSIS

orpie

QUICK START

CAUTION: while this manpage should be suitable as a quick reference, it may be subject to miscellaneous shortcomings in typesetting. The definitive documentation is the user manual provided with Orpie in PDF format.

This section describes how to use Orpie in its default configuration. After familiarizing yourself with the basic operations as outlined in this section, you may wish to consult the orpierc(5) manpage to see how Orpie can be configured to better fit your needs.

OVERVIEW

The interface has two panels. The left panel combines status information with context-sensitive help; the right panel represents the calculator's stack. (Note that the left panel will be hidden if Orpie is run in a terminal with less than 80 columns.)

In general, you perform calculations by first entering data on to the stack, then executing functions that operate on the stack data. As an example, you can hit 1<enter>2<enter>+ in order to add 1 and 2.

ENTERING REAL NUMBERS

To enter a real number, just type the desired digits and hit enter. The space bar will begin entry of a scientific notation exponent. The 'n' key is used for negation. Here are some examples:


Keypresses Resulting Entry

1.23<enter> 1.23
1.23<space>23n<enter> 1.23e-23
1.23n<space>23<enter> -1.23e23

ENTERING COMPLEX NUMBERS

Orpie can represent complex numbers using either cartesian (rectangular) or polar coordinates. See PERFORMING BASIC COMMAND OPERATIONS to see how to change the complex number display mode.

A complex number is entered by first pressing '(', then entering the real part, then pressing ',' followed by the imaginary part. Alternatively, you can press '(' followed by the magnitude, then '<' followed by the phase angle. The angle will be interpreted in degrees or radians, depending on the current setting of the angle mode (see PERFORMING BASIC COMMAND OPERATIONS). Examples:


Keypresses Resulting Entry

(1.23, 4.56<enter> (1.23, 4.56)
(0.7072<45<enter> (0.500065915655126, 0.50006591...
(1.23n,4.56<space>10<enter> (-1.23, 45600000000)

ENTERING MATRICES

You can enter matrices by pressing '['. The elements of the matrix may then be entered as described in the previous sections, and should be separated using ','. To start a new row of the matrix, press '[' again. On the stack, each row of the matrix is enclosed in a set of brackets; for example, the matrix

1 2
3 4

would appear on the stack as [[1, 2][3, 4]].

Examples of matrix entry:


Keypresses Resulting Entry

[1,2[3,4<enter> [[1, 2][3, 4]]
[1.2<space>10,0[3n,5n<enter> [[ 12000000000, 0 ][ -3, -5 ]]
[(1,2,3,4[5,6,7,8<enter> [[ (1, 2), (3, 4) ][ (5, 6), (...

ENTERING DATA WITH UNITS

Real and complex scalars and matrices can optionally be labeled with units. After typing in the numeric portion of the data, press '_' followed by a units string. The format of units strings is described in the UNITS FORMATTING section.

Examples of entering dimensioned data:


Keypresses Resulting Entry

1.234_N*mm^2/s<enter> 1.234_N*mm^2*s^-1
(2.3,5_s^-4<enter> (2.3, 5)_s^-4
[1,2[3,4_lbf*in<enter> [[ 1, 2 ][ 3, 4 ]]_lbf*in
_nm<enter> 1_nm

ENTERING EXACT INTEGERS

An exact integer may be entered by pressing '#' followed by the desired digits. The base of the integer will be assumed to be the same as the current calculator base mode (see PERFORMING BASIC COMMAND OPERATIONS to see how to set this mode). Alternatively, the desired base may be specified by pressing space and appending one of {b, o, d, h}, to represent binary, octal, decimal, or hexadecimal, respectively. On the stack, the representation of the integer will be changed to match the current base mode. Examples:


Keypresses Resulting Entry

#123456<enter> # 123456`d
#ffff<space>h<enter> # 65535`d
#10101n<space>b<enter> # -21`d

Note that exact integers may have unlimited length, and the basic arithmetic operations (addition, subtraction, multiplication, division) will be performed using exact arithmetic when both arguments are integers.

ENTERING VARIABLE NAMES

A variable name may be entered by pressing '@' followed by the desired variable name string. The string may contain alphanumeric characters, dashes, and underscores. Example:


Keypresses Resulting Entry

@myvar @ myvar

Orpie also supports autocompletion of variable names. The help panel displays a list of pre-existing variables that partially match the name currently being entered. You can press '<tab>' to iterate through the list of matching variables.

As a shortcut, keys <f1>-<f4> will enter the variables (``registers'') @ r01 through @ r04.

ENTERING PHYSICAL CONSTANTS

Orpie includes definitions for a number of fundamental physical constants. To enter a constant, press 'C', followed by the first few letters/digits of the constant's symbol, then hit enter. Orpie offers an autocompletion feature for physical constants, so you only need to type enough of the constant to identify it uniquely. A list of matching constants will appear in the left panel of the display, to assist you in finding the desired choice.

The following is a list of Orpie's physical constant symbols:


Symbol Physical Constant

NA Avagadro's number
k Boltzmann constant
Vm molar volume
R universal gas constant
stdT standard temperature
stdP standard pressure
sigma Stefan-Boltzmann constant
c speed of light
eps0 permittivity of free space
u0 permeability of free space
g acceleration of gravity
G Newtonian gravitational constant
h Planck's constant
hbar Dirac's constant
e electron charge
me electron mass
mp proton mass
alpha fine structure constant
phi magnetic flux quantum
F Faraday's constant
Rinf ``infinity'' Rydberg constant
a0 Bohr radius
uB Bohr magneton
uN nuclear magneton
lam0 wavelength of a 1eV photon
f0 frequency of a 1eV photon
lamc Compton wavelength
c3 Wien's constant

All physical constants are defined in the Orpie run-configuration file; consult the orpierc(5) manpage if you wish to define your own constants or change the existing definitions.

ENTERING DATA WITH AN EXTERNAL EDITOR

Orpie can also parse input entered via an external editor. You may find this to be a convenient method for entering large matrices. Pressing 'E' will launch the external editor, and the various data types may be entered as illustrated by the examples below:


Data Type Sample Input String

exact integer #12345678`d, where the trailing
letter is one of the base characters {b, o, d, h}
real number -123.45e67
complex number (1e10, 2) or (1 <90)
real matrix [[1, 2][3.1, 4.5e10]]
complex matrix [[(1, 0), 5][1e10, (2 <90)]]
variable @myvar

Real and complex numbers and matrices may have units appended; just add a units string such as ``_N*m/s'' immediately following the numeric portion of the expression.

Notice that the complex matrix input parser is quite flexible; real and complex matrix elements may be mixed, and cartesian and polar complex formats may be mixed as well.

Multiple stack entries may be specified in the same file, if they are separated by whitespace. For example, entering (1, 2) 1.5 into the editor will cause the complex value (1, 2) to be placed on the stack, followed by the real value 1.5.

The input parser will discard whitespace where possible, so feel free to add any form of whitespace between matrix rows, matrix elements, real and complex components, etc.

EXECUTING BASIC FUNCTION OPERATIONS

Once some data has been entered on the stack, you can apply operations to that data. For example, '+' will add the last two elements on the stack. By default, the following keys have been bound to such operations:


Keys Operations

+ add last two stack elements
- subtract element 1 from element 2
* multiply last two stack elements
/ divide element 2 by element 1
^ raise element 2 to the power of element 1
n negate last element
i invert last element
s square root function
a absolute value function
e exponential function
l natural logarithm function
c complex conjugate function
! factorial function
% element 2 mod element 1
S store element 2 in (variable) element 1
; evaluate variable to obtain contents

As a shortcut, function operators will automatically enter any data that you were in the process of entering. So instead of the sequence 2<enter>2<enter>+, you could type simply 2<enter>2+ and the second number would be entered before the addition operation is applied.

As an additional shortcut, any variable names used as function arguments will be evaluated before application of the function. In other words, it is not necessary to evaluate variables before performing arithmetic operations on them.

EXECUTING FUNCTION ABBREVIATIONS

One could bind nearly all calculator operations to specific keypresses, but this would rapidly get confusing since the PC keyboard is not labeled as nicely as a calculator keyboard is. For this reason, Orpie includes an abbreviation syntax.

To activate an abbreviation, press ''' (quote key), followed by the first few letters/digits of the abbreviation, then hit enter. Orpie offers an autocompletion feature for abbreviations, so you only need to type enough of the operation to identify it uniquely. The matching abbreviations will appear in the left panel of the display, to assist you in finding the appropriate operation.

To avoid interface conflicts, abbreviations may be entered only when the entry buffer (the bottom line of the screen) is empty.

The following functions are available as abbreviations:


Abbreviations Functions

inv inverse function
pow raise element 2 to the power of element 1
sq square last element
sqrt square root function
abs absolute value function
exp exponential function
ln natural logarithm function
10^ base 10 exponential function
log10 base 10 logarithm function
conj complex conjugate function
sin sine function
cos cosine function
tan tangent function
sinh hyperbolic sine function
cosh hyperbolic cosine function
tanh hyperbolic tangent function
asin arcsine function
acos arccosine function
atan arctangent function
asinh inverse hyperbolic sine function
acosh inverse hyperbolic cosine function
atanh inverse hyperbolic tangent function
re real part of complex number
im imaginary part of complex number
gamma Euler gamma function
lngamma natural log of Euler gamma function
erf error function
erfc complementary error function
fact factorial function
gcd greatest common divisor function
lcm least common multiple function
binom binomial coefficient function
perm permutation function
trans matrix transpose
trace trace of a matrix
solvelin solve a linear system of the form Ax = b
mod element 2 mod element 1
floor floor function
ceil ceiling function
toint convert a real number to an integer type
toreal convert an integer type to a real number
add add last two elements
sub subtract element 1 from element 2
mult multiply last two elements
div divide element 2 by element 1
neg negate last element
store store element 2 in (variable) element 1
eval evaluate variable to obtain contents
purge delete a variable
total sum the columns of a real matrix
mean compute the sample means of the columns of a real matrix
sumsq sum the squares of the columns of a real matrix
var compute the unbiased sample variances of the columns of a real matrix
varbias compute the biased (population) sample variances of the columns of a real matrix
stdev compute the unbiased sample standard deviations of the columns of a real matrix
stdevbias compute the biased (pop.) sample standard deviations of the columns of a matrix
min find the minima of the columns of a real matrix
max find the maxima of the columns of a real matrix
utpn compute the upper tail probability of a normal distribution
uconvert convert element 2 to an equivalent expression with units matching element 1
ustand convert to equivalent expression using SI standard base units
uvalue drop the units of the last element

Entering abbreviations can become tedious when performing repetitive calculations. To save some keystrokes, Orpie will automatically bind recently-used operations with no prexisting binding to keys <f5>-<f12>. The current autobindings can be viewed by pressing 'h' to cycle between the various pages of the help panel.

EXECUTING BASIC COMMAND OPERATIONS

In addition to the function operations listed in the section EXECUTING BASIC FUNCTION OPERATIONS, a number of basic calculator commands have been bound to single keypresses:


Keys Operations

\     drop last element
| clear all stack elements
<pagedown> swap last two elements
<enter> duplicate last element (when entry buffer is empty)
u undo last operation
r toggle angle mode between degrees and radians
p toggle complex display mode between rectangular and polar
b cycle base display mode between binary, octal, decimal, hex
h cycle through multiple help windows
v view last stack element in a fullscreen editor
E create a new stack element using an external editor
P enter 3.14159265 on the stack
C-L refresh the display
<up> begin stack browsing mode
Q quit Orpie

EXECUTING COMMAND ABBREVIATIONS

In addition to the function operations listed in
the section EXECUTING FUNCTION ABBREVIATIONS, there are a large number of calculator commands that have been implemented using the abbreviation syntax:


Abbreviations Calculator Operation

drop drop last element
clear clear all stack elements
swap swap last two elements
dup duplicate last element
undo undo last operation
rad set angle mode to radians
deg set angle mode to degrees
rect set complex display mode to rectangular
polar set complex display mode to polar
bin set base display mode to binary
oct set base display mode to octal
dec set base display mode to decimal
hex set base display mode to hexidecimal
view view last stack element in a fullscreen editor
edit create a new stack element using an external editor
pi enter 3.14159265 on the stack
rand generate a random number between 0 and 1 (uniformly distributed)
refresh refresh the display
about display a nifty ``About Orpie'' screen
quit quit Orpie

BROWSING THE STACK

Orpie offers a stack browsing mode to assist in viewing and manipulating stack data. Press <up> to enter stack browsing mode; this should highlight the last stack element. You can use the up and down arrow keys to select different stack elements. The following keys are useful in stack browsing mode:


Keys Operations

q quit stack browsing mode
<left> scroll selected entry to the left
<right> scroll selected entry to the right
r cyclically ``roll'' stack elements downward, below the selected element (inclusive)
R cyclically ``roll'' stack elements upward, below the selected element (inclusive)
v view the currently selected element in a fullscreen editor
E edit the currently selected element with an external editor
<enter> duplicate the currently selected element

The left and right scrolling option may prove useful for viewing very lengthy stack entries, such as large matrices. The edit option provides a convenient way to correct data after it has been entered on the stack.

UNITS FORMATTING

A units string is a list of units separated by '*' to indicate multiplication and '/' to indicate division. Units may be raised to real-valued powers using the '^'character. A contrived example of a valid unit string would be "N*nm^2*kg/s/in^-3*GHz^2.34".

Orpie supports the standard SI prefix set, {y, z, a, f, p, n, u, m, c, d, da, h, k, M, G, T, P, E, Z, Y} (note the use of 'u' for micro-). These prefixes may be applied to any of the following exhaustive sets of units:


String Length Unit

m meter
ft foot
in inch
yd yard
mi mile
pc parsec
AU astronomical unit
Ang angstrom
furlong furlong
pt PostScript point
pica PostScript pica
nmi nautical mile
lyr lightyear


String Mass Unit

g gram
lb pound mass
oz ounce
slug slug
lbt Troy pound
ton (USA) short ton
tonl (UK) long ton
tonm metric ton
ct carat
gr grain


String Time Unit

s second
min minute
hr hour
day day
yr year
Hz Hertz


String Temperature Unit

K Kelvin
R Rankine

Note: No, Celsius and Fahrenheit will not be supported. Because these temperature units do not share a common zero point, their behavior is ill-defined under many operations.


String ``Amount of Substance'' Unit

mol Mole


String Force Unit

N Newton
lbf pound force
dyn dyne
kip kip


String Energy Unit

J Joule
erg erg
cal calorie
BTU british thermal unit
eV electron volt


String Electrical Unit

A Ampere
C Coulomb
V volt
Ohm Ohm
F Farad
H Henry
T Tesla
G Gauss
Wb Weber
Mx Maxwell


String Power Unit

W Watt
hp horsepower


String Pressure Unit

Pa Pascal
atm atmosphere
bar bar
Ohm Ohm
mmHg millimeters of mercury
inHg inches of mercury


String Luminance Unit

cd candela
lm lumen
lx lux

Note: Although the lumen is defined by 1_lm = 1_cd * sr, Orpie drops the steridian because it is a dimensionless unit and therefore is of questionable use to a calculator.


String Volume Unit

ozfl fluid ounce (US)
cup cup (US)
pt pint (US)
qt quart (US)
gal gallon (US)
L liter

All units are defined in the Orpie run-configuration file; consult the orpierc(5) manpage if you wish to define your own units or change the existing definitions.

LICENSING

Orpie is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL), Version 2, as published by the Free Software Foundation. You should have received a copy of the GPL along with this program, in the file ``COPYING''.

CREDITS

Orpie includes portions of the ocamlgsl [1] bindings supplied by Olivier Andrieu, as well as the curses bindings from the OCaml Text Mode Kit [2] written by Nicolas George. I would like to thank these authors for helping to make Orpie possible.

CONTACT INFO

Orpie author: Paul Pelzl <[email protected]>
Orpie website: http://pessimization.com/software/orpie

Feel free to contact me if you have bugs, feature requests, patches, etc. I would also welcome volunteers interested in packaging Orpie for various platforms.