Average Error: 13.8 → 2.3
Time: 4.1s
Precision: binary64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[x + \left(\sqrt[3]{wj} \cdot \sqrt[3]{wj}\right) \cdot \left(\sqrt[3]{wj} \cdot \left(wj - x \cdot 2\right)\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
x + \left(\sqrt[3]{wj} \cdot \sqrt[3]{wj}\right) \cdot \left(\sqrt[3]{wj} \cdot \left(wj - x \cdot 2\right)\right)
(FPCore (wj x)
 :precision binary64
 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x)
 :precision binary64
 (+ x (* (* (cbrt wj) (cbrt wj)) (* (cbrt wj) (- wj (* x 2.0))))))
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 + ((cbrt(wj) * cbrt(wj)) * (cbrt(wj) * (wj - (x * 2.0))));
}

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.3
\[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.1

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

    \[\leadsto \color{blue}{x + wj \cdot \left(wj - x \cdot 2\right)}\]
  4. Using strategy rm
  5. Applied add-cube-cbrt_binary64_5612.3

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

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

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

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

Reproduce

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