1ORPIE(1) a console-based RPN calculator ORPIE(1)
2
3
4
6 orpie is a console-based RPN calculator with an interactive visual
7 stack.
8
10 orpie
11
13 CAUTION: while this manpage should be suitable as a quick reference, it
14 may be subject to miscellaneous shortcomings in typesetting. The defin‐
15 itive documentation is the user manual provided with Orpie in PDF for‐
16 mat.
17
18 This section describes how to use Orpie in its default configuration.
19 After familiarizing yourself with the basic operations as outlined in
20 this section, you may wish to consult the orpierc(5) manpage to see how
21 Orpie can be configured to better fit your needs.
22
23 OVERVIEW
24 The interface has two panels. The left panel combines status informa‐
25 tion with context-sensitive help; the right panel represents the calcu‐
26 lator's stack. (Note that the left panel will be hidden if Orpie is run
27 in a terminal with less than 80 columns.)
28
29 In general, you perform calculations by first entering data on to the
30 stack, then executing functions that operate on the stack data. As an
31 example, you can hit 1<enter>2<enter>+ in order to add 1 and 2.
32
33 ENTERING REAL NUMBERS
34 To enter a real number, just type the desired digits and hit enter. The
35 space bar will begin entry of a scientific notation exponent. The 'n'
36 key is used for negation. Here are some examples:
37
38 ────────────────────────────────────────────
39 Keypresses Resulting Entry
40 ────────────────────────────────────────────
41 1.23<enter> 1.23
42 1.23<space>23n<enter> 1.23e-23
43 1.23n<space>23<enter> -1.23e23
44 ────────────────────────────────────────────
45
46 ENTERING COMPLEX NUMBERS
47 Orpie can represent complex numbers using either cartesian (rectangu‐
48 lar) or polar coordinates. See PERFORMING BASIC COMMAND OPERATIONS to
49 see how to change the complex number display mode.
50
51 A complex number is entered by first pressing '(', then entering the
52 real part, then pressing ',' followed by the imaginary part. Alterna‐
53 tively, you can press '(' followed by the magnitude, then '<' followed
54 by the phase angle. The angle will be interpreted in degrees or radi‐
55 ans, depending on the current setting of the angle mode (see PERFORMING
56 BASIC COMMAND OPERATIONS). Examples:
57
58 ────────────────────────────────────────────────────────────────────
59 Keypresses Resulting Entry
60 ────────────────────────────────────────────────────────────────────
61 (1.23, 4.56<enter> (1.23, 4.56)
62 (0.7072<45<enter> (0.500065915655126, 0.50006591...
63 (1.23n,4.56<space>10<enter> (-1.23, 45600000000)
64 ────────────────────────────────────────────────────────────────────
65
66 ENTERING MATRICES
67 You can enter matrices by pressing '['. The elements of the matrix may
68 then be entered as described in the previous sections, and should be
69 separated using ','. To start a new row of the matrix, press '[' again.
70 On the stack, each row of the matrix is enclosed in a set of brackets;
71 for example, the matrix
72
73 1 2
74 3 4
75
76 would appear on the stack as [[1, 2][3, 4]].
77
78 Examples of matrix entry:
79
80 ─────────────────────────────────────────────────────────────────────
81 Keypresses Resulting Entry
82 ─────────────────────────────────────────────────────────────────────
83 [1,2[3,4<enter> [[1, 2][3, 4]]
84 [1.2<space>10,0[3n,5n<enter> [[ 12000000000, 0 ][ -3, -5 ]]
85 [(1,2,3,4[5,6,7,8<enter> [[ (1, 2), (3, 4) ][ (5, 6), (...
86 ─────────────────────────────────────────────────────────────────────
87
88 ENTERING DATA WITH UNITS
89 Real and complex scalars and matrices can optionally be labeled with
90 units. After typing in the numeric portion of the data, press '_' fol‐
91 lowed by a units string. The format of units strings is described in
92 the UNITS FORMATTING section.
93
94 Examples of entering dimensioned data:
95
96 ───────────────────────────────────────────────────────
97 Keypresses Resulting Entry
98 ───────────────────────────────────────────────────────
99 1.234_N*mm^2/s<enter> 1.234_N*mm^2*s^-1
100 (2.3,5_s^-4<enter> (2.3, 5)_s^-4
101 [1,2[3,4_lbf*in<enter> [[ 1, 2 ][ 3, 4 ]]_lbf*in
102 _nm<enter> 1_nm
103 ───────────────────────────────────────────────────────
104
105 ENTERING INTEGER CONSTANTS
106 An exact integer may be entered by pressing '#' followed by the desired
107 digits. The base of the integer will be assumed to be the same as the
108 current calculator base mode (see PERFORMING BASIC COMMAND OPERATIONS
109 to see how to set this mode). Alternatively, the desired base may be
110 specified by pressing space and appending one of {b, o, d, h}, to rep‐
111 resent binary, octal, decimal, or hexadecimal, respectively. On the
112 stack, the representation of the integer will be changed to match the
113 current base mode. Examples:
114
115 ─────────────────────────────────────────────
116 Keypresses Resulting Entry
117 ─────────────────────────────────────────────
118 #123456<enter> # 123456`d
119 #ffff<space>h<enter> # 65535`d
120 #10101n<space>b<enter> # -21`d
121 ─────────────────────────────────────────────
122
123 Note that integer constants may have unlimited length, and the basic
124 arithmetic operations (addition, subtraction, multiplication, division)
125 will be performed using exact arithmetic when both arguments are inte‐
126 gers.
127
128 ENTERING VARIABLE NAMES
129 A variable name may be entered by pressing '@' followed by the desired
130 variable name string. The string may contain alphanumeric characters,
131 dashes, and underscores. Example:
132
133 ─────────────────────────────────
134 Keypresses Resulting Entry
135 ─────────────────────────────────
136
137 @myvar @ myvar
138 ─────────────────────────────────
139
140 Orpie also supports autocompletion of variable names. The help panel
141 displays a list of pre-existing variables that partially match the name
142 currently being entered. You can press '<tab>' to iterate through the
143 list of matching variables.
144
145 As a shortcut, keys <f1>-<f12> will enter the variables (``registers'')
146 @ r01 through @ r12.
147
148 ENTERING DATA WITH AN EXTERNAL EDITOR
149 Orpie can also parse input entered via an external editor. You may find
150 this to be a convenient method for entering large matrices. Pressing
151 'E' will launch the external editor, and the various data types may be
152 entered as illustrated by the examples below:
153
154 ────────────────────────────────────────────────────────────────────────────────────────
155 Data Type Sample Input String
156 ────────────────────────────────────────────────────────────────────────────────────────
157 integer constant #12345678`d, where the trailing
158 letter is one of the base characters {b, o, d, h}
159 real number -123.45e67
160 complex number (1e10, 2) or (1 <90)
161 real matrix [[1, 2][3.1, 4.5e10]]
162 complex matrix [[(1, 0), 5][1e10, (2 <90)]]
163 variable @myvar
164 ────────────────────────────────────────────────────────────────────────────────────────
165
166 Real and complex numbers and matrices may have units appended; just add
167 a units string such as ``_N*m/s'' immediately following the numeric
168 portion of the expression.
169
170 Notice that the complex matrix input parser is quite flexible; real and
171 complex matrix elements may be mixed, and cartesian and polar complex
172 formats may be mixed as well.
173
174 Multiple stack entries may be specified in the same file, if they are
175 separated by whitespace. For example, entering (1, 2) 1.5 into the edi‐
176 tor will cause the complex value (1, 2) to be placed on the stack, fol‐
177 lowed by the real value 1.5.
178
179 The input parser will discard whitespace where possible, so feel free
180 to add any form of whitespace between matrix rows, matrix elements,
181 real and complex components, etc.
182
183 EXECUTING BASIC FUNCTION OPERATIONS
184 Once some data has been entered on the stack, you can apply operations
185 to that data. For example, '+' will add the last two elements on the
186 stack. By default, the following keys have been bound to such opera‐
187 tions:
188
189 ─────────────────────────────────────────────────────
190 Keys Operations
191 ─────────────────────────────────────────────────────
192 + add last two stack elements
193 - subtract element 1 from element 2
194 * multiply last two stack elements
195 / divide element 2 by element 1
196 ^ raise element 2 to the power of element 1
197 n negate last element
198 i invert last element
199 s square root function
200 a absolute value function
201 e exponential function
202 l natural logarithm function
203 c complex conjugate function
204
205 ! factorial function
206 % element 2 mod element 1
207 S store element 2 in (variable) element 1
208 ; evaluate variable to obtain contents
209 ─────────────────────────────────────────────────────
210
211 As a shortcut, function operators will automatically enter any data
212 that you were in the process of entering. So instead of the sequence
213 2<enter>2<enter>+, you could type simply 2<enter>2+ and the second num‐
214 ber would be entered before the addition operation is applied.
215
216 As an additional shortcut, any variable names used as function argu‐
217 ments will be evaluated before application of the function. In other
218 words, it is not necessary to evaluate variables before performing
219 arithmetic operations on them.
220
221 EXECUTING FUNCTION ABBREVIATIONS
222 One could bind nearly all calculator operations to specific keypresses,
223 but this would rapidly get confusing since the PC keyboard is not
224 labeled as nicely as a calculator keyboard is. For this reason, Orpie
225 includes an abbreviation syntax.
226
227 To activate an abbreviation, press ''' (quote key), followed by the
228 first few letters/digits of the abbreviation, then hit enter. Orpie
229 offers an autocompletion feature for abbreviations, so you only need to
230 type enough of the operation to identify it uniquely. The matching
231 abbreviations will appear in the left panel of the display, to assist
232 you in finding the appropriate operation.
233
234 To avoid interface conflicts, abbreviations may be entered only when
235 the entry buffer (the bottom line of the screen) is empty.
236
237 The following functions are available as abbreviations:
238
239 ─────────────────────────────────────────────────────────────────────────────────────────────────────
240 Abbreviations Functions
241 ─────────────────────────────────────────────────────────────────────────────────────────────────────
242 inv inverse function
243 pow raise element 2 to the power of element 1
244 sq square last element
245 sqrt square root function
246 abs absolute value function
247 exp exponential function
248 ln natural logarithm function
249 10^ base 10 exponential function
250 log10 base 10 logarithm function
251 conj complex conjugate function
252 sin sine function
253 cos cosine function
254 tan tangent function
255 sinh hyperbolic sine function
256 cosh hyperbolic cosine function
257 tanh hyperbolic tangent function
258 asin arcsine function
259 acos arccosine function
260 atan arctangent function
261 asinh inverse hyperbolic sine function
262 acosh inverse hyperbolic cosine function
263 atanh inverse hyperbolic tangent function
264 re real part of complex number
265 im imaginary part of complex number
266 gamma Euler gamma function
267 lngamma natural log of Euler gamma function
268 erf error function
269 erfc complementary error function
270 fact factorial function
271 gcd greatest common divisor function
272
273 lcm least common multiple function
274 binom binomial coefficient function
275 perm permutation function
276 trans matrix transpose
277 trace trace of a matrix
278 solvelin solve a linear system of the form Ax = b
279 mod element 2 mod element 1
280 floor floor function
281 ceil ceiling function
282 toint convert a real number to an integer type
283 toreal convert an integer type to a real number
284 add add last two elements
285 sub subtract element 1 from element 2
286 mult multiply last two elements
287 div divide element 2 by element 1
288 neg negate last element
289 store store element 2 in (variable) element 1
290 eval evaluate variable to obtain contents
291 purge delete a variable
292 total sum the columns of a real matrix
293 mean compute the sample means of the columns of a real matrix
294 sumsq sum the squares of the columns of a real matrix
295 var compute the unbiased sample variances of the columns of a real matrix
296 varbias compute the biased (population) sample variances of the columns of a real matrix
297 stdev compute the unbiased sample standard deviations of the columns of a real matrix
298 stdevbias compute the biased (pop.) sample standard deviations of the columns of a matrix
299 min find the minima of the columns of a real matrix
300 max find the maxima of the columns of a real matrix
301 utpn compute the upper tail probability of a normal distribution
302 uconvert convert element 2 to an equivalent expression with units matching element 1
303 ustand convert to equivalent expression using SI standard base units
304 uvalue drop the units of the last element
305 ─────────────────────────────────────────────────────────────────────────────────────────────────────
306
307 Entering abbreviations can become tedious when performing repetitive
308 calculations. To save some keystrokes, Orpie will automatically bind
309 recently-used operations with no prexisting binding to keys <f5>-<f12>.
310 The current autobindings can be viewed by pressing 'h' to cycle between
311 the various pages of the help panel.
312
313 EXECUTING BASIC COMMAND OPERATIONS
314 In addition to the function operations listed in the section EXECUTING
315 BASIC FUNCTION OPERATIONS, a number of basic calculator commands have
316 been bound to single keypresses:
317
318 ─────────────────────────────────────────────────────────────────────────────
319 Keys Operations
320 ─────────────────────────────────────────────────────────────────────────────
321 \ drop last element
322 | clear all stack elements
323 <pagedown> swap last two elements
324 <enter> duplicate last element (when entry buffer is empty)
325 u undo last operation
326 r toggle angle mode between degrees and radians
327 p toggle complex display mode between rectangular and polar
328 b cycle base display mode between binary, octal, decimal, hex
329 h cycle through multiple help windows
330 v view last stack element in a fullscreen editor
331 E create a new stack element using an external editor
332 P enter 3.14159265 on the stack
333 C-L refresh the display
334 <up> begin stack browsing mode
335 Q quit Orpie
336 ─────────────────────────────────────────────────────────────────────────────
337
338 EXECUTING COMMAND ABBREVIATIONS
339 In addition to the function operations listed in the section EXECUTING
340 FUNCTION ABBREVIATIONS, there are a large number of calculator commands
341 that have been implemented using the abbreviation syntax:
342
343 ─────────────────────────────────────────────────────────────────────────────────────
344 Abbreviations Calculator Operation
345 ─────────────────────────────────────────────────────────────────────────────────────
346 drop drop last element
347 clear clear all stack elements
348 swap swap last two elements
349 dup duplicate last element
350 undo undo last operation
351 rad set angle mode to radians
352 deg set angle mode to degrees
353 rect set complex display mode to rectangular
354 polar set complex display mode to polar
355 bin set base display mode to binary
356 oct set base display mode to octal
357 dec set base display mode to decimal
358 hex set base display mode to hexidecimal
359 view view last stack element in a fullscreen editor
360 edit create a new stack element using an external editor
361 pi enter 3.14159265 on the stack
362 rand generate a random number between 0 and 1 (uniformly distributed)
363 refresh refresh the display
364 about display a nifty ``About Orpie'' screen
365 quit quit Orpie
366 ─────────────────────────────────────────────────────────────────────────────────────
367
368 BROWSING THE STACK
369 Orpie offers a stack browsing mode to assist in viewing and manipulat‐
370 ing stack data. Press <up> to enter stack browsing mode; this should
371 highlight the last stack element. You can use the up and down arrow
372 keys to select different stack elements. The following keys are useful
373 in stack browsing mode:
374
375 ──────────────────────────────────────────────────────────────────────────────────────────────────
376 Keys Operations
377 ──────────────────────────────────────────────────────────────────────────────────────────────────
378 q quit stack browsing mode
379 <left> scroll selected entry to the left
380 <right> scroll selected entry to the right
381 r cyclically ``roll'' stack elements downward, below the selected element (inclusive)
382 R cyclically ``roll'' stack elements upward, below the selected element (inclusive)
383 v view the currently selected element in a fullscreen editor
384 E edit the currently selected element with an external editor
385 <enter> duplicate the currently selected element
386 ──────────────────────────────────────────────────────────────────────────────────────────────────
387
388 The left and right scrolling option may prove useful for viewing very
389 lengthy stack entries, such as large matrices. The edit option provides
390 a convenient way to correct data after it has been entered on the
391 stack.
392
393 UNITS FORMATTING
394 A units string is a list of units separated by '*' to indicate multi‐
395 plication and '/' to indicate division. Units may be raised to
396 real-valued powers using the '^'character. A contrived example of a
397 valid unit string would be "N*nm^2*kg/s/in^-3*GHz^2.34".
398
399 Orpie supports the standard SI prefix set, {y, z, a, f, p, n, u, m, c,
400 d, da, h, k, M, G, T, P, E, Z, Y} (note the use of 'u' for micro-).
401 These prefixes may be applied to any of the following exhaustive sets
402 of units:
403
404 ────────────────────────────────
405 String Length Unit
406 ────────────────────────────────
407 m meter
408
409 ft foot
410 in inch
411 yd yard
412 mi mile
413 pc parsec
414 AU astronomical unit
415 Ang angstrom
416 furlong furlong
417 pt PostScript point
418 pica PostScript pica
419 nmi nautical mile
420 lyr lightyear
421 ────────────────────────────────
422
423 ─────────────────────────────
424 String Mass Unit
425 ─────────────────────────────
426 g gram
427 lb pound mass
428 oz ounce
429 slug slug
430 lbt Troy pound
431 ton (USA) short ton
432 tonl (UK) long ton
433 tonm metric ton
434 ct carat
435 gr grain
436 ─────────────────────────────
437
438 ───────────────────────
439 String Time Unit
440 ───────────────────────
441 s second
442 min minute
443 hr hour
444 day day
445 yr year
446 Hz Hertz
447 ───────────────────────
448
449 ──────────────────────────────
450 String Temperature Unit
451 ──────────────────────────────
452 K Kelvin
453 R Rankine
454 ──────────────────────────────
455
456 Note: No, Celsius and Fahrenheit will not be supported. Because these
457 temperature units do not share a common zero point, their behavior is
458 ill-defined under many operations.
459
460 ─────────────────────────
461 String Force Unit
462 ─────────────────────────
463 N Newton
464 lbf pound force
465 dyn dyne
466 kip kip
467 ─────────────────────────
468
469 ──────────────────────────────────
470 String Energy Unit
471 ──────────────────────────────────
472 J Joule
473 erg erg
474 cal calorie
475 BTU british thermal unit
476
477 eV electron volt
478 ──────────────────────────────────
479
480 ─────────────────────────────
481 String Electrical Unit
482 ─────────────────────────────
483 A Ampere
484 C Coulomb
485 V volt
486 Ohm Ohm
487 F Farad
488 H Henry
489 T Tesla
490 G Gauss
491 Wb Weber
492 Mx Maxwell
493 ─────────────────────────────
494
495 ────────────────────────
496 String Power Unit
497 ────────────────────────
498 W Watt
499 hp horsepower
500 ────────────────────────
501
502 ────────────────────────────────────
503 String Pressure Unit
504 ────────────────────────────────────
505 Pa Pascal
506 atm atmosphere
507 bar bar
508 Ohm Ohm
509 mmHg millimeters of mercury
510 inHg inches of mercury
511 ────────────────────────────────────
512
514 Orpie is Free Software; it has been made available under version 2 of
515 the GNU General Public License (GPL). You should have received a copy
516 of the GPL along with this program, in the file ``COPYING''.
517
519 Orpie includes portions of the ocamlgsl [1] bindings supplied by
520 Olivier Andrieu, as well as the curses bindings from the OCaml Text
521 Mode Kit [2] written by Nicolas George. I would like to thank these
522 authors for helping to make Orpie possible.
523
525 Orpie author: Paul Pelzl <pelzlpj@eecs.umich.edu>
526 Orpie website: http://www.eecs.umich.edu/~pelzlpj/orpie
527
528 Feel free to contact me if you have bugs, feature requests, patches,
529 etc. I would also welcome volunteers interested in packaging Orpie for
530 various platforms.
531
532 Orpie is developed with the aid of the excellent GNU Arch RCS [3].
533 Interested developers are advised to track Orpie development via my
534 public archive:
535 pelzlpj@eecs.umich.edu--2004 http://www-personal.engin.umich.edu/~pel‐
536 zlpj/tla/2004
537 Orpie uses tla's ``configs'' support. After getting a copy of the
538 source, run
539 "tla build-config dist.arch" in the project tree root to grab the extra
540 packages that Orpie depends on.
541
542 At the moment, I would really appreciate help writing additional test
543 cases for the calculator object. It's not terribly difficult, just
544 time-consuming. If you're interested in lending a hand, have a look at
545 the source in calc_test.ml and use "make test.opt" to build the testing
546 executable.
547
548 Do you feel compelled to compensate me for writing Orpie? As a poor,
549 starving graduate student, I will gratefully accept donations. Please
550 see
551 http://www.eecs.umich.edu/~pelzlpj/orpie/donate.html for more informa‐
552 tion.
553
555 [1] http://oandrieu.nerim.net/ocaml/gsl/
556 [2] http://www.nongnu.org/ocaml-tmk/
557 [3] http://www.gnu.org/software/gnu-arch/.
558
560 orpierc(5), orpie-curses-keys(1)
561
562a console-based RPN calculator 31 October 2005 ORPIE(1)