Average Error: 13.8 → 2.2
Time: 33.2s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[wj \cdot \left(wj + x \cdot -2\right) + x\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
wj \cdot \left(wj + x \cdot -2\right) + x
double f(double wj, double x) {
        double r11937262 = wj;
        double r11937263 = exp(r11937262);
        double r11937264 = r11937262 * r11937263;
        double r11937265 = x;
        double r11937266 = r11937264 - r11937265;
        double r11937267 = r11937263 + r11937264;
        double r11937268 = r11937266 / r11937267;
        double r11937269 = r11937262 - r11937268;
        return r11937269;
}

double f(double wj, double x) {
        double r11937270 = wj;
        double r11937271 = x;
        double r11937272 = -2.0;
        double r11937273 = r11937271 * r11937272;
        double r11937274 = r11937270 + r11937273;
        double r11937275 = r11937270 * r11937274;
        double r11937276 = r11937275 + r11937271;
        return r11937276;
}

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

Derivation

  1. Initial program 13.8

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
  2. Taylor expanded around 0 2.1

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

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

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

Reproduce

herbie shell --seed 2019135 
(FPCore (wj x)
  :name "Jmat.Real.lambertw, newton loop step"

  :herbie-target
  (- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))

  (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))