Average Error: 0.1 → 0.0
Time: 12.1s
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.0

    \[\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.0

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

Alternatives

Alternative 1
Error7.1
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -97795366.83123074:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 8.755777455688613 \cdot 10^{-13}:\\ \;\;\;\;\sin y + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 3
Error11.0
Cost7384
\[\begin{array}{l} t_0 := x + \sin y\\ t_1 := z \cdot \cos y\\ \mathbf{if}\;z \leq -5.798011671593216 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.661615810050664 \cdot 10^{-36}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 3.5146490695017535 \cdot 10^{-151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.793705266753835 \cdot 10^{-67}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{elif}\;z \leq 5.754616414316947 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.907462836815851 \cdot 10^{+182}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error11.6
Cost7376
\[\begin{array}{l} t_0 := x + \sin y\\ t_1 := x + \left(y + z \cdot \cos y\right)\\ \mathbf{if}\;z \leq -2.1097587687146453 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.5146490695017535 \cdot 10^{-151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.793705266753835 \cdot 10^{-67}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{elif}\;z \leq 259204554409507400:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error13.1
Cost6856
\[\begin{array}{l} t_0 := x + \sin y\\ \mathbf{if}\;y \leq -1213188.7799515845:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.388100587500896 \cdot 10^{-30}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error19.6
Cost6596
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1777957987261718 \cdot 10^{+260}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq -1213188.7799515845:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 3707.5009248211663:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 7
Error29.8
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -1159624358053.3381:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3301190699310927 \cdot 10^{-127}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 6.734925636651939 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7816210.003262672:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error27.5
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9920373195445725 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3301190699310927 \cdot 10^{-127}:\\ \;\;\;\;z + y\\ \mathbf{elif}\;x \leq 7.769879261260951 \cdot 10^{-58}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 7816210.003262672:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error19.2
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1213188.7799515845:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 3707.5009248211663:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 10
Error26.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9920373195445725 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7816210.003262672:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error20.7
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -5.697579503660023 \cdot 10^{-180}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 8.182841214278481 \cdot 10^{-172}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 12
Error37.4
Cost64
\[x \]

Error

Reproduce

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