?

Average Error: 0.21% → 0.21%
Time: 6.9s
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.21

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

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

    [Start]0.21

    \[ x \cdot \cos y + z \cdot \sin y \]

    fma-def [=>]0.21

    \[ \color{blue}{\mathsf{fma}\left(x, \cos y, z \cdot \sin y\right)} \]
  3. Final simplification0.21

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

Alternatives

Alternative 1
Error0.21%
Cost13248
\[z \cdot \sin y + x \cdot \cos y \]
Alternative 2
Error25.65%
Cost6988
\[\begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -0.00156:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 96:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+184}:\\ \;\;\;\;z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error14.69%
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+108} \lor \neg \left(x \leq 2.3 \cdot 10^{-35}\right):\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \sin y\\ \end{array} \]
Alternative 4
Error25.11%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -0.005 \lor \neg \left(y \leq 96\right):\\ \;\;\;\;z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 5
Error58.74%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{-165}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-164}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error48.02%
Cost320
\[x + y \cdot z \]
Alternative 7
Error61.63%
Cost64
\[x \]

Error

Reproduce?

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