UP | HOME

free42 equations

Author: Mitch Richling
Updated: 2022-06-04 16:21:07

Copyright 2024 Mitch Richling. All rights reserved.

Table of Contents

1. Metadata

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

A PDF version of this file may be found here: https://richmit.github.io/hp42/equations.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

Here we have a few handy equations. All of them have MVAR declarations so they work with the 42s' integrator and solver.

Note that this is one "program" containing "sub-programs" with global labels. Why not just let each equation be an individual program? RAM! The DM42 chews up about half a kilobyte per program, and by combining them all into one program we save a ton of space. Note that if CLP is used on any of the global labels, then all of the equations are deleted (i.e. the entire program is zapped). That is a feature! It makes it easy to delete all the equations at one time so they can all be reloaded when the Git repo is updated.

3. Master Program Label

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (EQLIB)
@@@@ DSC: Container Program for Equations
@@@@ UPD: 2021-04-18
LBL "EQLIB"

4. Equations

4.1. KEPLE: Kepler's Equation

\[E_A - E \sin(E_A) - M_A = 0\]

\(M_A\) is the mean anomaly, and is represented by "MA" in the program. \(E_A\) is the eccentric anomaly, and is represented by "EA" in the program. \(E\) is the eccentricity.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (KEPLE)
@@@@ DSC: MVAR Kepler's Equation
@@@@ UPD: 2021-04-05
LBL "KEPLE"
MVAR "MA"
MVAR "EA"
MVAR "M"
RCL "EA"
SIN
RCL× "E"
+/-
RCL+ "EA"
RCL- "MA"
RTN
@@@@ END

4.2. KIUS: Kiusalas Perfs

\[\frac{100000}{127 K}-P = 0\]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (KIUS)
@@@@ DSC: MVAR Kiusalas Perferations vs Standard Perferations
@@@@ UPD: 2021-04-05
LBL "KIUS"
MVAR "P"
MVAR "K"
100000
RCL× "K"
127
÷
RCL- "P"
RTN
@@@@ END

4.3. TVM: Time Value of Money Equation

Can be used to solve TVM problems when solved.

\[PV+(1 + ip)\cdot PMT\cdot \frac{1-(1+i)^{-N}}{i}+FV\cdot (1+i)^{-N}\]

In the program we use "B1/E0" for the variable \(p\).

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (TVM)
@@@@ DSC: MVAR Time Value of Money Equation
@@@@ UPD: 2021-04-05
LBL "TVM"
MVAR "N"
MVAR "I"
MVAR "PV"
MVAR "PMT"
MVAR "FV"
MVAR "B1/E0"
1
ENTER
ENTER
RCL "I"
%
STO ST T
RCL× "B1/E0"
+
R↓
+
RCL "N"
+/-
Y↑X
1
X<>Y
-
LASTX
RCL× "FV"
R↓
X<>Y
÷
×
RCL× "PMT"
+
RCL+ "PV"
@@@@ END

4.4. EULI:Euler Integral

Can be used to directly compute the incomplete beta function when integrated.

Related to the beta function, F distribution, and z distributions.

\[(x-1)(1-t)^{y-1}\]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (EULI)
@@@@ DSC: MVAR Euler Integral
@@@@ UPD: 2021-04-05
LBL "EULI"
MVAR "T"
MVAR "Y"
MVAR "X"
RCL "T"
RCL  "X"
1
-
Y↑X
1
RCL- "T"
RCL "Y"
1
-
Y↑X
×
RTN
@@@@ END

4.5. NORMD: Normal Distribution PDF

Can be used to compute normal probabilities when integrated.

Related to the err function.

\[\frac{1}{s\sqrt{2\pi}}e^{-\frac{1}{2}\left(\frac{x-m}{s}\right)^2}\]

In most sources \(\sigma\) is used instead of \(s\) and \(\mu\) is used instead of \(m\).

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (NORMD)
@@@@ DSC: MVAR Normal Distribution PDF
@@@@ UPD: 2021-04-05
LBL "NORMD"
MVAR "S"
MVAR "M"
MVAR "X"
RCL "X"
RCL- "M"
RCL÷ "S"
X↑2
-2
÷
E↑X
RCL÷ "S"
2
PI
×
SQRT
÷
RTN
@@@@ END

4.6. FDIST: F Distribution PDF

Can be used to compute F probabilities when integrated.

\[\frac{\sqrt{\frac{(d_1x)^{d_1}d_2^{d_2}}{(d_1x+d_2)^{d_1+d_2}}}}{x\mathrm{B}\left(\frac{d_1}{2},\frac{d_2}{2}\right)}\]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (FDIST)
@@@@ DSC: MVAR F Distribution PDF
@@@@ UPD: 2021-04-05
LBL "FDIST"
MVAR "D1"
MVAR "D2"
MVAR "X"
RCL "D1"
2
÷
RCL "D2"
2
÷
XEQ "BETA"
RCL× "X"
RCL "D1"
RCL× "X"
RCL "D1"
Y↑X
RCL "D2"
RCL "D2"
Y↑X
×
RCL "D1"
RCL× "X"
RCL+ "D2"
RCL "D1"
RCL+ "D2"
Y↑X
÷
SQRT
X<>Y
÷
RTN
@@@@ END

