Average Error: 13.9 → 0.3
Time: 56.9s
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le -0.9633784380037818:\\ \;\;\;\;wj - \left(\frac{wj}{wj + 1} - \frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*}\right)\\ \mathbf{if}\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 8.298208654837247 \cdot 10^{-16}:\\ \;\;\;\;(wj \cdot wj + x)_*\\ \mathbf{else}:\\ \;\;\;\;wj - \left(\frac{wj}{wj + 1} - \frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*}\right)\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < -0.9633784380037818 or 8.298208654837247e-16 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))

    1. Initial program 1.6

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

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

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

    if -0.9633784380037818 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < 8.298208654837247e-16

    1. Initial program 28.1

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

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

      \[\leadsto \color{blue}{(wj \cdot wj + x)_*}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 56.9s)Debug logProfile

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