Average Error: 0.1 → 0.1
Time: 5.9s
Precision: binary64
\[x \cdot \sin y + z \cdot \cos y \]
\[\mathsf{fma}\left(x, \sin y, \cos y \cdot z\right) \]
x \cdot \sin y + z \cdot \cos y
\mathsf{fma}\left(x, \sin y, \cos y \cdot z\right)
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma x (sin y) (* (cos y) z)))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
double code(double x, double y, double z) {
	return fma(x, sin(y), (cos(y) * z));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.1

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
  3. Applied add-cube-cbrt_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, z \cdot \color{blue}{\left(\left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right) \cdot \sqrt[3]{\cos y}\right)}\right) \]
  4. Applied associate-*r*_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \color{blue}{\left(z \cdot \left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right)\right) \cdot \sqrt[3]{\cos y}}\right) \]
  5. Applied pow1_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \left(z \cdot \left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right)\right) \cdot \color{blue}{{\left(\sqrt[3]{\cos y}\right)}^{1}}\right) \]
  6. Applied pow1_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \left(z \cdot \left(\sqrt[3]{\cos y} \cdot \color{blue}{{\left(\sqrt[3]{\cos y}\right)}^{1}}\right)\right) \cdot {\left(\sqrt[3]{\cos y}\right)}^{1}\right) \]
  7. Applied pow1_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \left(z \cdot \left(\color{blue}{{\left(\sqrt[3]{\cos y}\right)}^{1}} \cdot {\left(\sqrt[3]{\cos y}\right)}^{1}\right)\right) \cdot {\left(\sqrt[3]{\cos y}\right)}^{1}\right) \]
  8. Applied pow-prod-down_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \left(z \cdot \color{blue}{{\left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right)}^{1}}\right) \cdot {\left(\sqrt[3]{\cos y}\right)}^{1}\right) \]
  9. Applied pow1_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \left(\color{blue}{{z}^{1}} \cdot {\left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right)}^{1}\right) \cdot {\left(\sqrt[3]{\cos y}\right)}^{1}\right) \]
  10. Applied pow-prod-down_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \color{blue}{{\left(z \cdot \left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right)\right)}^{1}} \cdot {\left(\sqrt[3]{\cos y}\right)}^{1}\right) \]
  11. Applied pow-prod-down_binary640.4

    \[\leadsto \mathsf{fma}\left(x, \sin y, \color{blue}{{\left(\left(z \cdot \left(\sqrt[3]{\cos y} \cdot \sqrt[3]{\cos y}\right)\right) \cdot \sqrt[3]{\cos y}\right)}^{1}}\right) \]
  12. Simplified0.1

    \[\leadsto \mathsf{fma}\left(x, \sin y, {\color{blue}{\left(\cos y \cdot z\right)}}^{1}\right) \]
  13. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(x, \sin y, \cos y \cdot z\right) \]

Reproduce

herbie shell --seed 2021329 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
  :precision binary64
  (+ (* x (sin y)) (* z (cos y))))