Average Error: 13.4 → 0.5
Time: 1.0m
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 -4.0569538964864165 \cdot 10^{-12} \lor \neg \left(wj \le 2.027931899622708 \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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.4
Target12.9
Herbie0.5
\[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 < -4.0569538964864165e-12 or 2.027931899622708e-11 < wj

    1. Initial program 16.2

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

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

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

    if -4.0569538964864165e-12 < wj < 2.027931899622708e-11

    1. Initial program 13.3

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;wj \le -4.0569538964864165 \cdot 10^{-12} \lor \neg \left(wj \le 2.027931899622708 \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: 1.0m)Debug logProfile

herbie shell --seed '#(1072936661 1621281212 3440817831 3219514234 460296804 1258167384)' 
(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))))))