Average Error: 14.1 → 0.2
Time: 59.4s
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj - \frac{{\left(wj \cdot e^{wj}\right)}^{3} - {x}^{3}}{\left(e^{wj} + wj \cdot e^{wj}\right) \cdot \left(\left(wj \cdot e^{wj}\right) \cdot \left(wj \cdot e^{wj}\right) + \left(x \cdot x + \left(wj \cdot e^{wj}\right) \cdot x\right)\right)} \le 1.121841522316379 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{x}{e^{wj}}}{1 + wj} + \left({wj}^{4} + \left(1 - wj\right) \cdot \left(wj \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

Original14.1
Target13.5
Herbie0.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 (/ (- (pow (* wj (exp wj)) 3) (pow x 3)) (* (+ (exp wj) (* wj (exp wj))) (+ (* (* wj (exp wj)) (* wj (exp wj))) (+ (* x x) (* (* wj (exp wj)) x)))))) < 1.121841522316379e-13

    1. Initial program 20.9

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

      \[\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 associate--r-14.2

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

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

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

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

    if 1.121841522316379e-13 < (- wj (/ (- (pow (* wj (exp wj)) 3) (pow x 3)) (* (+ (exp wj) (* wj (exp wj))) (+ (* (* wj (exp wj)) (* wj (exp wj))) (+ (* x x) (* (* wj (exp wj)) x))))))

    1. Initial program 7.3

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

      \[\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 associate--r-1.3

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

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

Runtime

Time bar (total: 59.4s)Debug logProfile

herbie shell --seed '#(1071725047 233389029 2036512464 3988615230 2972226563 1111574017)' 
(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))))))