Average Error: 13.6 → 2.1
Time: 22.7s
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 r204177 = wj;
        double r204178 = exp(r204177);
        double r204179 = r204177 * r204178;
        double r204180 = x;
        double r204181 = r204179 - r204180;
        double r204182 = r204178 + r204179;
        double r204183 = r204181 / r204182;
        double r204184 = r204177 - r204183;
        return r204184;
}

double f(double wj, double x) {
        double r204185 = x;
        double r204186 = wj;
        double r204187 = 2.0;
        double r204188 = pow(r204186, r204187);
        double r204189 = r204185 + r204188;
        double r204190 = r204186 * r204185;
        double r204191 = r204187 * r204190;
        double r204192 = r204189 - r204191;
        return r204192;
}

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

Derivation

  1. Initial program 13.6

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

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

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

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

Reproduce

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