Enter RPN

Files in hp12c/albillo-trig/ of trunk
Login

Files in hp12c/albillo-trig/ of trunk

Files in directory hp12c/albillo-trig from the latest check-in of branch trunk


Description

This is an HP-12C simulator/emulator-friendly version of Valentin Albillo’s Tried & Tricky Trigonometrics.

The files linked above give you the article’s code in the following formats:

Using rejig, you can get it into other HP-12C formats such as the one used by the RLM-12C simulator:

rejig albillo-trig.12cmem -o albillo-trig.12c

(That output file name extension implicitly sets --to rlm12c mode.)

Usage

All angles are in radians. Put the operand into X, then:

Fn Command Input range
SIN R/S (implicit g GTO 00) `−5π…5π`
COS same, then leave X `−π÷2…+π÷2`
TAN same, then ÷ `−π÷2…+π÷2`
ASIN g GTO 37 R/S `−1…+1`
ACOS g GTO 93 R/S `0…1`
ATAN g GTO 30 R/S `−9.99×10^49…9.99×10^49`
π/2 g GTO 92 R/S (no input)

SIN and COS are produced together: sine in Y, cosine in X. Tan is then a single division; if cosine is zero, treat tan as infinite.

Every routine finishes by returning to step 00, so a series of sines, cosines, and tangents can be run with bare R/S after the first call. (f PRGM or GTO 01 also starts at the top.)

Accuracy loss occurs for `sintheta, quad theta gg 2pi`, and it takes longer to calculate besides. It is best to reduce the argument modulo `2π` first.

For cosines outside `±π/2`, use `sin(x + π/2)` or reduce the angle first.

For a negative `arccos` argument, use `π/2 − arcsin(x)`.

Resources

There is no separate constants block and no degrees mode.

Tests

Run make test to verify that this program runs properly under voyem. A Perl script pushes the program through several calculations to show that it gives the same results as reported in Albillo’s article.

See Also

This effort is partially in support of my “Ballpark Accuracy” article.