Average Error: 3.6 → 0.1
Time: 16.6s
Precision: 64
Internal Precision: 320
$\left(p + \frac{inflow}{lam}\right) - \frac{outflow \cdot p}{lam}$
$\begin{array}{l} \mathbf{if}\;\left(\frac{inflow}{lam} + p\right) - \frac{outflow \cdot p}{lam} = -\infty:\\ \;\;\;\;\left(\frac{inflow}{lam} + p\right) - p \cdot \frac{outflow}{lam}\\ \mathbf{elif}\;\left(\frac{inflow}{lam} + p\right) - \frac{outflow \cdot p}{lam} \le 1.1484297405980849 \cdot 10^{+305}:\\ \;\;\;\;\left(\frac{inflow}{lam} + p\right) - \frac{outflow \cdot p}{lam}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{inflow}{lam} + p\right) - \frac{p}{lam} \cdot outflow\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if (- (+ p (/ inflow lam)) (/ (* outflow p) lam)) < -inf.0

1. Initial program 60.8

$\left(p + \frac{inflow}{lam}\right) - \frac{outflow \cdot p}{lam}$
2. Using strategy rm
3. Applied div-inv60.8

$\leadsto \left(p + \frac{inflow}{lam}\right) - \color{blue}{\left(outflow \cdot p\right) \cdot \frac{1}{lam}}$
4. Using strategy rm
5. Applied pow160.8

$\leadsto \left(p + \frac{inflow}{lam}\right) - \left(outflow \cdot p\right) \cdot \color{blue}{{\left(\frac{1}{lam}\right)}^{1}}$
6. Applied pow160.8

$\leadsto \left(p + \frac{inflow}{lam}\right) - \color{blue}{{\left(outflow \cdot p\right)}^{1}} \cdot {\left(\frac{1}{lam}\right)}^{1}$
7. Applied pow-prod-down60.8

$\leadsto \left(p + \frac{inflow}{lam}\right) - \color{blue}{{\left(\left(outflow \cdot p\right) \cdot \frac{1}{lam}\right)}^{1}}$
8. Simplified0.1

$\leadsto \left(p + \frac{inflow}{lam}\right) - {\color{blue}{\left(\frac{outflow}{lam} \cdot p\right)}}^{1}$

## if -inf.0 < (- (+ p (/ inflow lam)) (/ (* outflow p) lam)) < 1.1484297405980849e+305

1. Initial program 0.1

$\left(p + \frac{inflow}{lam}\right) - \frac{outflow \cdot p}{lam}$

## if 1.1484297405980849e+305 < (- (+ p (/ inflow lam)) (/ (* outflow p) lam))

1. Initial program 54.6

$\left(p + \frac{inflow}{lam}\right) - \frac{outflow \cdot p}{lam}$
2. Initial simplification0.8

$\leadsto \left(\frac{inflow}{lam} + p\right) - \frac{p}{lam} \cdot outflow$
3. Recombined 3 regimes into one program.
4. Final simplification0.1

$\leadsto \begin{array}{l} \mathbf{if}\;\left(\frac{inflow}{lam} + p\right) - \frac{outflow \cdot p}{lam} = -\infty:\\ \;\;\;\;\left(\frac{inflow}{lam} + p\right) - p \cdot \frac{outflow}{lam}\\ \mathbf{elif}\;\left(\frac{inflow}{lam} + p\right) - \frac{outflow \cdot p}{lam} \le 1.1484297405980849 \cdot 10^{+305}:\\ \;\;\;\;\left(\frac{inflow}{lam} + p\right) - \frac{outflow \cdot p}{lam}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{inflow}{lam} + p\right) - \frac{p}{lam} \cdot outflow\\ \end{array}$

# Runtime

Time bar (total: 16.6s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)'
(FPCore (p inflow lam outflow)
:name "(p + inflow/lam) - outflow * p / lam"
(- (+ p (/ inflow lam)) (/ (* outflow p) lam)))