Average Error: 13.7 → 1.9
Time: 5.6s
Precision: binary64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
\[\left(2.5 \cdot \left({wj}^{2} \cdot x\right) + \left({wj}^{2} + x\right)\right) - 2 \cdot \left(wj \cdot x\right) \]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\left(2.5 \cdot \left({wj}^{2} \cdot x\right) + \left({wj}^{2} + x\right)\right) - 2 \cdot \left(wj \cdot x\right)
(FPCore (wj x)
 :precision binary64
 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x)
 :precision binary64
 (- (+ (* 2.5 (* (pow wj 2.0) x)) (+ (pow wj 2.0) x)) (* 2.0 (* wj x))))
double code(double wj, double x) {
	return wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))));
}
double code(double wj, double x) {
	return ((2.5 * (pow(wj, 2.0) * x)) + (pow(wj, 2.0) + x)) - (2.0 * (wj * x));
}

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.2
Herbie1.9
\[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.2

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

    \[\leadsto \color{blue}{\left(2.5 \cdot \left({wj}^{2} \cdot x\right) + \left({wj}^{2} + x\right)\right) - 2 \cdot \left(wj \cdot x\right)} \]
  4. Final simplification1.9

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

Reproduce

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