?

Average Error: 0.19% → 0.19%
Time: 10.8s
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.19

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

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

    [Start]0.19

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

    fma-def [=>]0.19

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

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

Alternatives

Alternative 1
Error0.19%
Cost13248
\[z \cdot \sin y + x \cdot \cos y \]
Alternative 2
Error26.88%
Cost7516
\[\begin{array}{l} t_0 := x \cdot \cos y\\ t_1 := z \cdot \sin y\\ t_2 := x + y \cdot z\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{+185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+66}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error27.04%
Cost7516
\[\begin{array}{l} t_0 := x \cdot \cos y\\ t_1 := z \cdot \sin y\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{+183}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{+138}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+65}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error13.83%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-15} \lor \neg \left(z \leq 2.95 \cdot 10^{-92}\right):\\ \;\;\;\;x + z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \cos y\\ \end{array} \]
Alternative 5
Error25.66%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -14 \lor \neg \left(y \leq 0.0195\right):\\ \;\;\;\;z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 6
Error59.49%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-117}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-297}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error48.26%
Cost320
\[x + y \cdot z \]
Alternative 8
Error61.35%
Cost64
\[x \]

Error

Reproduce?

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