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

Error

Bits error versus wj

Bits error versus x

Target

Original13.6
Target13.0
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 < 9.475873275491869e-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. Simplified0.9

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

    if 9.475873275491869e-09 < wj

    1. Initial program 22.2

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied distribute-rgt1-in22.3

      \[\leadsto wj - \frac{wj \cdot e^{wj} - x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}}\]
    4. Applied *-un-lft-identity22.3

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

      \[\leadsto wj - \color{blue}{\frac{1}{wj + 1} \cdot \frac{wj \cdot e^{wj} - x}{e^{wj}}}\]
    6. Simplified3.3

      \[\leadsto wj - \frac{1}{wj + 1} \cdot \color{blue}{\left(wj - \frac{x}{e^{wj}}\right)}\]
    7. Using strategy rm
    8. Applied flip-+3.4

      \[\leadsto wj - \frac{1}{\color{blue}{\frac{wj \cdot wj - 1 \cdot 1}{wj - 1}}} \cdot \left(wj - \frac{x}{e^{wj}}\right)\]
    9. Applied associate-/r/3.5

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

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

Runtime

Time bar (total: 53.0s)Debug logProfile

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