Chapters:
1: Introduction
2: Simple example
3: Invocation
4: Finer Control
5: X-Y Plots
6: Contour Plots
7: Image Plots
8: Examples
9: Gri Commands
10: Programming
11: Environment
12: Emacs Mode
13: History
14: Installation
15: Gri Bugs
16: Test Suite
17: Gri in Press
18: Acknowledgments

Indices:
Concepts
Commands
Variables

### 10.9.8: rpn Examples

Here are some reverse-polish expressions and the corresponding algebraic interpretations:

• {rpn 1 2 + 10 / }' = (1+2)/10

• {rpn .a. .b. + .c. + .d. / }' = (.a.+.b.+.c.)/.d.

• {rpn e 2 / }' = e/2 (Gri knows values of e'' and pi'')

• {rpn 23 sin 100 * 12 cos + }' = cos(12) + 100sin(23)

• {rpn 5 2 power }' = 25

• {rpn 2 log exp }' = exp(log 2)

• {rpn 2 ln exp10 }' = 10^ln2

• {rpn 1.7 floor }' = 1 (rounds down to nearest integer. Note that the floor of -1.7 is -2)

• {rpn 10.1 2 remainder }' = 0.1 (remainder of 10.1 after division by 2; see C function remainder(x,y)')

• {rpn -10.1 2 remainder }' = -0.1

• {rpn -10.1 -2 remainder }' = -0.1

• {rpn .num. 10 > }' = 1 if 10 exceeds .num., or 0 otherwise

NOTES:

• The units of sin', cos', etc, are degrees, not radians.
• The scales of the plot are accessible to rpn'. For example, with the command

  draw label "hi" at 10 20 

you draw the indicated string at the indicated location in user coordinates. To put it 0.15 centimetres to the right of this location and 0.1 centimetres lower, you could do as follows:

  draw label "\label" at \ {rpn .x. xusertocm 0.15 + xcmtouser} \ {rpn .y. yusertocm 0.10 - ycmtouser} 

(Note that the x and y scales have individual translations from "user" to "cm" coordinates.)

• Some conversion factors are built into rpn'; cmtopt' converts from centimetres to points (by dividing by 28.45; the conversion factor to inches is 72.27) while pttocm' converts from points to centimetres. For example, here is how to label a data curve with a label placed near the last y-value of the data set:

  draw curve .y. = {rpn ..ylast.. yusertocm 0.5 - ycmtouser} draw label "Smoothed" at ..xlast.. .y. `