Average Error: 13.9 → 2.2
Time: 7.9s
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 r185182 = wj;
        double r185183 = exp(r185182);
        double r185184 = r185182 * r185183;
        double r185185 = x;
        double r185186 = r185184 - r185185;
        double r185187 = r185183 + r185184;
        double r185188 = r185186 / r185187;
        double r185189 = r185182 - r185188;
        return r185189;
}

double f(double wj, double x) {
        double r185190 = x;
        double r185191 = wj;
        double r185192 = 2.0;
        double r185193 = pow(r185191, r185192);
        double r185194 = r185190 + r185193;
        double r185195 = r185191 * r185190;
        double r185196 = r185192 * r185195;
        double r185197 = r185194 - r185196;
        return r185197;
}

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

Derivation

  1. Initial program 13.9

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

    \[\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 2020025 
(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))))))