Average Error: 0.1 → 0.1
Time: 7.6s
Precision: binary64
Cost: 19520
\[x \cdot \sin y + z \cdot \cos y \]
\[\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right) \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma x (sin y) (* z (cos y))))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
double code(double x, double y, double z) {
	return fma(x, sin(y), (z * cos(y)));
}
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function code(x, y, z)
	return fma(x, sin(y), Float64(z * cos(y)))
end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \sin y + z \cdot \cos y
\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)

Error

Derivation

  1. Initial program 0.1

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
    Proof
    (fma.f64 x (sin.f64 y) (*.f64 z (cos.f64 y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y)))): 2 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[z \cdot \cos y + x \cdot \sin y \]
Alternative 2
Error16.3
Cost7516
\[\begin{array}{l} t_0 := z \cdot \cos y\\ t_1 := x \cdot \sin y\\ \mathbf{if}\;y \leq -2.8 \cdot 10^{+201}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{+118}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -8.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 0.042:\\ \;\;\;\;\left(z + x \cdot y\right) + -0.5 \cdot \left(y \cdot \left(y \cdot z\right)\right)\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+262}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+292}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.8
Cost7504
\[\begin{array}{l} t_0 := z \cdot \cos y\\ t_1 := z + x \cdot \left(\left(\sin y + 1\right) + -1\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-202}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-39}:\\ \;\;\;\;x \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.4
Cost6856
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;y \leq -0.009:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.026:\\ \;\;\;\;\left(z + x \cdot y\right) + -0.5 \cdot \left(y \cdot \left(y \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error37.5
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{-200}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-69}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 6
Error30.8
Cost320
\[z + x \cdot y \]
Alternative 7
Error39.0
Cost64
\[z \]

Error

Reproduce

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