Average Error: 13.6 → 1.2
Time: 51.6s
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 3.2251490900753397 \cdot 10^{-12}:\\ \;\;\;\;(wj \cdot wj + x)_*\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*} - \left(\frac{wj}{1 + wj} - wj\right)\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

Original13.6
Target13.0
Herbie1.2
\[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 < 3.2251490900753397e-12

    1. Initial program 13.3

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

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

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

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

    if 3.2251490900753397e-12 < wj

    1. Initial program 23.1

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

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

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

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

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

Runtime

Time bar (total: 51.6s)Debug logProfile

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