Average Error: 13.3 → 1.2
Time: 53.0s
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 -1.2258032662059475 \cdot 10^{-16}:\\ \;\;\;\;wj - \frac{1}{\frac{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}}\\ \mathbf{if}\;wj \le 1.179072063820203:\\ \;\;\;\;(wj \cdot wj + x)_*\\ \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.3
Target12.7
Herbie1.2
\[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 < -1.2258032662059475e-16

    1. Initial program 7.8

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

      \[\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. Using strategy rm
    4. Applied clear-num7.9

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

    if -1.2258032662059475e-16 < wj < 1.179072063820203

    1. Initial program 13.0

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Applied simplify13.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 0 13.5

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

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

    if 1.179072063820203 < wj

    1. Initial program 42.5

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

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

      \[\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: 53.0s)Debug logProfile

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