Average Error: 0.1 → 0.1
Time: 10.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)))): 2 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
Error7.2
Cost13384
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -7.242755417033766 \cdot 10^{+78}:\\ \;\;\;\;x + \left(y + t_0\right)\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;\sin y + t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[\left(x + \sin y\right) + z \cdot \cos y \]
Alternative 3
Error11.3
Cost7120
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -3.561976126371877 \cdot 10^{+175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.5955346731555302 \cdot 10^{+121}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq -171242.39464640015:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error18.3
Cost6988
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -3.561976126371877 \cdot 10^{+175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.325800161513698 \cdot 10^{-148}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error14.8
Cost6988
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1313940557463502 \cdot 10^{-66}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 1.5491214806175476 \cdot 10^{-140}:\\ \;\;\;\;z + \sin y\\ \mathbf{elif}\;x \leq 1.4109044396418216 \cdot 10^{-38}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 6
Error7.6
Cost6984
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -3.561976126371877 \cdot 10^{+175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error7.2
Cost6984
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -7.242755417033766 \cdot 10^{+78}:\\ \;\;\;\;x + \left(y + t_0\right)\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error19.0
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5689418592315446 \cdot 10^{+91}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 1.1148360912509461 \cdot 10^{+21}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Error33.2
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1514728422659725 \cdot 10^{-7}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 10
Error26.5
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4982982968575364 \cdot 10^{+20}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.032843798311854 \cdot 10^{-16}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error20.3
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -8.698480835359714 \cdot 10^{-212}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 1.7076220005650084 \cdot 10^{-147}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 12
Error45.8
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -4.3067751468584874 \cdot 10^{-161}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.1046098938209496 \cdot 10^{-115}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 13
Error31.9
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1514728422659725 \cdot 10^{-7}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 0.022348561497808516:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 14
Error47.0
Cost64
\[z \]

Error

Reproduce

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