Average Error: 13.3 → 0.6
Time: 1.2m
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj - \left(\frac{\sqrt[3]{e^{wj} \cdot wj - x}}{\sqrt{\left(wj + 1\right) \cdot e^{wj}}} \cdot \sqrt[3]{e^{wj} \cdot wj - x}\right) \cdot \frac{\sqrt[3]{e^{wj} \cdot wj - x}}{\sqrt{\left(wj + 1\right) \cdot e^{wj}}} \le 7.29930593245523 \cdot 10^{-15}:\\ \;\;\;\;\left({wj}^{2} + x\right) - 2 \cdot \left(wj \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{1}{\frac{wj + 1}{wj - \frac{x}{e^{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.3
Target12.7
Herbie0.6
\[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 (* (* (/ (cbrt (- (* (exp wj) wj) x)) (sqrt (* (+ wj 1) (exp wj)))) (cbrt (- (* (exp wj) wj) x))) (/ (cbrt (- (* (exp wj) wj) x)) (sqrt (* (+ wj 1) (exp wj)))))) < 7.29930593245523e-15

    1. Initial program 17.7

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

      \[\leadsto \color{blue}{\left({wj}^{2} + x\right) - 2 \cdot \left(wj \cdot x\right)}\]

    if 7.29930593245523e-15 < (- wj (* (* (/ (cbrt (- (* (exp wj) wj) x)) (sqrt (* (+ wj 1) (exp wj)))) (cbrt (- (* (exp wj) wj) x))) (/ (cbrt (- (* (exp wj) wj) x)) (sqrt (* (+ wj 1) (exp wj))))))

    1. Initial program 2.5

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

      \[\leadsto wj - \color{blue}{\frac{1}{\frac{e^{wj} + wj \cdot e^{wj}}{wj \cdot e^{wj} - x}}}\]
    4. Applied simplify0.6

      \[\leadsto wj - \frac{1}{\color{blue}{\frac{wj + 1}{wj - \frac{x}{e^{wj}}}}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.2m)Debug logProfile

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