Average Error: 14.3 → 2.2
Time: 4.8s
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 r187811 = wj;
        double r187812 = exp(r187811);
        double r187813 = r187811 * r187812;
        double r187814 = x;
        double r187815 = r187813 - r187814;
        double r187816 = r187812 + r187813;
        double r187817 = r187815 / r187816;
        double r187818 = r187811 - r187817;
        return r187818;
}

double f(double wj, double x) {
        double r187819 = x;
        double r187820 = wj;
        double r187821 = 2.0;
        double r187822 = pow(r187820, r187821);
        double r187823 = r187819 + r187822;
        double r187824 = r187820 * r187819;
        double r187825 = r187821 * r187824;
        double r187826 = r187823 - r187825;
        return r187826;
}

Error

Bits error versus wj

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.3
Target13.6
Herbie2.2
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Initial program 14.3

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

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