Average Error: 13.5 → 2.2
Time: 21.3s
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 r6454046 = wj;
        double r6454047 = exp(r6454046);
        double r6454048 = r6454046 * r6454047;
        double r6454049 = x;
        double r6454050 = r6454048 - r6454049;
        double r6454051 = r6454047 + r6454048;
        double r6454052 = r6454050 / r6454051;
        double r6454053 = r6454046 - r6454052;
        return r6454053;
}

double f(double wj, double x) {
        double r6454054 = wj;
        double r6454055 = x;
        double r6454056 = 2.0;
        double r6454057 = r6454055 * r6454056;
        double r6454058 = r6454054 - r6454057;
        double r6454059 = r6454054 * r6454058;
        double r6454060 = r6454059 + r6454055;
        return r6454060;
}

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

Derivation

  1. Initial program 13.5

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