Average Error: 13.6 → 1.2
Time: 51.6s
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 3.2251490900753397 \cdot 10^{-12}:\\
\;\;\;\;(wj \cdot wj + x)_*\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*} - \left(\frac{wj}{1 + wj} - wj\right)\\
\end{array}\]
Target
| Original | 13.6 |
|---|
| Target | 13.0 |
|---|
| Herbie | 1.2 |
|---|
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]
Derivation
- Split input into 2 regimes
if wj < 3.2251490900753397e-12
Initial program 13.3
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify13.3
\[\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.2
\[\leadsto wj - \color{blue}{\left(wj - \left({wj}^{2} + x\right)\right)}\]
Applied simplify1.1
\[\leadsto \color{blue}{(wj \cdot wj + x)_*}\]
if 3.2251490900753397e-12 < wj
Initial program 23.1
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
- Using strategy
rm Applied div-sub23.1
\[\leadsto wj - \color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\]
Applied simplify4.5
\[\leadsto wj - \left(\color{blue}{\frac{wj}{wj + 1}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]
Applied simplify4.5
\[\leadsto wj - \left(\frac{wj}{wj + 1} - \color{blue}{\frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*}}\right)\]
Taylor expanded around inf 4.5
\[\leadsto wj - \left(\frac{wj}{wj + 1} - \frac{x}{\color{blue}{e^{wj} \cdot wj + e^{wj}}}\right)\]
Applied simplify4.5
\[\leadsto \color{blue}{\frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*} - \left(\frac{wj}{1 + wj} - wj\right)}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed 2018206 +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))))))