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

Error

Bits error versus wj

Bits error versus x

Target

Original13.6
Target13.0
Herbie1.6
\[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. Simplified13.0

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(2.5, x \cdot \left(wj \cdot wj\right), \mathsf{fma}\left(wj, wj, x\right)\right) - \mathsf{fma}\left(x, \mathsf{fma}\left(2, wj, 2.6666666666666665 \cdot {wj}^{3}\right), {wj}^{3}\right)} \]
  5. Applied add-cube-cbrt_binary642.9

    \[\leadsto \color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(2.5, x \cdot \left(wj \cdot wj\right), \mathsf{fma}\left(wj, wj, x\right)\right) - \mathsf{fma}\left(x, \mathsf{fma}\left(2, wj, 2.6666666666666665 \cdot {wj}^{3}\right), {wj}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(2.5, x \cdot \left(wj \cdot wj\right), \mathsf{fma}\left(wj, wj, x\right)\right) - \mathsf{fma}\left(x, \mathsf{fma}\left(2, wj, 2.6666666666666665 \cdot {wj}^{3}\right), {wj}^{3}\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(2.5, x \cdot \left(wj \cdot wj\right), \mathsf{fma}\left(wj, wj, x\right)\right) - \mathsf{fma}\left(x, \mathsf{fma}\left(2, wj, 2.6666666666666665 \cdot {wj}^{3}\right), {wj}^{3}\right)}} \]
  6. Simplified3.0

    \[\leadsto \color{blue}{\left(\sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)} \cdot \sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(2.5, x \cdot \left(wj \cdot wj\right), \mathsf{fma}\left(wj, wj, x\right)\right) - \mathsf{fma}\left(x, \mathsf{fma}\left(2, wj, 2.6666666666666665 \cdot {wj}^{3}\right), {wj}^{3}\right)} \]
  7. Simplified3.0

    \[\leadsto \left(\sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)} \cdot \sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}\right) \cdot \color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}} \]
  8. Applied pow3_binary643.0

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}\right)}^{3}} \]
  9. Applied *-un-lft-identity_binary643.0

    \[\leadsto {\left(\sqrt[3]{\color{blue}{1 \cdot \left(\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)\right)}}\right)}^{3} \]
  10. Applied cbrt-prod_binary643.0

    \[\leadsto {\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}\right)}}^{3} \]
  11. Applied unpow-prod-down_binary643.0

    \[\leadsto \color{blue}{{\left(\sqrt[3]{1}\right)}^{3} \cdot {\left(\sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}\right)}^{3}} \]
  12. Simplified3.0

    \[\leadsto \color{blue}{1} \cdot {\left(\sqrt[3]{\left(\mathsf{fma}\left(wj, wj, x\right) + \left(wj \cdot x\right) \cdot \mathsf{fma}\left(wj, 2.5, -2\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)}\right)}^{3} \]
  13. Simplified1.6

    \[\leadsto 1 \cdot \color{blue}{\left(\mathsf{fma}\left(x \cdot wj, \mathsf{fma}\left(wj, 2.5, -2\right), \mathsf{fma}\left(wj, wj, x\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right)\right)} \]
  14. Final simplification1.6

    \[\leadsto \mathsf{fma}\left(x \cdot wj, \mathsf{fma}\left(wj, 2.5, -2\right), \mathsf{fma}\left(wj, wj, x\right)\right) - {wj}^{3} \cdot \mathsf{fma}\left(x, 2.6666666666666665, 1\right) \]

Reproduce

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