Average Error: 0.1 → 0.1
Time: 12.1s
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
Error9.7
Cost13520
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;x \leq -7.422309639359841 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.411838439478305 \cdot 10^{+60}:\\ \;\;\;\;x + \sin y \cdot z\\ \mathbf{elif}\;x \leq -1.2343978564443895 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.1578212054370495 \cdot 10^{+23}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[\sin y \cdot z + x \cdot \cos y \]
Alternative 3
Error16.9
Cost7252
\[\begin{array}{l} t_0 := \sin y \cdot z\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;z \leq -2.5736110648635675 \cdot 10^{+88}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7.850447580832386 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8434.577087517517:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7.609276778893957 \cdot 10^{-56}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;z \leq 1.2095943291590694 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error9.7
Cost7248
\[\begin{array}{l} t_0 := x \cdot \cos y\\ t_1 := x + \sin y \cdot z\\ \mathbf{if}\;x \leq -7.422309639359841 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.411838439478305 \cdot 10^{+60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.2343978564443895 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.1578212054370495 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.6
Cost6856
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -3349594454779.5894:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.00299966792259384:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error37.5
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -5.668647897976149 \cdot 10^{+105}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 1.3868229239506407 \cdot 10^{+116}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 7
Error30.9
Cost320
\[x + y \cdot z \]
Alternative 8
Error38.9
Cost64
\[x \]

Error

Reproduce

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