Average Error: 13.6 → 1.0
Time: 40.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 7.481673145473972 \cdot 10^{-09}:\\ \;\;\;\;(\left(x \cdot 2\right) \cdot \left(-wj\right) + \left((wj \cdot wj + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + e^{wj} \cdot wj}\right)\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

Original13.6
Target13.1
Herbie1.0
\[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 < 7.481673145473972e-09

    1. Initial program 13.3

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

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

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

    if 7.481673145473972e-09 < wj

    1. Initial program 24.6

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

      \[\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. Simplified3.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \le 7.481673145473972 \cdot 10^{-09}:\\ \;\;\;\;(\left(x \cdot 2\right) \cdot \left(-wj\right) + \left((wj \cdot wj + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + e^{wj} \cdot wj}\right)\\ \end{array}\]

Runtime

Time bar (total: 40.6s)Debug logProfile

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