Average Error: 13.7 → 1.6
Time: 5.8s
Precision: binary64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[x + \left(\left(x \cdot 2.5 + 1\right) \cdot \left(wj \cdot wj\right) - \left({wj}^{3} + x \cdot \left(\left(wj + wj\right) + {wj}^{3} \cdot 2.6666666666666665\right)\right)\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
x + \left(\left(x \cdot 2.5 + 1\right) \cdot \left(wj \cdot wj\right) - \left({wj}^{3} + x \cdot \left(\left(wj + wj\right) + {wj}^{3} \cdot 2.6666666666666665\right)\right)\right)
(FPCore (wj x)
 :precision binary64
 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x)
 :precision binary64
 (+
  x
  (-
   (* (+ (* x 2.5) 1.0) (* wj wj))
   (+ (pow wj 3.0) (* x (+ (+ wj wj) (* (pow wj 3.0) 2.6666666666666665)))))))
double code(double wj, double x) {
	return wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))));
}
double code(double wj, double x) {
	return x + ((((x * 2.5) + 1.0) * (wj * wj)) - (pow(wj, 3.0) + (x * ((wj + wj) + (pow(wj, 3.0) * 2.6666666666666665)))));
}

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

Derivation

  1. Initial program 13.7

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

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

    \[\leadsto \color{blue}{\left({wj}^{2} + \left(x + 2.5 \cdot \left({wj}^{2} \cdot x\right)\right)\right) - \left({wj}^{3} + \left(2.6666666666666665 \cdot \left({wj}^{3} \cdot x\right) + 2 \cdot \left(wj \cdot x\right)\right)\right)}\]
  4. Simplified1.6

    \[\leadsto \color{blue}{x + \left(\left(2.5 \cdot x + 1\right) \cdot \left(wj \cdot wj\right) - \left({wj}^{3} + x \cdot \left(\left(wj + wj\right) + {wj}^{3} \cdot 2.6666666666666665\right)\right)\right)}\]
  5. Final simplification1.6

    \[\leadsto x + \left(\left(x \cdot 2.5 + 1\right) \cdot \left(wj \cdot wj\right) - \left({wj}^{3} + x \cdot \left(\left(wj + wj\right) + {wj}^{3} \cdot 2.6666666666666665\right)\right)\right)\]

Reproduce

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

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

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