Average Error: 0.1 → 0.1
Time: 12.3s
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.5
Cost7384
\[\begin{array}{l} t_0 := z \cdot \sin y\\ t_1 := x \cdot \cos y\\ \mathbf{if}\;y \leq -5.773901193465493 \cdot 10^{+50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -162671694012.22647:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.016975672981508 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.564967545708885 \cdot 10^{-5}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 4.2274113302286874 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8514155374616943 \cdot 10^{+266}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error16.3
Cost7372
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;x \leq -404717.8097016547:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.704211662859401 \cdot 10^{-157}:\\ \;\;\;\;z \cdot \sin y\\ \mathbf{elif}\;x \leq 1.6319780425701814 \cdot 10^{+69}:\\ \;\;\;\;x + z \cdot \left(\left(\sin y + 1\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.3
Cost6856
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -162671694012.22647:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.564967545708885 \cdot 10^{-5}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error38.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2785685710583106 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.0068756707268119 \cdot 10^{-280}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error31.1
Cost320
\[x + y \cdot z \]
Alternative 7
Error39.2
Cost64
\[x \]

Error

Reproduce

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