Average Error: 0.1 → 0.1
Time: 11.8s
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
Error21.4
Cost6992
\[\begin{array}{l} \mathbf{if}\;x \leq -9.906342940571468 \cdot 10^{-219}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq -5.33684750857382 \cdot 10^{-262}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq 1.5512872373336204 \cdot 10^{-246}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{elif}\;x \leq 3.6465996271126133 \cdot 10^{-72}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 4
Error10.0
Cost6988
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.494977013994149 \cdot 10^{+163}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.2828973129543407 \cdot 10^{-59}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 7467826829884971:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error18.4
Cost6856
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8939672978711524 \cdot 10^{+44}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 3.6713465662994665 \cdot 10^{+50}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 6
Error18.9
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.8690080106936887 \cdot 10^{+23}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 0.0004406951564213727:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 7
Error26.3
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1335595.5653913505:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.0854284218421 \cdot 10^{-24}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error20.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -6.657102180469003 \cdot 10^{-122}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 8.226831608733367 \cdot 10^{-96}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
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 10
Error59.6
Cost64
\[y \]

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))))