Average Error: 13.5 → 1.3
Time: 1.4m
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[(\left({\left(e^{wj}\right)}^{\left(\frac{1}{2} \cdot wj\right)}\right) \cdot \left(\frac{wj \cdot wj}{e^{wj}}\right) + \left(\frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*}\right))_*\]

Error

Bits error versus wj

Bits error versus x

Target

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

Derivation

  1. Initial program 13.5

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
  2. Using strategy rm
  3. Applied div-sub13.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 associate--r-7.5

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

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

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

    \[\leadsto \color{blue}{\frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + (\left(wj \cdot wj\right) \cdot \left(1 - wj\right) + \left({wj}^{4}\right))_*}\]
  8. Using strategy rm
  9. Applied add-exp-log1.8

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

    \[\leadsto \frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + e^{\color{blue}{\left(\frac{1}{2} \cdot {wj}^{2} + 2 \cdot \log wj\right) - wj}}\]
  11. Applied simplify1.3

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

Runtime

Time bar (total: 1.4m)Debug logProfile

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