Average Error: 13.4 → 2.3
Time: 19.0s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\left(x + wj \cdot wj\right) - 2 \cdot \left(x \cdot wj\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\left(x + wj \cdot wj\right) - 2 \cdot \left(x \cdot wj\right)
double f(double wj, double x) {
        double r13047826 = wj;
        double r13047827 = exp(r13047826);
        double r13047828 = r13047826 * r13047827;
        double r13047829 = x;
        double r13047830 = r13047828 - r13047829;
        double r13047831 = r13047827 + r13047828;
        double r13047832 = r13047830 / r13047831;
        double r13047833 = r13047826 - r13047832;
        return r13047833;
}

double f(double wj, double x) {
        double r13047834 = x;
        double r13047835 = wj;
        double r13047836 = r13047835 * r13047835;
        double r13047837 = r13047834 + r13047836;
        double r13047838 = 2.0;
        double r13047839 = r13047834 * r13047835;
        double r13047840 = r13047838 * r13047839;
        double r13047841 = r13047837 - r13047840;
        return r13047841;
}

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.3
\[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. Taylor expanded around 0 2.3

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

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

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

Reproduce

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

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

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