Average Error: 0.1 → 0.1
Time: 12.1s
Precision: binary64
Cost: 19584
\[x \cdot \cos y - z \cdot \sin y \]
\[\mathsf{fma}\left(\sin y, -z, x \cdot \cos y\right) \]
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (* x (cos y))))
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(sin(y), -z, (x * cos(y)));
}
function code(x, y, z)
	return Float64(Float64(x * cos(y)) - Float64(z * sin(y)))
end
function code(x, y, z)
	return fma(sin(y), Float64(-z), Float64(x * cos(y)))
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[Sin[y], $MachinePrecision] * (-z) + N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \cos y - z \cdot \sin y
\mathsf{fma}\left(\sin y, -z, x \cdot \cos y\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(\sin y, -z, x \cdot \cos y\right)} \]
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[x \cdot \cos y - \sin y \cdot z \]
Alternative 2
Error10.1
Cost7512
\[\begin{array}{l} t_0 := x - \sin y \cdot z\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;z \leq -1.0534156578752266 \cdot 10^{+85}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -0.0006250749902912553:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.07117478959281 \cdot 10^{-89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.6296287302526506 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3431943441470405 \cdot 10^{-118}:\\ \;\;\;\;\sin y \cdot \left(-z\right)\\ \mathbf{elif}\;z \leq 6.346609771289541 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error19.3
Cost7448
\[\begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;z \leq -1.0534156578752266 \cdot 10^{+85}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -0.0006250749902912553:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.260393229177624 \cdot 10^{-38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.6296287302526506 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3431943441470405 \cdot 10^{-118}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.346609771289541 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.1
Cost6920
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -4.773562577435384 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.9709589350215084 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.0
Cost6856
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -219.7734271665244:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.9709589350215084 \cdot 10^{-6}:\\ \;\;\;\;x + y \cdot \left(x \cdot \left(y \cdot -0.5\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error37.2
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -3.150219895453394 \cdot 10^{-100}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.40598540089577 \cdot 10^{-104}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error30.4
Cost320
\[x - y \cdot z \]
Alternative 8
Error39.0
Cost64
\[x \]

Error

Reproduce

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