4.7. CHI2: Chi Square Distribution PDF

Can be used to compute chi square probabilities when integrated.

\[\frac{x^{\frac{k}{2}-1}e^{-\frac{x}{2}}}{2^{\frac{k}{2}}\Gamma\left(\frac{k}{2}\right)}\]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (CHI2)
@@@@ DSC: MVAR Chi Square Distribution PDF
@@@@ UPD: 2021-04-05
LBL "CHI2"
MVAR "K"
MVAR "X"
RCL "K"
2
÷
ENTER
ENTER
1
-
RCL "X"
X<>Y
Y↑X
RCL "X"
-2
÷
E↑X
×
2
RCL ST Z
Y↑X
÷
X<>Y
GAMMA
÷
RTN
@@@@ END

4.8. BETAF: Beta Distribution PDF

Can be used to compute beta probabilities when integrated.

\[\frac{x^{a-1}(1-x)^{b-1}}{\mathrm{B}(a,b)}\]

In most sources \(\alpha\) is used instead of \(a\) and \(\beta\) is used instead of \(b\).

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (BETAF)
@@@@ DSC: MVAR Beta Distribution PDF
@@@@ UPD: 2021-04-05
LBL "BETAF"
MVAR "A"
MVAR "B"
MVAR "X"
RCL "A"
RCL "B"
XEQ "BETA"
RCL "X"
-1
RCL+ "A"
Y↑X
X<>Y
÷
1
RCL "X"
-
RCL "B"
1
-
Y↑X
×
RTN
@@@@ END

4.9. LOGID: Logistic Distribution PDF

Can be used to compute logistic probabilities when integrated.

\[\frac{1}{4s}\mathrm{sech}\left(\frac{x-m}{2s}\right)\]

Note \(s\) is sometimes called the "scale parameter", and \(m\) is sometimes called the "location parameter".

Also note that various symbols are used for the parameters – \(\mu\) & \(\sigma\) for example.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (LOGID)
@@@@ DSC: MVAR Logistic Distribution PDF
@@@@ UPD: 2021-04-05
LBL "LOGID"
MVAR "S"
MVAR "M"
MVAR "X"
RCL "M"
RCL- "X"
RCL÷ "S"
E↑X
ENTER
ENTER
1
+
X↑2
÷
RCL÷ "S"
RTN
@@@@ END

4.10. STUTD: Student's t Distribution PDF

Can be used to compute Student's t probabilities when integrated.

\[\frac{1}{\sqrt{\nu}\cdot\mathrm{B}\left(\frac{1}{2},\frac{\nu}{2}\right)}\left(1+\frac{x^2}{\nu}\right)^{-\frac{\nu+1}{2}}\]

In the program "V" is used for \(\nu\).

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (STUTD)
@@@@ DSC: MVAR Student's t Distribution PDF
@@@@ UPD: 2021-04-05
LBL "STUTD"
MVAR "V"
MVAR "X"
0.5
RCL "V"
2
÷
XEQ "BETA"
RCL "V"
SQRT
×
1
RCL "X"
X↑2
RCL÷ "V"
+
1
RCL+ "V"
-2
÷
Y↑X
X<>Y
÷
RTN
@@@@ END

4.11. WEIBD: Weibull Distribution PDF

Can be used to compute Weibull probabilities when integrated.

\[\frac{k}{\lambda}\left(\frac{x}{\lambda}\right)^{k-1}e^{-\left(\frac{x}{\lambda}\right)^k}\]

In the program below we use "L" for \(\lambda\).

Note that some sources use \(\frac{1}{\lambda}\) as the parameter instead of \(\lambda\).

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (WEIBD)
@@@@ DSC: MVAR Weibull Distribution PDF
@@@@ UPD: 2021-04-05
LBL "WEIBD"
MVAR "K"
MVAR "L"
MVAR "X"
RCL "K"
RCL÷ "L"
RCL "X"
RCL÷ "L"
-1
RCL+ "K"
Y↑X
×
RCL "X"
RCL÷ "L"
RCL "K"
Y↑X
+/-
E↑X
×
RTN
@@@@ END

4.12. EXPOD: Exponential Distribution PDF

Can be used to compute exponential probabilities when integrated.

\[\lambda e^{-\lambda x}\]

In the program below we use "L" for \(\lambda\).

Note that some sources use \(\frac{1}{\lambda}\) as the parameter instead of \(\lambda\).

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (EXPOD)
@@@@ DSC: MVAR Exponential Distribution PDF
@@@@ UPD: 2021-04-05
LBL "EXPOD"
MVAR "L"
MVAR "X"
RCL "L"
RCL× "X"
+/-
E↑X
RCL× "L"
RTN
@@@@ END

4.13. SINFSF: Sinusoid Frequency Standard Form

\[A\cdot\sin(2\pi Fx+P)\]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (EXPOD)
@@@@ DSC: Sinusoid Frequency Standard Form
@@@@ UPD: 2021-05-01
LBL "SINFSF"
MVAR "X"
MVAR "A"
MVAR "P"
MVAR "F"
2
PI
×
RCL× "F"
RCL× "X"
RCL+ "P"
SIN
RCL× "A"
RTN

5. Master Program END

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

6. EOF