Average Error: 13.4 → 2.2
Time: 18.2s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\left({wj}^{2} + x\right) - 2 \cdot \left(x \cdot wj\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\left({wj}^{2} + x\right) - 2 \cdot \left(x \cdot wj\right)
double f(double wj, double x) {
        double r139477 = wj;
        double r139478 = exp(r139477);
        double r139479 = r139477 * r139478;
        double r139480 = x;
        double r139481 = r139479 - r139480;
        double r139482 = r139478 + r139479;
        double r139483 = r139481 / r139482;
        double r139484 = r139477 - r139483;
        return r139484;
}

double f(double wj, double x) {
        double r139485 = wj;
        double r139486 = 2.0;
        double r139487 = pow(r139485, r139486);
        double r139488 = x;
        double r139489 = r139487 + r139488;
        double r139490 = r139488 * r139485;
        double r139491 = r139486 * r139490;
        double r139492 = r139489 - r139491;
        return r139492;
}

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

Derivation

  1. Initial program 13.4

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

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

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

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

Reproduce

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

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

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