Average Error: 13.1 → 2.3
Time: 13.8s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[x + wj \cdot \left(wj - 2 \cdot x\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
x + wj \cdot \left(wj - 2 \cdot x\right)
double f(double wj, double x) {
        double r234620 = wj;
        double r234621 = exp(r234620);
        double r234622 = r234620 * r234621;
        double r234623 = x;
        double r234624 = r234622 - r234623;
        double r234625 = r234621 + r234622;
        double r234626 = r234624 / r234625;
        double r234627 = r234620 - r234626;
        return r234627;
}

double f(double wj, double x) {
        double r234628 = x;
        double r234629 = wj;
        double r234630 = 2.0;
        double r234631 = r234630 * r234628;
        double r234632 = r234629 - r234631;
        double r234633 = r234629 * r234632;
        double r234634 = r234628 + r234633;
        return r234634;
}

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.1
Target12.4
Herbie2.3
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Initial program 13.1

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
  2. Simplified12.4

    \[\leadsto \color{blue}{wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}}\]
  3. Taylor expanded around 0 2.3

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

    \[\leadsto \color{blue}{x + wj \cdot \left(wj - 2 \cdot x\right)}\]
  5. Final simplification2.3

    \[\leadsto x + wj \cdot \left(wj - 2 \cdot x\right)\]

Reproduce

herbie shell --seed 2019350 
(FPCore (wj x)
  :name "Jmat.Real.lambertw, newton loop step"
  :precision binary64

  :herbie-target
  (- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))

  (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))