Average Error: 0.1 → 0.1
Time: 11.3s
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)))): 1 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)))): 0 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.1
Cost13384
\[\begin{array}{l} t_0 := z \cdot \sin y\\ t_1 := x - t_0\\ \mathbf{if}\;x \leq -2263007.935109674:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.023382197811077386:\\ \;\;\;\;\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
Error4.6
Cost6984
\[\begin{array}{l} t_0 := x - z \cdot \sin y\\ \mathbf{if}\;z \leq -3.129823936231271 \cdot 10^{+22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 901.4964957225062:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error11.5
Cost6920
\[\begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -3.561976126371877 \cdot 10^{+175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.914108039000788 \cdot 10^{+72}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error12.7
Cost6856
\[\begin{array}{l} t_0 := x + \cos y\\ \mathbf{if}\;y \leq -77290300315584860:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.2966822269877143 \cdot 10^{-14}:\\ \;\;\;\;x - \left(z \cdot y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error19.3
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -77290300315584860:\\ \;\;\;\;x - -1\\ \mathbf{elif}\;y \leq 1.2966822269877143 \cdot 10^{-14}:\\ \;\;\;\;x - \left(z \cdot y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;x - -1\\ \end{array} \]
Alternative 7
Error23.5
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq 2.6472241617781067 \cdot 10^{+248}:\\ \;\;\;\;x - -1\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot y\\ \end{array} \]
Alternative 8
Error23.9
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq 2.6472241617781067 \cdot 10^{+248}:\\ \;\;\;\;x - -1\\ \mathbf{else}:\\ \;\;\;\;-z \cdot y\\ \end{array} \]
Alternative 9
Error24.4
Cost192
\[x - -1 \]
Alternative 10
Error37.0
Cost64
\[x \]

Error

Reproduce

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