Average Error: 14.0 → 0.1
Time: 57.4s
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
↓
\[\begin{array}{l}
\mathbf{if}\;e^{\log \left(wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \le 1.1060540041510762 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(1 + wj\right)} + \left(wj \cdot wj - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 14.0 |
|---|
| Target | 13.3 |
|---|
| Herbie | 0.1 |
|---|
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]
Derivation
- Split input into 2 regimes
if (exp (log (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))) < 1.1060540041510762e-13
Initial program 38.7
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
- Using strategy
rm Applied div-sub38.7
\[\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 associate--r-20.2
\[\leadsto \color{blue}{\left(wj - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}}\]
Applied simplify20.1
\[\leadsto \color{blue}{\left(wj - \frac{wj}{1 + wj}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
Taylor expanded around 0 20.1
\[\leadsto \left(wj - \color{blue}{\left(\left({wj}^{3} + wj\right) - {wj}^{2}\right)}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
Applied simplify0.0
\[\leadsto \color{blue}{\frac{x}{e^{wj} \cdot \left(1 + wj\right)} + \left(wj \cdot wj - {wj}^{3}\right)}\]
if 1.1060540041510762e-13 < (exp (log (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))))
Initial program 1.6
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
- Using strategy
rm Applied div-sub1.6
\[\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 associate--r-1.2
\[\leadsto \color{blue}{\left(wj - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}}\]
Applied simplify0.2
\[\leadsto \color{blue}{\left(wj - \frac{wj}{1 + wj}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed 2018214
(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))))))