Average Error: 0.0 → 0.0
Time: 6.6s
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
    (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
Error6.3
Cost13384
\[\begin{array}{l} t_0 := z + \left(x + \sin y\right)\\ \mathbf{if}\;x \leq -2.05 \cdot 10^{-18}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-11}:\\ \;\;\;\;\sin y + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost13248
\[\left(x + \sin y\right) + z \cdot \cos y \]
Alternative 3
Error15.6
Cost6988
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-18}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-281}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{-39}:\\ \;\;\;\;z + \sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 4
Error7.4
Cost6984
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -4.4 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{+16}:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.8
Cost6856
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-18}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-10}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 6
Error11.4
Cost6856
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -2.1 \cdot 10^{+77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.31:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error18.7
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+85}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 14000000:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Error20.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{-67}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-159}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Error35.3
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-158}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error27.9
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -7000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2050000000000:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error21.2
Cost192
\[z + x \]
Alternative 12
Error36.6
Cost64
\[x \]

Error

Reproduce

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