Average Error: 13.8 → 2.0
Time: 18.0s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[x + \left(wj \cdot wj - 2 \cdot \left(x \cdot wj\right)\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
x + \left(wj \cdot wj - 2 \cdot \left(x \cdot wj\right)\right)
double f(double wj, double x) {
        double r4137775 = wj;
        double r4137776 = exp(r4137775);
        double r4137777 = r4137775 * r4137776;
        double r4137778 = x;
        double r4137779 = r4137777 - r4137778;
        double r4137780 = r4137776 + r4137777;
        double r4137781 = r4137779 / r4137780;
        double r4137782 = r4137775 - r4137781;
        return r4137782;
}

double f(double wj, double x) {
        double r4137783 = x;
        double r4137784 = wj;
        double r4137785 = r4137784 * r4137784;
        double r4137786 = 2.0;
        double r4137787 = r4137783 * r4137784;
        double r4137788 = r4137786 * r4137787;
        double r4137789 = r4137785 - r4137788;
        double r4137790 = r4137783 + r4137789;
        return r4137790;
}

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

Derivation

  1. Initial program 13.8

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
  2. Taylor expanded around 0 2.0

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

    \[\leadsto \color{blue}{\left(x - \left(2 \cdot x\right) \cdot wj\right) + wj \cdot wj}\]
  4. Using strategy rm
  5. Applied sub-neg2.1

    \[\leadsto \color{blue}{\left(x + \left(-\left(2 \cdot x\right) \cdot wj\right)\right)} + wj \cdot wj\]
  6. Applied associate-+l+2.1

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

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

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

Reproduce

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