Average Error: 13.3 → 0.9
Time: 4.0m
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;\left(\frac{1}{wj} + wj\right) - (\left(\frac{1}{wj}\right) \cdot \left(\frac{1}{wj}\right) + 1)_* \le -125981247538304.98:\\ \;\;\;\;(\left(x \cdot 2\right) \cdot \left(-wj\right) + \left((wj \cdot wj + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{(\left(e^{wj}\right) \cdot wj + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (- (+ (/ 1 wj) wj) (fma (/ 1 wj) (/ 1 wj) 1)) < -125981247538304.98

    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 0.2

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

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

    if -125981247538304.98 < (- (+ (/ 1 wj) wj) (fma (/ 1 wj) (/ 1 wj) 1))

    1. Initial program 16.2

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Applied simplify16.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. Recombined 2 regimes into one program.

Runtime

Time bar (total: 4.0m)Debug logProfile

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