Average Error: 13.7 → 1.6
Time: 45.7s
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj \le 4.520570026650869 \cdot 10^{-18}:\\ \;\;\;\;(wj \cdot wj + x)_*\\ \mathbf{if}\;wj \le 692.3975420953346:\\ \;\;\;\;wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}\\ \mathbf{else}:\\ \;\;\;\;wj - \left(\left(1 + \frac{x}{e^{wj} \cdot {wj}^{2}}\right) - \frac{x}{e^{wj} \cdot wj}\right)\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

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

Derivation

  1. Split input into 3 regimes
  2. if wj < 4.520570026650869e-18

    1. Initial program 13.2

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Applied simplify13.2

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

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

      \[\leadsto \color{blue}{(wj \cdot wj + x)_*}\]

    if 4.520570026650869e-18 < wj < 692.3975420953346

    1. Initial program 13.1

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Applied simplify13.2

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

    if 692.3975420953346 < wj

    1. Initial program 62.0

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Applied simplify62.0

      \[\leadsto \color{blue}{wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}}\]
    3. Taylor expanded around inf 15.1

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

Runtime

Time bar (total: 45.7s)Debug logProfile

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