Average Error: 13.4 → 2.2
Time: 13.5s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[wj \cdot \left(wj - 2 \cdot x\right) + x\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
wj \cdot \left(wj - 2 \cdot x\right) + x
double f(double wj, double x) {
        double r144806 = wj;
        double r144807 = exp(r144806);
        double r144808 = r144806 * r144807;
        double r144809 = x;
        double r144810 = r144808 - r144809;
        double r144811 = r144807 + r144808;
        double r144812 = r144810 / r144811;
        double r144813 = r144806 - r144812;
        return r144813;
}

double f(double wj, double x) {
        double r144814 = wj;
        double r144815 = 2.0;
        double r144816 = x;
        double r144817 = r144815 * r144816;
        double r144818 = r144814 - r144817;
        double r144819 = r144814 * r144818;
        double r144820 = r144819 + r144816;
        return r144820;
}

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

Derivation

  1. Initial program 13.4

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

    \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj}\]
  3. Taylor expanded around 0 2.2

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

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

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

Reproduce

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