Average Error: 13.3 → 2.0
Time: 9.0s
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 r269752 = wj;
        double r269753 = exp(r269752);
        double r269754 = r269752 * r269753;
        double r269755 = x;
        double r269756 = r269754 - r269755;
        double r269757 = r269753 + r269754;
        double r269758 = r269756 / r269757;
        double r269759 = r269752 - r269758;
        return r269759;
}

double f(double wj, double x) {
        double r269760 = x;
        double r269761 = wj;
        double r269762 = 2.0;
        double r269763 = pow(r269761, r269762);
        double r269764 = r269760 + r269763;
        double r269765 = r269761 * r269760;
        double r269766 = r269762 * r269765;
        double r269767 = r269764 - r269766;
        return r269767;
}

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

Derivation

  1. Initial program 13.3

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

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

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

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

Reproduce

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