Average Error: 14.0 → 1.2
Time: 1.0m
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
↓
\[\begin{array}{l}
\mathbf{if}\;wj \le -6.120139512610608 \cdot 10^{-09}:\\
\;\;\;\;\frac{wj \cdot wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} \cdot \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}{wj + \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}\\
\mathbf{if}\;wj \le 1.4918198301414643 \cdot 10^{-11}:\\
\;\;\;\;(wj \cdot wj + x)_*\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{1}{\frac{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}}\\
\end{array}\]
Target
| Original | 14.0 |
|---|
| Target | 13.4 |
|---|
| Herbie | 1.2 |
|---|
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]
Derivation
- Split input into 3 regimes
if wj < -6.120139512610608e-09
Initial program 3.9
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify3.9
\[\leadsto \color{blue}{wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}\]
- Using strategy
rm Applied flip--19.0
\[\leadsto \color{blue}{\frac{wj \cdot wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} \cdot \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}{wj + \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}}\]
if -6.120139512610608e-09 < wj < 1.4918198301414643e-11
Initial program 13.9
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify13.9
\[\leadsto \color{blue}{wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}\]
Taylor expanded around 0 14.0
\[\leadsto wj - \color{blue}{\left(wj - \left({wj}^{2} + x\right)\right)}\]
Applied simplify0.2
\[\leadsto \color{blue}{(wj \cdot wj + x)_*}\]
if 1.4918198301414643e-11 < wj
Initial program 22.5
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify22.5
\[\leadsto \color{blue}{wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}\]
- Using strategy
rm Applied clear-num22.6
\[\leadsto wj - \color{blue}{\frac{1}{\frac{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)' +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))