Average Error: 13.6 → 2.1
Time: 4.6s
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 r248266 = wj;
        double r248267 = exp(r248266);
        double r248268 = r248266 * r248267;
        double r248269 = x;
        double r248270 = r248268 - r248269;
        double r248271 = r248267 + r248268;
        double r248272 = r248270 / r248271;
        double r248273 = r248266 - r248272;
        return r248273;
}

double f(double wj, double x) {
        double r248274 = x;
        double r248275 = wj;
        double r248276 = 2.0;
        double r248277 = r248276 * r248274;
        double r248278 = r248275 - r248277;
        double r248279 = r248275 * r248278;
        double r248280 = r248274 + r248279;
        return r248280;
}

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
Target13.0
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. Simplified13.0

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

    \[\leadsto \color{blue}{\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)}\]
  4. Using strategy rm
  5. Applied associate--l+2.1

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

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

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

Reproduce

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