Average Error: 0.1 → 0.1
Time: 29.8s
Precision: binary64
Cost: 19520
\[x \cdot \sin y + z \cdot \cos y \]
\[\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right) \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma x (sin y) (* z (cos y))))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
double code(double x, double y, double z) {
	return fma(x, sin(y), (z * cos(y)));
}
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function code(x, y, z)
	return fma(x, sin(y), Float64(z * cos(y)))
end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \sin y + z \cdot \cos y
\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)

Error

Derivation

  1. Initial program 0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[x \cdot \sin y + z \cdot \cos y \]
Alternative 2
Error16.4
Cost7648
\[\begin{array}{l} t_0 := \sin y \cdot x\\ t_1 := \cos y \cdot z\\ \mathbf{if}\;y \leq -1.35 \cdot 10^{+260}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{+105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -0.066:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-6}:\\ \;\;\;\;y \cdot x + z\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+279}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+304}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.4
Cost7648
\[\begin{array}{l} t_0 := \sin y \cdot x\\ t_1 := \cos y \cdot z\\ \mathbf{if}\;y \leq -1 \cdot 10^{+263}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{+105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -0.07:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(y, x, z\right)\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+276}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+303}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error9.6
Cost7240
\[\begin{array}{l} t_0 := \cos y \cdot z\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{+123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.7 \cdot 10^{+156}:\\ \;\;\;\;\frac{\sin y}{0.3333333333333333} \cdot \frac{x}{3} + z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.6
Cost7240
\[\begin{array}{l} t_0 := \cos y \cdot z\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+131}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+158}:\\ \;\;\;\;\frac{0.3333333333333333 \cdot \left(\sin y \cdot x\right)}{0.3333333333333333} + z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error16.8
Cost6856
\[\begin{array}{l} t_0 := \cos y \cdot z\\ \mathbf{if}\;y \leq -2.6 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+16}:\\ \;\;\;\;y \cdot x + z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error37.7
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+114}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+139}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Error31.1
Cost320
\[y \cdot x + z \]
Alternative 9
Error39.6
Cost64
\[z \]

Error

Reproduce

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