Average Error: 13.6 → 1.8
Time: 10.6s
Precision: binary64
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[x + \left(\left(\sqrt{\left(wj \cdot wj\right) \cdot \left(\sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)} \cdot \sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)}\right)} \cdot \sqrt{\left(wj \cdot wj\right) \cdot \left(\sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)} \cdot \sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)}\right)}\right) \cdot \sqrt[3]{\left(x \cdot 2.5 + 1\right) - wj} - x \cdot \left(2.6666666666666665 \cdot {wj}^{3} + \left(wj + wj\right)\right)\right)\]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
x + \left(\left(\sqrt{\left(wj \cdot wj\right) \cdot \left(\sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)} \cdot \sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)}\right)} \cdot \sqrt{\left(wj \cdot wj\right) \cdot \left(\sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)} \cdot \sqrt[3]{x \cdot 2.5 + \left(1 - wj\right)}\right)}\right) \cdot \sqrt[3]{\left(x \cdot 2.5 + 1\right) - wj} - x \cdot \left(2.6666666666666665 \cdot {wj}^{3} + \left(wj + wj\right)\right)\right)
(FPCore (wj x)
 :precision binary64
 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x)
 :precision binary64
 (+
  x
  (-
   (*
    (*
     (sqrt
      (*
       (* wj wj)
       (* (cbrt (+ (* x 2.5) (- 1.0 wj))) (cbrt (+ (* x 2.5) (- 1.0 wj))))))
     (sqrt
      (*
       (* wj wj)
       (* (cbrt (+ (* x 2.5) (- 1.0 wj))) (cbrt (+ (* x 2.5) (- 1.0 wj)))))))
    (cbrt (- (+ (* x 2.5) 1.0) wj)))
   (* x (+ (* 2.6666666666666665 (pow wj 3.0)) (+ wj wj))))))
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 + (((sqrt((wj * wj) * (cbrt((x * 2.5) + (1.0 - wj)) * cbrt((x * 2.5) + (1.0 - wj)))) * sqrt((wj * wj) * (cbrt((x * 2.5) + (1.0 - wj)) * cbrt((x * 2.5) + (1.0 - wj))))) * cbrt(((x * 2.5) + 1.0) - wj)) - (x * ((2.6666666666666665 * pow(wj, 3.0)) + (wj + wj))));
}

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

Derivation

  1. Initial program 13.6

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

    \[\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)}\]
  3. Simplified1.8

    \[\leadsto \color{blue}{\left(wj \cdot wj\right) \cdot \left(2.5 \cdot x + 1\right) + \left(x - \left({wj}^{3} + x \cdot \left(\left(wj + wj\right) + {wj}^{3} \cdot 2.6666666666666665\right)\right)\right)}\]
  4. Taylor expanded around 0 1.8

    \[\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)}\]
  5. Simplified1.8

    \[\leadsto \color{blue}{x + \left(\left(wj \cdot wj\right) \cdot \left(\left(2.5 \cdot x + 1\right) - wj\right) - x \cdot \left(2.6666666666666665 \cdot {wj}^{3} + \left(wj + wj\right)\right)\right)}\]
  6. Using strategy rm
  7. Applied add-cube-cbrt_binary64_31821.8

    \[\leadsto x + \left(\left(wj \cdot wj\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\left(2.5 \cdot x + 1\right) - wj} \cdot \sqrt[3]{\left(2.5 \cdot x + 1\right) - wj}\right) \cdot \sqrt[3]{\left(2.5 \cdot x + 1\right) - wj}\right)} - x \cdot \left(2.6666666666666665 \cdot {wj}^{3} + \left(wj + wj\right)\right)\right)\]
  8. Applied associate-*r*_binary64_30871.8

    \[\leadsto x + \left(\color{blue}{\left(\left(wj \cdot wj\right) \cdot \left(\sqrt[3]{\left(2.5 \cdot x + 1\right) - wj} \cdot \sqrt[3]{\left(2.5 \cdot x + 1\right) - wj}\right)\right) \cdot \sqrt[3]{\left(2.5 \cdot x + 1\right) - wj}} - x \cdot \left(2.6666666666666665 \cdot {wj}^{3} + \left(wj + wj\right)\right)\right)\]
  9. Simplified1.8

    \[\leadsto x + \left(\color{blue}{\left(\left(wj \cdot wj\right) \cdot \left(\sqrt[3]{2.5 \cdot x + \left(1 - wj\right)} \cdot \sqrt[3]{2.5 \cdot x + \left(1 - wj\right)}\right)\right)} \cdot \sqrt[3]{\left(2.5 \cdot x + 1\right) - wj} - x \cdot \left(2.6666666666666665 \cdot {wj}^{3} + \left(wj + wj\right)\right)\right)\]
  10. Using strategy rm
  11. Applied add-sqr-sqrt_binary64_31691.8

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

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

Reproduce

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