Average Error: 13.6 → 1.3
Time: 1.8m
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 -6.650866495614256 \cdot 10^{-16} \lor \neg \left(wj \le 1.6822743286041894 \cdot 10^{-19}\right):\\ \;\;\;\;wj - \frac{e^{wj} \cdot wj - x}{e^{wj} + e^{wj} \cdot wj}\\ \mathbf{else}:\\ \;\;\;\;x + wj \cdot wj\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.6
Target13.0
Herbie1.3
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if wj < -6.650866495614256e-16 or 1.6822743286041894e-19 < wj

    1. Initial program 17.9

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]

    if -6.650866495614256e-16 < wj < 1.6822743286041894e-19

    1. Initial program 13.2

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Taylor expanded around 0 13.2

      \[\leadsto wj - \color{blue}{\left(wj - \left({wj}^{2} + x\right)\right)}\]
    3. Applied simplify0.0

      \[\leadsto \color{blue}{x + wj \cdot wj}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify1.3

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;wj \le -6.650866495614256 \cdot 10^{-16} \lor \neg \left(wj \le 1.6822743286041894 \cdot 10^{-19}\right):\\ \;\;\;\;wj - \frac{e^{wj} \cdot wj - x}{e^{wj} + e^{wj} \cdot wj}\\ \mathbf{else}:\\ \;\;\;\;x + wj \cdot wj\\ \end{array}}\]

Runtime

Time bar (total: 1.8m)Debug logProfile

herbie shell --seed 2018296 
(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))))))