Average Error: 0.0 → 0.0
Time: 10.2s
Precision: binary64
Cost: 19520
\[\left(x + \sin y\right) + z \cdot \cos y \]
\[\mathsf{fma}\left(z, \cos y, x + \sin y\right) \]
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma z (cos y) (+ x (sin 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(z, cos(y), (x + sin(y)));
}
function code(x, y, z)
	return Float64(Float64(x + sin(y)) + Float64(z * cos(y)))
end
function code(x, y, z)
	return fma(z, cos(y), Float64(x + sin(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[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + \sin y\right) + z \cdot \cos y
\mathsf{fma}\left(z, \cos y, x + \sin y\right)

Error

Derivation

  1. Initial program 0.0

    \[\left(x + \sin y\right) + z \cdot \cos y \]
  2. Simplified0.0

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

    [Start]0.0

    \[ \left(x + \sin y\right) + z \cdot \cos y \]

    +-commutative [=>]0.0

    \[ \color{blue}{z \cdot \cos y + \left(x + \sin y\right)} \]

    fma-def [=>]0.0

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

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

Alternatives

Alternative 1
Error10.9
Cost13648
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.05 \cdot 10^{+53}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-42}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+50}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+186}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;\sin y + t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 3
Error19.6
Cost7384
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+54}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-248}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-291}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-117}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-62}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{+185}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error19.2
Cost7124
\[\begin{array}{l} \mathbf{if}\;y \leq -4.1 \cdot 10^{+223}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{+186}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{+53}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 3800000000000:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{+51}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 5
Error10.9
Cost7120
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -7 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-42}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+50}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+185}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error18.7
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{+54} \lor \neg \left(y \leq 1.92 \cdot 10^{-16}\right):\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;z + \left(y + x\right)\\ \end{array} \]
Alternative 7
Error20.1
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-166}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-214}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Error28.9
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.32 \cdot 10^{-67}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+21}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error21.1
Cost192
\[z + x \]
Alternative 10
Error36.6
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z)
  :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
  :precision binary64
  (+ (+ x (sin y)) (* z (cos y))))