Average Error: 13.7 → 2.1
Time: 59.8s
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 r33875676 = wj;
        double r33875677 = exp(r33875676);
        double r33875678 = r33875676 * r33875677;
        double r33875679 = x;
        double r33875680 = r33875678 - r33875679;
        double r33875681 = r33875677 + r33875678;
        double r33875682 = r33875680 / r33875681;
        double r33875683 = r33875676 - r33875682;
        return r33875683;
}

double f(double wj, double x) {
        double r33875684 = wj;
        double r33875685 = x;
        double r33875686 = -2.0;
        double r33875687 = r33875685 * r33875686;
        double r33875688 = r33875684 + r33875687;
        double r33875689 = r33875684 * r33875688;
        double r33875690 = r33875689 + r33875685;
        return r33875690;
}

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

Derivation

  1. Initial program 13.7

    \[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.1

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

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

Reproduce

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