?

Average Error: 0.1 → 0.1
Time: 8.4s
Precision: binary64
Cost: 19520

?

\[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), 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
Cost19520
\[\mathsf{fma}\left(x, \cos y, \sin y \cdot z\right) \]
Alternative 2
Error0.1
Cost13248
\[\sin y \cdot z + x \cdot \cos y \]
Alternative 3
Error16.3
Cost7696
\[\begin{array}{l} t_0 := \sin y \cdot z\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -3.55 \cdot 10^{+177}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -0.074:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.17:\\ \;\;\;\;x + \left(-0.16666666666666666 \cdot \left(z \cdot {y}^{3}\right) + y \cdot z\right)\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.4
Cost7252
\[\begin{array}{l} t_0 := \sin y \cdot z\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -7 \cdot 10^{+189}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6.9 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.17:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.4
Cost7252
\[\begin{array}{l} t_0 := \sin y \cdot z\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -1.05 \cdot 10^{+178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6.9 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.17:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error16.0
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -6.9 \cdot 10^{-6} \lor \neg \left(y \leq 2.5 \cdot 10^{-7}\right):\\ \;\;\;\;\sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 7
Error39.1
Cost324
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+71}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error31.0
Cost320
\[x + y \cdot z \]
Alternative 9
Error39.5
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023060 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3"
  :precision binary64
  (+ (* x (cos y)) (* z (sin y))))