Average Error: 13.9 → 0.4
Time: 35.5s
Precision: 64
Internal Precision: 896
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;\left(\sqrt[3]{{wj}^{2} + x} \cdot \sqrt[3]{{wj}^{2} + x}\right) \cdot \log \left(e^{\sqrt[3]{{wj}^{2} + x}}\right) - 2 \cdot \left(wj \cdot x\right) \le -126087061.82620384:\\ \;\;\;\;wj - \left(\frac{wj}{wj + 1} - \frac{\frac{x}{1 + wj}}{e^{wj}}\right)\\ \mathbf{if}\;\left(\sqrt[3]{{wj}^{2} + x} \cdot \sqrt[3]{{wj}^{2} + x}\right) \cdot \log \left(e^{\sqrt[3]{{wj}^{2} + x}}\right) - 2 \cdot \left(wj \cdot x\right) \le 7.230032173577354 \cdot 10^{-16}:\\ \;\;\;\;\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}\]

Error

Bits error versus wj

Bits error versus x

Target

Original13.9
Target13.2
Herbie0.4
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Split input into 3 regimes
  2. if (- (* (* (cbrt (+ (pow wj 2) x)) (cbrt (+ (pow wj 2) x))) (log (exp (cbrt (+ (pow wj 2) x))))) (* 2 (* wj x))) < -126087061.82620384

    1. Initial program 0.5

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied div-sub0.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)}\]
    4. Applied simplify0.0

      \[\leadsto wj - \left(\color{blue}{\frac{wj}{wj + 1}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]
    5. Applied simplify0.0

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

    if -126087061.82620384 < (- (* (* (cbrt (+ (pow wj 2) x)) (cbrt (+ (pow wj 2) x))) (log (exp (cbrt (+ (pow wj 2) x))))) (* 2 (* wj x))) < 7.230032173577354e-16

    1. Initial program 27.5

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

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

    if 7.230032173577354e-16 < (- (* (* (cbrt (+ (pow wj 2) x)) (cbrt (+ (pow wj 2) x))) (log (exp (cbrt (+ (pow wj 2) x))))) (* 2 (* wj x)))

    1. Initial program 2.3

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

      \[\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)}\]
    4. Applied associate--r-2.3

      \[\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}}}\]
    5. Applied simplify0.5

      \[\leadsto \color{blue}{\left(wj - \frac{wj}{1 + wj}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 35.5s)Debug logProfile

herbie shell --seed '#(1064397287 3527694221 3797617954 1138343853 2854031332 1153838279)' 
(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))))))