Average Error: 31.5 → 0.2
Time: 10.3s
Precision: 64
Internal precision: 896
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 1.6280626156164055 \cdot 10^{-12}:\\
\;\;\;\;\left({wj}^2 + x\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\
\end{array}\]
Target
| Original | 31.5 |
| Comparison | 13.1 |
| Herbie | 0.2 |
\[ wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right) \]
Derivation
- Split input into 2 regimes.
-
if (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < 1.6280626156164055e-12
Initial program 24.6
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Applied taylor 0.0
\[\leadsto \left({wj}^2 + x\right) - 2 \cdot \left(wj \cdot x\right)\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{\left({wj}^2 + x\right) - 2 \cdot \left(wj \cdot x\right)}\]
if 1.6280626156164055e-12 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
Initial program 39.1
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
- Using strategy
rm
Applied div-sub 39.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 associate--r- 39.1
\[\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 simplify 0.4
\[\leadsto \color{blue}{\left(wj - \frac{wj}{1 + wj}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))