frechett@spot.Colorado.EDU (-=Runaway Daemon=-) (03/03/91)
I just picked up these routines from the hpbbs. Unfortunately, I downloaded them straight from the bbs into the calc so I don't have the message header to go with it, but I see it down in the code.. (John A. Kyle) This is a set of routines to deal with numbers like 2+-.5 or 3.056 +- .67 when doing the operations + - * / and ^. Those operations are treated as absolute errors so that 2.0 +- .5 + 3.0 +-.5 will result in 6.0 +- 0.0. Then there is an operation for dealing with stuff in a random fashion, with 90% assurance. For an example, I could choose the EQ 'X + Y' and enter the numbers X = 2.0 dX = .5 Y= 3.0 dY= .5 and yeilds "To correct SIG.FIG's 5.0+-0.7" and the real result 5.0+-0.707106781187. For anyone with a physics class that requires any sort of error analysis of the data, this set of programs is a MUST. The routines are completely idiot proof as they will tell you what to do if you don't have the right data. Just download this directory and when it it, hit CST and then INTRO. That will get you started.. I have found no problems in it yet. ian -- -=Runaway Daemon ----- X1DX -------------------------------------------- %%HP: T(3)A(D)F(.); DIR WORK DIR WIPE \<< 'WIPE' DUP RCL CLVAR SWAP STO \>> END X\177dX \<< "Press left-shifted menu key for HELP" CLLCD 1 DISP 1 FREEZE { { "INTRO" { \<< IN \>> } } { " + " { \<< ADD \>> \<< IN.A \>> } } { " - " { \<< SUBT \>> \<< IN.S \>> } } { " * " { \<< MUL \>> \<< IN.M \>> } } { " / " { \<< DIV \>> \<< IN.D \>> } } { " ^ " { \<< PWR \>> \<< IN.P \>> } } { "\|^\|v" { \<< SWP2 \>> \<< IN.SW \>> } } { "f(x)" { \<< RANDM \>> \<< IN.R \>> } } { "\-> %" { \<< P.UNC \>> \<< IN.% \>> } } { "SIGFIG" { \<< SIGFIG \>> \<< IN.SI \>> } } } MENU \>> IN \<< " UNCERTAINTY CALCULATION PROGRAM for the HP 48SX [\|v]" CLLCD 1 DISP 0 WAIT "Written for the public domain by John A. Kyle UBC 1991 [\|v] v 1.1" CLLCD 1 DISP 0 WAIT " Absolute Random error error functions function --------- -------- + - * / ^ f(x) [\|v]" CLLCD 1 DISP 0 WAIT "The absolute functions calculate total error whereas the random function calculates a less pessimistic error with a 90% confidence [\|v] level" CLLCD 1 DISP 0 WAIT "utilizing: Z=f(x,..) 1/2 dZ=[(\.df/\.dx)^2*dx^2+..] [\|v]" CLLCD 1 DISP 0 WAIT "NOTE: Use 0 for dX when X has no uncertainty associated with it, etc." CLLCD 1 DISP 0 WAIT 6 DROPN \>> IN.A \<< "Enter like so.. (X\177dX) + (Y\177dY) 4: X \-> 3: dX 2: Y 1: dY" CLLCD 1 DISP 7 FREEZE \>> IN.S \<< "Enter like so.. (X\177dX) - (Y\177dY) 4: X \-> 3: dX 2: Y 1: dY" CLLCD 1 DISP 7 FREEZE \>> IN.M \<< "Enter like so.. (X\177dX) * (Y\177dY) 4: X \-> 3: dX 2: Y 1: dY" CLLCD 1 DISP 7 FREEZE \>> IN.D \<< "Enter like so.. (X\177dX) / (Y\177dY) 4: X \-> 3: dX 2: Y 1: dY" CLLCD 1 DISP 7 FREEZE \>> IN.P \<< "Enter like so.. x (Y\177dY) 3: Y \-> 2: dY 1: x" CLLCD 1 DISP 7 FREEZE \>> IN.R \<< " Use EQUATION WRITER to enter symbolic expression.. then press f(x) key and follow prompts." CLLCD 1 DISP 7 FREEZE \>> IN.SW \<< "Rotates levels 1&2 with 3&4.. 4: X 4: Y 3: dX \-> 3: dY 2: Y 2: X 1: dY 1: dX" CLLCD 1 DISP 7 FREEZE \>> IN.% \<< " Utility to convert from absolute to % uncertainty ie. X\177dX \-> X\177dX%" CLLCD 1 DISP 7 FREEZE \>> IN.SI \<< " Utility to display X\177dX with the correct significant figures as determined by the uncertainty. " CLLCD 1 DISP 7 FREEZE \>> PRESERVE \<< RCLF \-> f \<< EVAL f STOF \>> \>> CST { { "INTRO" { \<< IN \>> } } { " + " { \<< ADD \>> \<< IN.A \>> } } { " - " { \<< SUBT \>> \<< IN.S \>> } } { " * " { \<< MUL \>> \<< IN.M \>> } } { " / " { \<< DIV \>> \<< IN.D \>> } } { " ^ " { \<< PWR \>> \<< IN.P \>> } } { "\|^\|v" { \<< SWP2 \>> \<< IN.SW \>> } } { "f(x)" { \<< RANDM \>> \<< IN.R \>> } } { "\-> %" { \<< P.UNC \>> \<< IN.% \>> } } { "SIGFIG" { \<< SIGFIG \>> \<< IN.SI \>> } } } SUBT \<< IFERR \-> x dx y dy \<< x y - 'Z' \->TAG dx dy + 'dZ' \->TAG SIGFIG \>> THEN IN.S END \>> MUL \<< IFERR \-> x dx y dy \<< x y * 'Z' \->TAG dx y * x dy * + 'dZ' \->TAG SIGFIG \>> THEN IN.M END \>> DIV \<< IFERR \-> x dx y dy \<< x y / 'Z' \->TAG dx y * x dy * + y 2 ^ / 'dZ' \->TAG SIGFIG \>> THEN IN.D END \>> PWR \<< IFERR \-> y dy x \<< y x ^ "Z" \->TAG dy x * y x 1 - ^ * "dZ" \->TAG SIGFIG \>> THEN IN.P END \>> P.UNC \<< IFERR DUP2 DTAG SWAP DTAG \-> dz z \<< " " 2 FIX z \->STR " \177 " " % " dz z / 100 * ABS \->STR STD + + + + CLLCD 2 DISP "Percent Uncertainty" 1 DISP 1 FREEZE \>> THEN " Requires entry like so.. Z\177dZ \-> 2: Z 1: dZ" CLLCD 1 DISP 7 FREEZE END \>> SIGFIG \<< IFERR DUP2 DTAG SWAP DTAG \-> dx x \<< IF x TYPE 0 == x 0 \=/ AND dx TYPE 0 == dx 0 \=/ AND AND THEN "( " x XPON DUP dx XPON - FIX x DUP SIGN SWAP MANT * SWAP ALOG dx SWAP / "\177" SWAP " )E" + + + + STD x XPON + " To correct SIG.FIG's " SWAP + CLLCD 1 DISP 1 FREEZE END \>> THEN " Requires entry like so.. Z\177dZ \-> 2: Z 1: dZ" CLLCD 1 DISP 7 FREEZE END \>> RANDM \<< IFERR DUP \<< -2 SF -3 CF IF TYPE 9 == THEN DUP { } 0 { } \-> equ dequ finlst ans varlst \<< "stop" WHILE dequ "stop" SAME NOT REPEAT CASE dequ TYPE 9 == THEN dequ OBJ\-> DROP2 END dequ TYPE 6 == THEN varlst 1 3 CF IF varlst SIZE THEN DO GETI IF dequ SAME THEN 3 SF END UNTIL -64 FS? END END IF 3 FC? THEN dequ 'varlst' STO+ END DROP2 END END 'dequ' STO END 3 CF varlst 1 DO GETI \-> i \<< " Enter values for.." ": " i ": :d" i ":" + + + + { { 1 0 } V } + INPUT OBJ\-> equ i \.d * SQ 'ans' STO+ DTAG i SWAP 'finlst' STO+ 'finlst' STO+ \>> UNTIL -64 FS? END DROP2 equ finlst | "Z" \->TAG ans finlst | \v/ "dZ" \->TAG SIGFIG \>> ELSE IN.R END \>> PRESERVE THEN IN.R END \>> SWP2 \<< IFERR 4 ROLL 4 ROLL THEN DROP IN.SW END \>> ADD \<< IFERR \-> x dx y dy \<< x y + 'Z' \->TAG dx dy + 'dZ' \->TAG SIGFIG \>> THEN IN.A END \>> END