Average Error: 14.0 → 2.0
Time: 24.1s
Precision: 64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\left(wj \cdot wj + x\right) - 2 \cdot \left(wj \cdot x\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\left(wj \cdot wj + x\right) - 2 \cdot \left(wj \cdot x\right)
double f(double wj, double x) {
        double r3016388 = wj;
        double r3016389 = exp(r3016388);
        double r3016390 = r3016388 * r3016389;
        double r3016391 = x;
        double r3016392 = r3016390 - r3016391;
        double r3016393 = r3016389 + r3016390;
        double r3016394 = r3016392 / r3016393;
        double r3016395 = r3016388 - r3016394;
        return r3016395;
}

double f(double wj, double x) {
        double r3016396 = wj;
        double r3016397 = r3016396 * r3016396;
        double r3016398 = x;
        double r3016399 = r3016397 + r3016398;
        double r3016400 = 2.0;
        double r3016401 = r3016396 * r3016398;
        double r3016402 = r3016400 * r3016401;
        double r3016403 = r3016399 - r3016402;
        return r3016403;
}

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

Derivation

  1. Initial program 14.0

    \[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.0

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

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

Reproduce

herbie shell --seed 2019128 +o rules:numerics
(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))))))