Average Error: 13.2 → 1.0
Time: 6.0m
Precision: 64
Internal Precision: 128
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[(\left(wj \cdot wj\right) \cdot \left(wj \cdot wj - wj\right) + \left(wj \cdot wj\right))_* + \frac{x}{e^{wj} + e^{wj} \cdot wj}\]

Error

Bits error versus wj

Bits error versus x

Target

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

Derivation

  1. Initial program 13.2

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

    \[\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.4

    \[\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.0

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

    \[\leadsto \color{blue}{(\left(wj \cdot wj\right) \cdot \left(wj \cdot wj - wj\right) + \left(wj \cdot wj\right))_*} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
  7. Final simplification1.0

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

Reproduce

herbie shell --seed 2019072 +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))))))