UP | HOME

free42 Uncertainty Propagation

Author: Mitch Richling
Updated: 2024-02-12 12:55:57

Copyright 2024 Mitch Richling. All rights reserved.

Table of Contents

1. Metadata

The home for this HTML file is: https://richmit.github.io/hp42/uprop.html

A PDF version of this file may be found here: https://richmit.github.io/hp42/uprop.pdf

Files related to this document may be found on github: https://github.com/richmit/hp42

Directory contents:

src - The org-mode file that generated this HTML document
src_42s - Ready to convert source listings for 42s code in this document
docs - This html document and associated PDF
bin - Importable RAW program files

2. Introduction

This org-mode file contains a program, UPROP, that can be used to preform calculations that propagate uncertainty using the standard Gaussian model. Values are represented as complex numbers with the imaginary part being the standard deviation. i.e. V+iU means the value is V and the uncertainty is represented by U (a standard deviation).

Menu LBL Value Uncertainty (Standard Deviation) Notes
+ U+ Y.v+X.v HYPOT(X.u, Y.u)  
- U- Y.v-X.v HYPOT(X.u, Y.u)  
× Y.v*X.v HYPOT(X.u*Y.v, X.v*Y.u)  
÷ Y.v/X.v HYPOT(X.u*Y.v, X.v*Y.u)/X.v^2  
+/- U+/- -X.v ABS(X.u)  
1/X U1/X 1/X.v ABS(X.u)/X.v^2  
LN ULN LN(X.v) ABS(X.u/X.v)  
E↑X UE↑X EXP(X.v) EXP(X.v)*ABS(X.u*X.v)  
Y↑X UY↑X Y.v^X.v ABS(Y.v^X.v)*HYPOT(Y.u*X.v/Y.v, LN(Y.v)*X.u)  
ABS UABS ABS(X.v) ABS(X.u)  
GAMMA UGAMMA GAMMA(X.v) ABS(DIGAMMA(X.v)*GAMMA(X.v)*X.u) Requires SFUN
▒▒▒▒        
SIN USIN SIN(X.v) ABS(COS(X.v)*X.u)  
COS UCOS COS(X.v) ABS(SIN(X.v)*X.u)  
TAN UTAN TAN(X.v) ABS(SEC^2(X.v)*X.u)  
ASIN UASIN ASIN(X.v) ABS(X.u/SQRT(1-X.v^2))  
ACOS UACOS ACOS(X.v) ABS(X.u/SQRT(1-X.v^2))  
ATAN UATAN ATAN(X.v) ABS(X.u/(1+X.v^2))  
SINH USINH SINH(X.v) ABS(COSH(X.v)*X.u)  
COSH UCOSH COSH(X.v) ABS(SINH(X.v)*X.u)  
TANH UTANH TANH(X.v) ABS(SECH^2(X.v)*X.u)  
ASINH UASINH ASINH(X.v) ABS(X.u/SQRT(1-X.v^2))  
ACOSH UACOSH ACOSH(X.v) ABS(X.u/SQRT(1-X.v^2))  
ATANH UATANH ATANH(X.v) ABS(X.u/(1+X.v^2))  
I→VU UI→VU (X+Y)/2 ABS(X-Y)/2 Interval->
VU→I UVU→I N/A N/A ->Interval
▒▒▒▒        
VU→% UVU→% N/A N/A Percentages
▒▒▒▒        
×U U×U Y.v Y.u×X U Factor

3.1. Notes

3.1.1. [SHIFT] key magic for menus

Menu keys that can accept a value with uncertainty in the X position of the stack behave differently when used with the [SHIFT] key. If the [SHIFT] key is pressed before such a menu key, then it is like pressing [SHIFT] [COMPLEX] and then the menu key. For example, pressing [SHIFT] [COSH] is the same as [SHIFT] [COMPLEX] [COSH]. This is a handy way to save a keystroke when entering new values.

Note that I→VU doesn't take a value with uncertainty, and thus pressing the [SHIFT] key before this function has no effect.

3.1.2. Global Labels

The menu items correspond to global labels that you can XEQ from other programs. The names are the menu labels prefixed with "U" – so "SIN" becomes "USIN".

3.1.3. UI→VU & UVU→I: Intervals

These functions convert between intervals and quantity with uncertainty. Intervals are specified by interval end points on levels X & Y of the stack. For I→VU the order is not relevant, but VU→I will always return the leftmost end point in Y and the rightmost end point in X.

3.1.4. UVU→%

