?

Average Accuracy: 99.8% → 99.8%
Time: 13.9s
Precision: binary64
Cost: 32896

?

\[x \cdot \cos y - z \cdot \sin y \]
\[\begin{array}{l} t_0 := z \cdot \sin y\\ \left(\mathsf{fma}\left(-z, \sin y, t_0\right) + x \cdot \cos y\right) - t_0 \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (sin y))))
   (- (+ (fma (- z) (sin y) t_0) (* x (cos y))) t_0)))
double code(double x, double y, double z) {
	return (x * cos(y)) - (z * sin(y));
}
double code(double x, double y, double z) {
	double t_0 = z * sin(y);
	return (fma(-z, sin(y), t_0) + (x * cos(y))) - t_0;
}
function code(x, y, z)
	return Float64(Float64(x * cos(y)) - Float64(z * sin(y)))
end
function code(x, y, z)
	t_0 = Float64(z * sin(y))
	return Float64(Float64(fma(Float64(-z), sin(y), t_0) + Float64(x * cos(y))) - t_0)
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_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[((-z) * N[Sin[y], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]
x \cdot \cos y - z \cdot \sin y
\begin{array}{l}
t_0 := z \cdot \sin y\\
\left(\mathsf{fma}\left(-z, \sin y, t_0\right) + x \cdot \cos y\right) - t_0
\end{array}

Error?

Derivation?

  1. Initial program 99.8%

    \[x \cdot \cos y - z \cdot \sin y \]
  2. Applied egg-rr99.8%

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

    [Start]99.8

    \[ x \cdot \cos y - z \cdot \sin y \]

    *-commutative [=>]99.8

    \[ x \cdot \cos y - \color{blue}{\sin y \cdot z} \]

    prod-diff [=>]99.8

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

    fma-def [<=]99.8

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

    +-commutative [=>]99.8

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

    associate-+l+ [=>]99.8

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

    distribute-rgt-neg-in [=>]99.8

    \[ \color{blue}{z \cdot \left(-\sin y\right)} + \left(x \cdot \cos y + \mathsf{fma}\left(-z, \sin y, z \cdot \sin y\right)\right) \]
  3. Final simplification99.8%

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

Alternatives

Alternative 1
Accuracy99.8%
Cost13248
\[x \cdot \cos y - z \cdot \sin y \]
Alternative 2
Accuracy74.7%
Cost7184
\[\begin{array}{l} t_0 := z \cdot \left(-\sin y\right)\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -4.4 \cdot 10^{+104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -0.0006:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 660:\\ \;\;\;\;x - z \cdot y\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+148}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy74.5%
Cost7184
\[\begin{array}{l} t_0 := z \cdot \left(-\sin y\right)\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 660:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy85.8%
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+64} \lor \neg \left(x \leq 3 \cdot 10^{+113}\right):\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \sin y\\ \end{array} \]
Alternative 5
Accuracy74.6%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -0.036 \lor \neg \left(y \leq 660\right):\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot y\\ \end{array} \]
Alternative 6
Accuracy41.6%
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-165}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-151}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy51.6%
Cost320
\[x - z \cdot y \]
Alternative 8
Accuracy39.1%
Cost64
\[x \]

Error

Reproduce?

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