Average Error: 13.8 → 0.8
Time: 48.6s
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\sqrt{{wj}^{2} + x} \cdot \sqrt{{wj}^{2} + x} - 2 \cdot \left(wj \cdot x\right) \le 5.551065755434053 \cdot 10^{-16}:\\
\;\;\;\;\left({\left(\frac{1}{wj}\right)}^{-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 | 13.8 |
|---|
| Target | 13.2 |
|---|
| Herbie | 0.8 |
|---|
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]
Derivation
- Split input into 2 regimes
if (- (* (sqrt (+ (pow wj 2) x)) (sqrt (+ (pow wj 2) x))) (* 2 (* wj x))) < 5.551065755434053e-16
Initial program 34.8
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Taylor expanded around 0 1.4
\[\leadsto \color{blue}{\left({wj}^{2} + x\right) - 2 \cdot \left(wj \cdot x\right)}\]
Taylor expanded around inf 1.5
\[\leadsto \color{blue}{\left({\left(\frac{1}{wj}\right)}^{-2} + x\right)} - 2 \cdot \left(wj \cdot x\right)\]
if 5.551065755434053e-16 < (- (* (sqrt (+ (pow wj 2) x)) (sqrt (+ (pow wj 2) x))) (* 2 (* wj x)))
Initial program 5.5
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
- Using strategy
rm Applied div-sub5.5
\[\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.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 simplify0.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.
Runtime
herbie shell --seed '#(1071246582 2318319007 2683472949 3810440501 3233274817 2724848749)'
(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))))))