Average Error: 0.1 → 0.1
Time: 26.5s
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

Alternatives

Alternative 1
Error10.3
Cost13388
\[\begin{array}{l} t_0 := x + z \cdot \sin y\\ t_1 := \cos y \cdot x\\ \mathbf{if}\;z \leq -7.4 \cdot 10^{-38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.02 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.85 \cdot 10^{-124}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, z, x\right)\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-198}:\\ \;\;\;\;\frac{\frac{x \cdot \cos y}{0.3333333333333333}}{3} + y \cdot z\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[x \cdot \cos y + z \cdot \sin y \]
Alternative 3
Error16.4
Cost7648
\[\begin{array}{l} t_0 := \cos y \cdot x\\ t_1 := \sin y \cdot z\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{+211}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{+105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -0.066:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-6}:\\ \;\;\;\;y \cdot z + \left(-0.16666666666666666 \cdot \left(\left(\left(y \cdot y\right) \cdot z\right) \cdot y\right) + x\right)\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+279}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.08 \cdot 10^{+304}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error10.3
Cost7632
\[\begin{array}{l} t_0 := x + z \cdot \sin y\\ t_1 := \cos y \cdot x\\ \mathbf{if}\;z \leq -1.2 \cdot 10^{-37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.86 \cdot 10^{-124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-198}:\\ \;\;\;\;\frac{\frac{x \cdot \cos y}{0.3333333333333333}}{3} + y \cdot z\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.9
Cost6984
\[\begin{array}{l} t_0 := x + z \cdot \sin y\\ \mathbf{if}\;z \leq -3.1 \cdot 10^{-38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+46}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error16.2
Cost6856
\[\begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;y \leq -0.155:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{-6}:\\ \;\;\;\;y \cdot z + \left(-0.16666666666666666 \cdot \left(\left(\left(y \cdot y\right) \cdot z\right) \cdot y\right) + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error38.0
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+104}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.26 \cdot 10^{+164}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 8
Error31.1
Cost320
\[y \cdot z + x \]
Alternative 9
Error39.4
Cost64
\[x \]

Error

Reproduce

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