Average Error: 13.7 → 0.2
Time: 1.3m
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{x}{e^{wj}}}{1 + wj} + e^{\log \left({wj}^{4} + \left(1 - wj\right) \cdot \left(wj \cdot wj\right)\right)} \le 0.0019065608306473914:\\ \;\;\;\;\frac{\frac{x}{e^{wj}}}{1 + wj} + \left({wj}^{4} + \left(1 - wj\right) \cdot \left(wj \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\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.7
Target13.1
Herbie0.2
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if (+ (/ (/ x (exp wj)) (+ 1 wj)) (exp (log (+ (pow wj 4) (* (- 1 wj) (* wj wj)))))) < 0.0019065608306473914

    1. Initial program 17.9

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

      \[\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-9.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 simplify9.3

      \[\leadsto \color{blue}{\left(wj - \frac{wj}{1 + wj}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
    6. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{\left(\left({wj}^{4} + {wj}^{2}\right) - {wj}^{3}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
    7. Applied simplify0.2

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

    if 0.0019065608306473914 < (+ (/ (/ x (exp wj)) (+ 1 wj)) (exp (log (+ (pow wj 4) (* (- 1 wj) (* wj wj))))))

    1. Initial program 2.1

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

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

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

Runtime

Time bar (total: 1.3m)Debug logProfile

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