?

Average Accuracy: 99.8% → 99.8%
Time: 12.5s
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 99.8%

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

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

    [Start]99.8

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

    sub-neg [=>]99.8

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

    +-commutative [=>]99.8

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

    *-commutative [=>]99.8

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

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

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

    fma-def [=>]99.8

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

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

Alternatives

Alternative 1
Accuracy99.8%
Cost13248
\[x \cdot \cos y - \sin y \cdot z \]
Alternative 2
Accuracy74.9%
Cost7316
\[\begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.95 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.75:\\ \;\;\;\;x - y \cdot z\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy74.9%
Cost7316
\[\begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -5.8 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.95 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.75:\\ \;\;\;\;\mathsf{fma}\left(-y, z, x\right)\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy86.1%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-75} \lor \neg \left(z \leq 1.95 \cdot 10^{-53}\right):\\ \;\;\;\;x - \sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \cos y\\ \end{array} \]
Alternative 5
Accuracy74.8%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -2100000 \lor \neg \left(y \leq 1.75\right):\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot z\\ \end{array} \]
Alternative 6
Accuracy41.6%
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -2.95 \cdot 10^{-139}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-108}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy52.3%
Cost320
\[x - y \cdot z \]
Alternative 8
Accuracy39.1%
Cost64
\[x \]

Error

Reproduce?

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