Average Error: 13.7 → 0.9
Time: 36.8s
Precision: 64
Internal Precision: 896
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj - \left(\frac{wj}{wj + 1} - \frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*}\right) \le 6.466522119638622 \cdot 10^{-19}:\\ \;\;\;\;(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.7
Target13.0
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 (- wj (- (/ wj (+ wj 1)) (/ x (fma (exp wj) wj (exp wj))))) < 6.466522119638622e-19

    1. Initial program 17.9

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

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

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

    if 6.466522119638622e-19 < (- wj (- (/ wj (+ wj 1)) (/ x (fma (exp wj) wj (exp wj)))))

    1. Initial program 3.1

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied div-sub3.1

      \[\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.6

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

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

Runtime

Time bar (total: 36.8s)Debug logProfile

herbie shell --seed '#(1064300848 3212030778 2049303162 3567222883 2277747821 1384278011)' +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))))))