Average Error: 0.1 → 0.1
Time: 8.5s
Precision: binary64
Cost: 19584
\[x \cdot \cos y - z \cdot \sin y \]
\[\mathsf{fma}\left(\cos y, x, \sin y \cdot \left(-z\right)\right) \]
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (fma (cos y) x (* (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(cos(y), x, (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(cos(y), x, Float64(sin(y) * Float64(-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[(N[Cos[y], $MachinePrecision] * x + N[(N[Sin[y], $MachinePrecision] * (-z)), $MachinePrecision]), $MachinePrecision]
x \cdot \cos y - z \cdot \sin y
\mathsf{fma}\left(\cos y, x, \sin y \cdot \left(-z\right)\right)

Error

Derivation

  1. Initial program 0.1

    \[x \cdot \cos y - z \cdot \sin y \]
  2. Applied egg-rr0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[\cos y \cdot x - \sin y \cdot z \]
Alternative 2
Error8.8
Cost6984
\[\begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;x \leq -0.0135:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.00082:\\ \;\;\;\;x - \sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.1
Cost6920
\[\begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;x \leq -8 \cdot 10^{-54}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-23}:\\ \;\;\;\;\sin y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.4
Cost6856
\[\begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;y \leq -0.00033:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3100000000000:\\ \;\;\;\;x + y \cdot \left(y \cdot \left(x \cdot -0.5\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error37.5
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -1.26 \cdot 10^{-191}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-125}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error31.1
Cost320
\[x - y \cdot z \]
Alternative 7
Error39.0
Cost64
\[x \]

Error

Reproduce

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