Average Error: 0.1 → 0.1
Time: 9.0s
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
Error8.0
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8939672978711524 \cdot 10^{+44}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 3.6713465662994665 \cdot 10^{+50}:\\ \;\;\;\;\sin y + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[\left(x + \sin y\right) + z \cdot \cos y \]
Alternative 3
Error35.1
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -6.657102180469003 \cdot 10^{-122}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.226831608733367 \cdot 10^{-96}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error36.6
Cost64
\[x \]

Error

Reproduce

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