Average Error: 14.0 → 0.4
Time: 2.8m
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 -1.761422657650809 \cdot 10^{-10} \lor \neg \left(wj \le 1.078185967556684 \cdot 10^{-11}\right):\\ \;\;\;\;wj - \frac{1}{\frac{wj + 1}{wj - \frac{x}{e^{wj}}}}\\ \mathbf{else}:\\ \;\;\;\;x + wj \cdot wj\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

Original14.0
Target13.4
Herbie0.4
\[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 < -1.761422657650809e-10 or 1.078185967556684e-11 < wj

    1. Initial program 15.7

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied clear-num15.8

      \[\leadsto wj - \color{blue}{\frac{1}{\frac{e^{wj} + wj \cdot e^{wj}}{wj \cdot e^{wj} - x}}}\]
    4. Applied simplify5.1

      \[\leadsto wj - \frac{1}{\color{blue}{\frac{wj + 1}{wj - \frac{x}{e^{wj}}}}}\]

    if -1.761422657650809e-10 < wj < 1.078185967556684e-11

    1. Initial program 13.9

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

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

      \[\leadsto \color{blue}{x + wj \cdot wj}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;wj \le -1.761422657650809 \cdot 10^{-10} \lor \neg \left(wj \le 1.078185967556684 \cdot 10^{-11}\right):\\ \;\;\;\;wj - \frac{1}{\frac{wj + 1}{wj - \frac{x}{e^{wj}}}}\\ \mathbf{else}:\\ \;\;\;\;x + wj \cdot wj\\ \end{array}}\]

Runtime

Time bar (total: 2.8m)Debug logProfile

herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)' 
(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))))))