Average Error: 0.1 → 0.1
Time: 10.4s
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.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, \cos y, x + \sin y\right)} \]
    Proof
    (fma.f64 z (cos.f64 y) (+.f64 x (sin.f64 y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (cos.f64 y)) (+.f64 x (sin.f64 y)))): 1 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y)))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error2.6
Cost13256
\[\begin{array}{l} \mathbf{if}\;z \leq -8.974192156555443 \cdot 10^{-13}:\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{elif}\;z \leq 4.013109801345175 \cdot 10^{-39}:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, \cos y, x\right)\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[\left(x + \sin y\right) + z \cdot \cos y \]
Alternative 3
Error19.8
Cost7124
\[\begin{array}{l} \mathbf{if}\;y \leq -6.237953476278223 \cdot 10^{+20}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 2.1029162195330391 \cdot 10^{+68}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{elif}\;y \leq 9.2124891195855 \cdot 10^{+94}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq 1.216054285511013 \cdot 10^{+146}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 5.9822126053297135 \cdot 10^{+159}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 4
Error10.5
Cost6988
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -6.592531959858113 \cdot 10^{+216}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.974192156555443 \cdot 10^{-13}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 425576.63372784475:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error2.6
Cost6984
\[\begin{array}{l} t_0 := x + z \cdot \cos y\\ \mathbf{if}\;z \leq -8.974192156555443 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.013109801345175 \cdot 10^{-39}:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error18.2
Cost6856
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -6.592531959858113 \cdot 10^{+216}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.3442933524802597 \cdot 10^{+126}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error19.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.237953476278223 \cdot 10^{+20}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 7.318806627289397 \cdot 10^{+60}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Error35.0
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.456574292024145 \cdot 10^{+97}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.318806627289397 \cdot 10^{+60}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error28.1
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7468294366694206 \cdot 10^{-111}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.553844872857042 \cdot 10^{+22}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error22.1
Cost192
\[z + x \]
Alternative 11
Error37.4
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022316 
(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))))