?

Average Accuracy: 99.8% → 99.8%
Time: 14.8s
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%
Cost19584
\[\mathsf{fma}\left(\cos y, x, z \cdot \left(-\sin y\right)\right) \]
Alternative 2
Accuracy99.8%
Cost13248
\[x \cdot \cos y - z \cdot \sin y \]
Alternative 3
Accuracy75.0%
Cost7317
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -0.0013:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.032:\\ \;\;\;\;x - z \cdot y\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+53} \lor \neg \left(y \leq 5.4 \cdot 10^{+107}\right) \land y \leq 7.2 \cdot 10^{+254}:\\ \;\;\;\;z \cdot \left(-\sin y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy75.0%
Cost7317
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -0.00047:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.06:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+53} \lor \neg \left(y \leq 2.95 \cdot 10^{+107}\right) \land y \leq 8.8 \cdot 10^{+254}:\\ \;\;\;\;z \cdot \left(-\sin y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy85.1%
Cost7250
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+84} \lor \neg \left(z \leq -1.1 \cdot 10^{+44}\right) \land \left(z \leq -7.5 \cdot 10^{-57} \lor \neg \left(z \leq 4.8 \cdot 10^{-67}\right)\right):\\ \;\;\;\;x - z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \cos y\\ \end{array} \]
Alternative 6
Accuracy74.5%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -0.00039 \lor \neg \left(y \leq 0.00042\right):\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot y\\ \end{array} \]
Alternative 7
Accuracy42.1%
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{-228}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-220}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy52.2%
Cost320
\[x - z \cdot y \]
Alternative 9
Accuracy39.8%
Cost64
\[x \]

Error

Reproduce?

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