Average Error: 0.1 → 0.1
Time: 12.6s
Precision: binary64
Cost: 19584
\[\left(x + \cos y\right) - z \cdot \sin y \]
\[x - \mathsf{fma}\left(z, \sin y, -\cos y\right) \]
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (- x (fma z (sin y) (- (cos y)))))
double code(double x, double y, double z) {
	return (x + cos(y)) - (z * sin(y));
}
double code(double x, double y, double z) {
	return x - fma(z, sin(y), -cos(y));
}
function code(x, y, z)
	return Float64(Float64(x + cos(y)) - Float64(z * sin(y)))
end
function code(x, y, z)
	return Float64(x - fma(z, sin(y), Float64(-cos(y))))
end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x - N[(z * N[Sin[y], $MachinePrecision] + (-N[Cos[y], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\left(x + \cos y\right) - z \cdot \sin y
x - \mathsf{fma}\left(z, \sin y, -\cos y\right)

Error

Derivation

  1. Initial program 0.1

    \[\left(x + \cos y\right) - z \cdot \sin y \]
  2. Simplified0.1

    \[\leadsto \color{blue}{x - \mathsf{fma}\left(z, \sin y, -\cos y\right)} \]
    Proof
    (-.f64 x (fma.f64 z (sin.f64 y) (neg.f64 (cos.f64 y)))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 z (sin.f64 y)) (cos.f64 y)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 x (*.f64 z (sin.f64 y))) (cos.f64 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> cancel-sign-sub-inv_binary64 (+.f64 x (*.f64 (neg.f64 z) (sin.f64 y)))) (cos.f64 y)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (cos.f64 y) (+.f64 x (*.f64 (neg.f64 z) (sin.f64 y))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (cos.f64 y) x) (*.f64 (neg.f64 z) (sin.f64 y)))): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 x (cos.f64 y))) (*.f64 (neg.f64 z) (sin.f64 y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y)))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error1.0
Cost13384
\[\begin{array}{l} t_0 := z \cdot \sin y\\ t_1 := x - t_0\\ \mathbf{if}\;x \leq -31461808.31811395:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.401023881761313 \cdot 10^{-9}:\\ \;\;\;\;\cos y - t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[\left(x + \cos y\right) - z \cdot \sin y \]
Alternative 3
Error12.2
Cost7316
\[\begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ t_1 := x + \left(1 - z \cdot y\right)\\ \mathbf{if}\;z \leq -6.592531959858113 \cdot 10^{+216}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.4242710173243785 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.021843281123916 \cdot 10^{+118}:\\ \;\;\;\;x + \cos y\\ \mathbf{elif}\;z \leq 1.1697690408816735 \cdot 10^{+200}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.563922839544438 \cdot 10^{+239}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error20.5
Cost7124
\[\begin{array}{l} \mathbf{if}\;y \leq -704050.1279253244:\\ \;\;\;\;x - -1\\ \mathbf{elif}\;y \leq 2.1029162195330391 \cdot 10^{+68}:\\ \;\;\;\;x + \left(1 - z \cdot y\right)\\ \mathbf{elif}\;y \leq 9.2124891195855 \cdot 10^{+94}:\\ \;\;\;\;\cos y\\ \mathbf{elif}\;y \leq 1.7215603961056001 \cdot 10^{+149}:\\ \;\;\;\;x - -1\\ \mathbf{elif}\;y \leq 2.9132438513657273 \cdot 10^{+232}:\\ \;\;\;\;\cos y\\ \mathbf{else}:\\ \;\;\;\;x - -1\\ \end{array} \]
Alternative 5
Error5.5
Cost6984
\[\begin{array}{l} t_0 := x - z \cdot \sin y\\ \mathbf{if}\;z \leq -3.028317977358803 \cdot 10^{+124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.3616549050694537 \cdot 10^{+23}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error12.6
Cost6856
\[\begin{array}{l} t_0 := x + \cos y\\ \mathbf{if}\;y \leq -704050.1279253244:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9.761974989807316 \cdot 10^{-5}:\\ \;\;\;\;x + \left(1 - z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error19.8
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -704050.1279253244:\\ \;\;\;\;x - -1\\ \mathbf{elif}\;y \leq 9.761974989807316 \cdot 10^{-5}:\\ \;\;\;\;x + \left(1 - z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - -1\\ \end{array} \]
Alternative 8
Error23.3
Cost584
\[\begin{array}{l} t_0 := x - z \cdot y\\ \mathbf{if}\;z \leq -2.4242710173243785 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.010107671555544 \cdot 10^{+257}:\\ \;\;\;\;x - -1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error24.9
Cost520
\[\begin{array}{l} t_0 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -6.465362759652451 \cdot 10^{+190}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.010107671555544 \cdot 10^{+257}:\\ \;\;\;\;x - -1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error25.8
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -31461808.31811395:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.401023881761313 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error25.2
Cost192
\[x - -1 \]
Alternative 12
Error50.2
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022316 
(FPCore (x y z)
  :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
  :precision binary64
  (- (+ x (cos y)) (* z (sin y))))