Average Error: 13.4 → 2.2
Time: 5.6s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)
double f(double wj, double x) {
        double r182249 = wj;
        double r182250 = exp(r182249);
        double r182251 = r182249 * r182250;
        double r182252 = x;
        double r182253 = r182251 - r182252;
        double r182254 = r182250 + r182251;
        double r182255 = r182253 / r182254;
        double r182256 = r182249 - r182255;
        return r182256;
}

double f(double wj, double x) {
        double r182257 = x;
        double r182258 = wj;
        double r182259 = 2.0;
        double r182260 = pow(r182258, r182259);
        double r182261 = r182257 + r182260;
        double r182262 = r182258 * r182257;
        double r182263 = r182259 * r182262;
        double r182264 = r182261 - r182263;
        return r182264;
}

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}{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj + 1}}\]
  3. Taylor expanded around 0 2.2

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

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

Reproduce

herbie shell --seed 2020046 
(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))))))