Average Error: 0.1 → 0.1
Time: 6.1s
Precision: binary64
\[x \cdot \cos y - z \cdot \sin y \]
\[\mathsf{fma}\left(x, \cos y, -\sin y \cdot z\right) \]
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (fma x (cos y) (- (* (sin y) z))))
double code(double x, double y, double z) {
	return (x * cos(y)) - (z * sin(y));
}
double code(double x, double y, double z) {
	return fma(x, cos(y), -(sin(y) * z));
}
function code(x, y, z)
	return Float64(Float64(x * cos(y)) - Float64(z * sin(y)))
end
function code(x, y, z)
	return fma(x, cos(y), Float64(-Float64(sin(y) * z)))
end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * N[Cos[y], $MachinePrecision] + (-N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision])), $MachinePrecision]
x \cdot \cos y - z \cdot \sin y
\mathsf{fma}\left(x, \cos y, -\sin y \cdot z\right)

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.1

    \[x \cdot \cos y - z \cdot \sin y \]
  2. Applied fma-neg_binary640.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \cos y, -z \cdot \sin y\right)} \]
  3. Applied log1p-expm1-u_binary640.2

    \[\leadsto \mathsf{fma}\left(x, \cos y, -z \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin y\right)\right)}\right) \]
  4. Applied *-un-lft-identity_binary640.2

    \[\leadsto \mathsf{fma}\left(x, \cos y, -\color{blue}{\left(1 \cdot z\right)} \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin y\right)\right)\right) \]
  5. Applied associate-*l*_binary640.2

    \[\leadsto \mathsf{fma}\left(x, \cos y, -\color{blue}{1 \cdot \left(z \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin y\right)\right)\right)}\right) \]
  6. Simplified0.1

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

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

Reproduce

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