Average Error: 13.6 → 1.5
Time: 21.1s
Precision: 64
Internal Precision: 128
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[(wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_* + (\left(wj \cdot x\right) \cdot \left((wj \cdot \frac{5}{2} + -2)_*\right) + x)_*\]

Error

Bits error versus wj

Bits error versus x

Target

Original13.6
Target12.9
Herbie1.5
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Initial program 13.6

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

    \[\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-7.1

    \[\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. Taylor expanded around 0 1.1

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

    \[\leadsto \color{blue}{(wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_*} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
  7. Taylor expanded around 0 1.5

    \[\leadsto (wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_* + \color{blue}{\left(\left(x + \frac{5}{2} \cdot \left(x \cdot {wj}^{2}\right)\right) - 2 \cdot \left(x \cdot wj\right)\right)}\]
  8. Simplified1.5

    \[\leadsto (wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_* + \color{blue}{(\left(x \cdot wj\right) \cdot \left((wj \cdot \frac{5}{2} + -2)_*\right) + x)_*}\]
  9. Final simplification1.5

    \[\leadsto (wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_* + (\left(wj \cdot x\right) \cdot \left((wj \cdot \frac{5}{2} + -2)_*\right) + x)_*\]

Reproduce

herbie shell --seed 2019053 +o rules:numerics
(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))))))