Given a quantity with uncertainty in X, it will return T% of the uncertainty. This value is always positive.

3.1.5. UxU: Multiply uncertainty

This is a quick way to multiply the uncertainty by a factor. For example if you are using an expanded uncertainty value.

4. Menu Code

(MJR-generate-42-menu-code "UPROP" 0 tbl 0 1 'stay 'up 'auto
                           (lambda (atrg row) (if (string-equal "UI→VU" atrg)
                                                  (format "\"%s\"" atrg)))
                           ;;#'MJR-local-only-gen-lab
                           (lambda (atrg target row) 
                             (cl-destructuring-bind (md-menu md-lbl md-v md-u mdnotes) row
                                   (mapconcat #'string-trim-left 
                                              (list  (format "FS? 64")
                                                     (format "COMPLEX")
                                                     (format "XEQ \"U%s\"" md-menu))
                                              "\n"))))

5. Functions

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UPLUS)
@@@@ IN:  Y: Y   Quantity & Uncertainty _or_ Exact Quantity
@@@@      X: X   Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: Y+X Quantity & Uncertainty (Uncertainty is 0 when X & Y are exact)
LBL "U+"
FUNC 21              @@@@ X Y
L4STK
XEQ 99 @NM@ R->C     @@@@ X Y
X<>Y                 @@@@ Y X
XEQ 99 @NM@ R->C     @@@@ Y X
COMPLEX              @@@@ Y.u Y.v X 
X<>Y                 @@@@ Y.v Y.u X 
RCL ST Z             @@@@ X Y.v Y.u X 
COMPLEX              @@@@ X.u X.v Y.v Y.u
R↓                   @@@@ X.v Y.v Y.u X.u 
+                    @@@@ (Y+X).v Y.u X.u 
R↓                   @@@@ Y.u X.u ? (X+Y).v 
COMPLEX              @@@@ TMP ? (X+Y).v (X+Y).v 
ABS                  @@@@ (X+Y).u ? (X+Y).v (X+Y).v
R↑                   @@@@ (X+Y).v (X+Y).u ? (X+Y).v 
X<>Y                 @@@@ (X+Y).u (X+Y).v ? (X+Y).v 
COMPLEX              @@@@ X+Y
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UMINUS)
@@@@ IN:  Y: Y   Quantity & Uncertainty _or_ Exact Quantity
@@@@      X: X   Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: Y-X Quantity & Uncertainty (Uncertainty is 0 when X & Y are exact)
LBL "U-"
FUNC 21              @@@@ X Y
L4STK
XEQ 99 @NM@ R->C     @@@@ X Y
X<>Y                 @@@@ Y X
XEQ 99 @NM@ R->C     @@@@ Y X
COMPLEX              @@@@ Y.u Y.v X 
X<>Y                 @@@@ Y.v Y.u X 
RCL ST Z             @@@@ X Y.v Y.u X 
COMPLEX              @@@@ X.u X.v Y.v Y.u
R↓                   @@@@ X.v Y.v Y.u X.u 
-                    @@@@ (Y-X).v Y.u X.u 
R↓                   @@@@ Y.u X.u ? (X-Y).v 
COMPLEX              @@@@ TMP ? (X-Y).v (X-Y).v 
ABS                  @@@@ (X-Y).u ? (X-Y).v (X-Y).v
R↑                   @@@@ (X-Y).v (X-Y).u ? (X-Y).v 
X<>Y                 @@@@ (X-Y).u (X-Y).v ? (X-Y).v 
COMPLEX              @@@@ X-Y
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UMULT)
@@@@ IN:  Y: Y   Quantity & Uncertainty _or_ Exact Quantity
@@@@      X: X   Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: Y×X Quantity & Uncertainty (Uncertainty is 0 when X & Y are exact)
LBL "U×"
FUNC 21              @@@@ X Y
L4STK
XEQ 99 @NM@ R->C     @@@@ X Y
X<>Y                 @@@@ Y X
XEQ 99 @NM@ R->C     @@@@ Y X
COMPLEX              @@@@ Y.u Y.v X 
LSTO "_Yu"           @@@@ Y.u Y.v X 
R↓                   @@@@ Y.v X 
LSTO "_Yv"           @@@@ Y.v X
X<>Y                 @@@@ X Y.v
COMPLEX              @@@@ X.u X.v Y.v
LSTO "_Xu"           @@@@ X.u X.v Y.v
R↓                   @@@@ X.v Y.v
LSTO "_Xv"           @@@@ X.v Y.v
×                    @@@@ (YX).v
RCL "_Xu"            @@@@ Xu (YX).v
RCL× "_Yv"           @@@@ Xu*Yv (YX).v
RCL "_Xv"            @@@@ Yu Xu*Yv (YX).v
RCL× "_Yu"           @@@@ Xv*Yu Xu*Yv (YX).v
COMPLEX              @@@@ TMP (YX).v
ABS                  @@@@ (YX).u (YX).v
COMPLEX              @@@@ YX
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UDIV)
@@@@ IN:  Y: Y   Quantity & Uncertainty _or_ Exact Quantity
@@@@      X: X   Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: Y÷X Quantity & Uncertainty (Uncertainty is 0 when X & Y are exact)
LBL "U÷"
FUNC 21              @@@@ X Y
L4STK
XEQ 99 @NM@ R->C     @@@@ X Y
X<>Y                 @@@@ Y X
XEQ 99 @NM@ R->C     @@@@ Y X
COMPLEX              @@@@ Y.u Y.v X 
LSTO "_Yu"           @@@@ Y.u Y.v X 
R↓                   @@@@ Y.v X 
LSTO "_Yv"           @@@@ Y.v X
X<>Y                 @@@@ X Y.v
COMPLEX              @@@@ X.u X.v Y.v
LSTO "_Xu"           @@@@ X.u X.v Y.v
R↓                   @@@@ X.v Y.v
LSTO "_Xv"           @@@@ X.v Y.v
÷                    @@@@ (Y/X).v
RCL "_Xu"            @@@@ Xu (YX).v
RCL× "_Yv"           @@@@ Xu*Yv (YX).v
RCL "_Xv"            @@@@ Yu Xu*Yv (YX).v
RCL× "_Yu"           @@@@ Xv*Yu Xu*Yv (YX).v
COMPLEX              @@@@ TMP (YX).v
ABS                  @@@@ TMP (YX).v
RCL÷ "_Xv"           @@@@ TMP (YX).v
RCL÷ "_Xv"           @@@@ (YX).u (YX).v
COMPLEX              @@@@ Y/X
RTN    

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UPOW)
@@@@ IN:  Y: Y   Quantity & Uncertainty _or_ Exact Quantity
@@@@      X: X   Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: Y↑X Quantity & Uncertainty (Uncertainty is 0 when X & Y are exact)
LBL "UY↑X"
FUNC 21              @@@@ X Y
L4STK
XEQ 99 @NM@ R->C     @@@@ X Y
X<>Y                 @@@@ Y X
XEQ 99 @NM@ R->C     @@@@ Y X
COMPLEX              @@@@ Y.u Y.v X 
LSTO "_Yu"           @@@@ Y.u Y.v X 
R↓                   @@@@ Y.v X 
LSTO "_Yv"           @@@@ Y.v X
X<>Y                 @@@@ X Y.v
COMPLEX              @@@@ X.u X.v Y.v
LSTO "_Xu"           @@@@ X.u X.v Y.v
R↓                   @@@@ X.v Y.v
LSTO "_Xv"           @@@@ X.v Y.v
Y↑X                  @@@@ (Y↑X).v
RCL "_Yu"            @@@@ Y.u (Y↑X).v
RCL× "_Xv"           @@@@ Y.u*X.v (Y↑X).v
RCL÷ "_Yv"           @@@@ Y.u*X.v/Y.v (Y↑X).v
RCL "_Yv"            @@@@ Y.v Y.u*X.v/Y.v (Y↑X).v
LN                   @@@@ LN(Y.v) Y.u*X.v/Y.v (Y↑X).v
RCL× "_Xu"           @@@@ X.u*LN(Y.v) Y.u*X.v/Y.v (Y↑X).v
COMPLEX              @@@@ TMP (Y↑X).v
ABS                  @@@@ TMP (Y↑X).v
RCL× ST Y            @@@@ TMP (Y↑X).v
ABS                  @@@@ (Y↑X).u (Y↑X).v
COMPLEX              @@@@ Y↑X
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UNEG)
@@@@ IN:  X: X     Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: -X    Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "U+/-"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u   X.v
ABS                  @@@@ |X.u| X.v
X<>Y                 @@@@ X.v   |X.u| 
+/-                  @@@@ -X.v  |X.u| 
X<>Y                 @@@@ |X.u| X.v 
COMPLEX              @@@@ -X
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UINV)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: 1/X    Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "U1/X"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u     X.v
ABS                  @@@@ |X.u|   X.v
X<>Y                 @@@@ X.v     |X.u| 
1/X                  @@@@ (1/X).v |X.u| 
X<>Y                 @@@@ |X.u|   (1/X).v 
RCL× ST Y            @@@@ TMP     (1/X).v 
RCL× ST Y            @@@@ (1/X).u (1/X).v 
COMPLEX              @@@@ (1/X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UABS)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ABS(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UABS"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u   X.v
ABS                  @@@@ |X.u| X.v
X<>Y                 @@@@ X.v   |X.u| 
ABS                  @@@@ |X.v| |X.u| 
X<>Y                 @@@@ |X.u| |X.v| 
COMPLEX              @@@@ ABS(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (ULN)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ln(X)  Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "ULN"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
÷                    @@@@ X.u/X.v X.v
ABS                  @@@@ ln(X).u X.v
X<>Y                 @@@@ X.v ln(X).u 
LN                   @@@@ ln(X).v ln(X).u 
X<>Y                 @@@@ ln(X).u ln(X).v 
COMPLEX              @@@@ ln(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UEXP)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: E↑X    Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UE↑X"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
X<>Y                 @@@@ X.v X.u 
E↑X                  @@@@ exp(X).v X.u
X<>Y                 @@@@ X.u exp(X).v 
RCL× ST Y            @@@@ exp(X).v*X.u exp(X).v 
ABS                  @@@@ exp(X).u exp(X).v 
COMPLEX              @@@@ exp(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (USIN)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: SIN(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "USIN"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
COS                  @@@@ COS(X.v) X.u X.v
×                    @@@@ COS(X.v)*X.u X.v
ABS                  @@@@ SIN(X).u X.v 
X<>Y                 @@@@ X.v SIN(X).u 
SIN                  @@@@ SIN(X).v SIN(X).u
X<>Y                 @@@@ SIN(X).u SIN(X).v 
COMPLEX              @@@@ SIN(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UCOS)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: COS(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UCOS"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
SIN                  @@@@ SIN(X.v) X.u X.v
×                    @@@@ SIN(X.v)*X.u X.v
ABS                  @@@@ COS(X).u X.v 
X<>Y                 @@@@ X.v COS(X).u 
COS                  @@@@ COS(X).v COS(X).u
X<>Y                 @@@@ COS(X).u COS(X).v 
COMPLEX              @@@@ COS(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UTAN)
@@@@ IN:  X: X      Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: TAN(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UTAN"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
COS                  @@@@ COS(X.v) X.u X.v
1/X                  @@@@ SEC(X.v) X.u X.v 
X↑2                  @@@@ SEC^2(X.v) X.u X.v
×                    @@@@ SEC^2(X.v)*X.u X.v
ABS                  @@@@ tan(X).u X.v 
X<>Y                 @@@@ X.v tan(X).u
TAN                  @@@@ tan(X).v tan(X).u
X<>Y                 @@@@ tan(X).u tan(X).v 
COMPLEX              @@@@ tan(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UASIN)
@@@@ IN:  X: X       Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ASIN(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UASIN"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
1                    @@@@ 1 X.u X.v
RCL ST Z             @@@@ X.v 1 X.u X.v
X↑2                  @@@@ X.v^2 1 X.u X.v
-                    @@@@ 1-X.v^2 X.u X.v
SQRT                 @@@@ SQRT(1-X.v^2) X.u X.v
÷                    @@@@ X.u/SQRT(1-X.v^2) X.v
ABS                  @@@@ ASIN(X).u X.v
X<>Y                 @@@@ X.v ASIN(X).u 
ASIN                 @@@@ ASIN(X).v ASIN(X).u
X<>Y                 @@@@ ASIN(X).u ASIN(X).v 
COMPLEX              @@@@ ASIN(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UACOS)
@@@@ IN:  X: X       Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ACOS(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UACOS"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
1                    @@@@ 1 X.u X.v
RCL ST Z             @@@@ X.v 1 X.u X.v
X↑2                  @@@@ X.v^2 1 X.u X.v
-                    @@@@ 1-X.v^2 X.u X.v
SQRT                 @@@@ SQRT(1-X.v^2) X.u X.v
÷                    @@@@ X.u/SQRT(1-X.v^2) X.v
ABS                  @@@@ ACOS(X).u X.v
X<>Y                 @@@@ X.v ACOS(X).u 
ACOS                 @@@@ ACOS(X).v ACOS(X).u
X<>Y                 @@@@ ACOS(X).u ACOS(X).v 
COMPLEX              @@@@ ACOS(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UATAN)
@@@@ IN:  X: X       Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ATAN(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UATAN"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
1                    @@@@ 1 X.u X.v
RCL ST Z             @@@@ X.v 1 X.u X.v
X↑2                  @@@@ X.v^2 1 X.u X.v
+                    @@@@ 1+X.v^2 X.u X.v
÷                    @@@@ X.u/(1+X.v^2) X.v
ABS                  @@@@ ATAN(X).u X.v
X<>Y                 @@@@ X.v ATAN(X).u 
ATAN                 @@@@ ATAN(X).v ATAN(X).u
X<>Y                 @@@@ ATAN(X).u ATAN(X).v 
COMPLEX              @@@@ ATAN(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (USINH)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: SINH(X)  Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "USINH"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
COSH                 @@@@ COSH(X.v) X.u X.v
×                    @@@@ COSH(X.v)*X.u X.v
ABS                  @@@@ SINH(X).u X.v 
X<>Y                 @@@@ X.v SINH(X).u 
SINH                 @@@@ SINH(X).v SINH(X).u
X<>Y                 @@@@ SINH(X).u SINH(X).v 
COMPLEX              @@@@ SINH(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UCOSH)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: COSH(X)  Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UCOSH"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
SINH                 @@@@ SINH(X.v) X.u X.v
×                    @@@@ SINH(X.v)*X.u X.v
ABS                  @@@@ COSH(X).u X.v 
X<>Y                 @@@@ X.v COSH(X).u 
COSH                 @@@@ COSH(X).v COSH(X).u
X<>Y                 @@@@ COSH(X).u COSH(X).v 
COMPLEX              @@@@ COSH(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UTANH)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: TANH(X)  Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UTANH"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
COSH                 @@@@ COSH(X.v) X.u X.v
1/X                  @@@@ SECH(X.v) X.u X.v 
X↑2                  @@@@ SECH^2(X.v) X.u X.v
×                    @@@@ SECH^2(X.v)*X.u X.v
ABS                  @@@@ tanh(X).u X.v 
X<>Y                 @@@@ X.v tanh(X).u
TANH                 @@@@ tanh(X).v tanh(X).u
X<>Y                 @@@@ tanh(X).u tanh(X).v 
COMPLEX              @@@@ tanh(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UASINH)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ASINH(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UASINH"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
X↑2                  @@@@ X.v^2 X.u X.v
1                    @@@@ 1 X.v^2 X.u X.v
+                    @@@@ X.v^2-1 X.u X.v
SQRT                 @@@@ SQRT(X.v^2-1) X.u X.v
÷                    @@@@ X.u/SQRT(X.v^2-1) X.v
ABS                  @@@@ ASINH(X).u X.v
X<>Y                 @@@@ X.v ASINH(X).u 
ASINH                @@@@ ASINH(X).v ASINH(X).u
X<>Y                 @@@@ ASINH(X).u ASINH(X).v 
COMPLEX              @@@@ ASINH(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UACOSH)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ACOSH(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UACOSH"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
X↑2                  @@@@ X.v^2 X.u X.v
1                    @@@@ 1 X.v^2 X.u X.v
-                    @@@@ X.v^2-1 X.u X.v
SQRT                 @@@@ SQRT(X.v^2-1) X.u X.v
÷                    @@@@ X.u/SQRT(X.v^2-1) X.v
ABS                  @@@@ ACOSH(X).u X.v
X<>Y                 @@@@ X.v ACOSH(X).u 
ACOSH                @@@@ ACOSH(X).v ACOSH(X).u
X<>Y                 @@@@ ACOSH(X).u ACOSH(X).v 
COMPLEX              @@@@ ACOSH(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UATANH)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: ATANH(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UATANH"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
X↑2                  @@@@ X.v^2 X.u X.v
1                    @@@@ 1 X.v^2 X.u X.v
-                    @@@@ 1-X.v^2 X.u X.v
÷                    @@@@ X.u/(1-X.v^2) X.v
ABS                  @@@@ ATANH(X).u X.v
X<>Y                 @@@@ X.v ATANH(X).u 
ATANH                @@@@ ATANH(X).v ATANH(X).u
X<>Y                 @@@@ ATANH(X).u ATANH(X).v 
COMPLEX              @@@@ ATANH(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UGAMMA)
@@@@ IN:  X: X        Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT: X: GAMMA(X) Quantity & Uncertainty (Uncertainty is 0 when X is exact)
LBL "UGAMMA"
FUNC 11              @@@@ X
L4STK
XEQ 99 @NM@ R->C     @@@@ X
COMPLEX              @@@@ X.u X.v
RCL ST Y             @@@@ X.v X.u X.v
XEQ "DIGAMM"         @@@@ DIGAMM(X.v) X.u X.v
×                    @@@@ DIGAMM(X.v)*X.u X.v
X<>Y                 @@@@ X.v DIGAMM(X.v)*X.u 
GAMMA                @@@@ GAMMA(X.v) DIGAMM(X.v)*X.u 
X<>Y                 @@@@ DIGAMM(X.v)*X.u GAMMA(X.v) 
RCL× ST Y            @@@@ GAMMA(X.v)*DIGAMM(X.v)*X.u GAMMA(X.v) 
ABS                  @@@@ GAMMA(X).u GAMMA(X).v
COMPLEX              @@@@ GAMMA(X)
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UI2UV)
@@@@ DSC: Convert interval to center+uncertanty
@@@@ IN:  Y: Interval endpoint
@@@@      X: Interval endpoint
@@@@ OUT: X: Quantity & Uncertainty
@@@@ UPD: 2021-05-07
LBL "UI→VU"
FUNC 21  @@@@ P1      P2
L4STK
RCL ST Y @@@@ P2      P1    P2
RCL ST Y @@@@ P1      P2    P1 P2
+        @@@@ P1+P2   P1    P2 P2
2        @@@@ 2       P1+P2 P1 P2
÷        @@@@ C       P1    P2 P2
RCL ST Z @@@@ P2      C     P1 P2
RCL ST Z @@@@ P1      P2    C  P1
-        @@@@ P2-P1   C     P1 P1
ABS      @@@@ |P2-P1| C     P1 P1
2        @@@@ 2       R     C  P1
÷        @@@@ R/2     P2    C  P1
COMPLEX  @@@@ V+iU    C     P1 P1
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UUV2I)
@@@@ DSC: center+uncertanty to interval
@@@@ IN:  X: X Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT  Y: Interval left point
@@@@      X: Interval right point
@@@@ UPD: 2021-05-07
LBL "UVU→I"
FUNC 12           @@@@ X
L4STK
XEQ 99 @NM@ R->C  @@@@ X
COMPLEX           @@@@ X.u     X.v
ABS               @@@@ X.u     X.v
RCL ST Y          @@@@ X.v     X.u     X.v
RCL ST Y          @@@@ X.u     X.v     X.u     X.v
-                 @@@@ MIN     X.u     X.v     X.v
RCL ST Z          @@@@ X.v     MIN     X.u     X.v
RCL ST Z          @@@@ X.u     X.v     MIN     X.u
+                 @@@@ MAX     MIN     X.u     X.u
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UV2PERC)
@@@@ DSC: center+uncertanty to Percentage Uncertainty
@@@@ IN:  X: X Quantity & Uncertainty _or_ Exact Quantity
@@@@ OUT  X: U%
@@@@ UPD: 2021-05-07
LBL "UVU→%"
FUNC 11           @@@@ X
L4STK
XEQ 99 @NM@ R->C  @@@@ X
COMPLEX           @@@@ X.u       X.v
X<>Y              @@@@ X.v       X.u
÷                 @@@@ X.u/X.v      
ABS               @@@@ |X.u/X.v| 
100               @@@@ 100       |X.u/X.v| 
×                 @@@@ %T
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (UUMULT)
@@@@ DSC: Multiply Uncertainty 
@@@@ IN:  Y: Quantity & Uncertainty _or_ Exact Quantity
@@@@      X: Eexact quantity
@@@@ OUT  X: Quantity & Uncertainty
@@@@ UPD: 2021-05-07
LBL "U×U"
FUNC 21           @@@@ X        Y
L4STK
ABS               @@@@ |X|      Y
X<>Y              @@@@ Y        |X|    
XEQ 99 @NM@ R->C  @@@@ Y        |X|    
COMPLEX           @@@@ Y.u      Y.v   |X|
RCL× ST Z         @@@@ Y.u×|Y|  Y.v   |X|
COMPLEX           @@@@ Y
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@ DSC: If X is not complex, make it the real part of a complex number
LBL 99 @NM@ R->C
FUNC 11
L4STK
CPX?
RTN
0
COMPLEX
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@ DSC: If X is not complex, do a COMPLEX
LBL 98 @NM@ ?CPLX
FUNC 11
L4STK
CPX?
RTN
COMPLEX
RTN

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
END

6. EOF