Average Error: 0.1 → 0.1
Time: 7.4s
Precision: binary64
Cost: 19520
\[x \cdot \cos y + z \cdot \sin y \]
\[\mathsf{fma}\left(x, \cos y, z \cdot \sin y\right) \]
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (fma x (cos y) (* z (sin 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(x, cos(y), (z * sin(y)));
}
function code(x, y, z)
	return Float64(Float64(x * cos(y)) + Float64(z * sin(y)))
end
function code(x, y, z)
	return fma(x, cos(y), Float64(z * sin(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[(x * N[Cos[y], $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \cos y + z \cdot \sin y
\mathsf{fma}\left(x, \cos y, z \cdot \sin y\right)

Error

Derivation

  1. Initial program 0.1

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

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

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[z \cdot \sin y + x \cdot \cos y \]
Alternative 2
Error16.4
Cost7516
\[\begin{array}{l} t_0 := z \cdot \sin y\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{+201}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.8 \cdot 10^{+118}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -8.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.62 \cdot 10^{-6}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+263}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+294}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.5
Cost6856
\[\begin{array}{l} t_0 := z \cdot \sin y\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-6}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error37.6
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+223}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+107}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 5
Error30.7
Cost320
\[x + y \cdot z \]
Alternative 6
Error39.1
Cost64
\[x \]

Error

Reproduce

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