Average Error: 13.3 → 1.2
Time: 53.0s
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 -1.2258032662059475 \cdot 10^{-16}:\\
\;\;\;\;wj - \frac{1}{\frac{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}}\\
\mathbf{if}\;wj \le 1.179072063820203:\\
\;\;\;\;(wj \cdot wj + x)_*\\
\mathbf{else}:\\
\;\;\;\;wj - \left(\left(1 + \frac{x}{e^{wj} \cdot {wj}^{2}}\right) - \frac{x}{e^{wj} \cdot wj}\right)\\
\end{array}\]
Target
| Original | 13.3 |
|---|
| Target | 12.7 |
|---|
| 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 < -1.2258032662059475e-16
Initial program 7.8
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify7.8
\[\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-num7.9
\[\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))_*}}}\]
if -1.2258032662059475e-16 < wj < 1.179072063820203
Initial program 13.0
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify13.0
\[\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 13.5
\[\leadsto wj - \color{blue}{\left(wj - \left({wj}^{2} + x\right)\right)}\]
Applied simplify0.6
\[\leadsto \color{blue}{(wj \cdot wj + x)_*}\]
if 1.179072063820203 < wj
Initial program 42.5
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify42.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))_*}}\]
Taylor expanded around inf 23.3
\[\leadsto wj - \color{blue}{\left(\left(1 + \frac{x}{e^{wj} \cdot {wj}^{2}}\right) - \frac{x}{e^{wj} \cdot wj}\right)}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2018199 +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))))))