Average Error: 13.9 → 0.3
Time: 1.7m
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 -7.928590425983746 \cdot 10^{-09} \lor \neg \left(wj \le 3.974142294647761 \cdot 10^{-09}\right):\\ \;\;\;\;\left(\frac{\frac{x}{e^{wj}}}{1 + wj} - \frac{wj}{1 + wj}\right) + wj\\ \mathbf{else}:\\ \;\;\;\;\left({wj}^{2} + x\right) - 2 \cdot \left(x \cdot wj\right)\\ \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.9
Target13.2
Herbie0.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 < -7.928590425983746e-09 or 3.974142294647761e-09 < wj

    1. Initial program 18.3

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied sub-neg18.3

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)}\]
    4. Applied simplify3.8

      \[\leadsto wj + \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)}\]

    if -7.928590425983746e-09 < wj < 3.974142294647761e-09

    1. Initial program 13.6

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

      \[\leadsto \color{blue}{\left({wj}^{2} + x\right) - 2 \cdot \left(wj \cdot x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.3

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;wj \le -7.928590425983746 \cdot 10^{-09} \lor \neg \left(wj \le 3.974142294647761 \cdot 10^{-09}\right):\\ \;\;\;\;\left(\frac{\frac{x}{e^{wj}}}{1 + wj} - \frac{wj}{1 + wj}\right) + wj\\ \mathbf{else}:\\ \;\;\;\;\left({wj}^{2} + x\right) - 2 \cdot \left(x \cdot wj\right)\\ \end{array}}\]

Runtime

Time bar (total: 1.7m)Debug logProfile

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