Average Error: 0.1 → 0.1
Time: 40.1s
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
Error6.6
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -2.35 \cdot 10^{+20}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+38}:\\ \;\;\;\;\cos y - z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error0.1
Cost13248
\[\left(x + \cos y\right) - z \cdot \sin y \]
Alternative 3
Error12.3
Cost7448
\[\begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ t_1 := x + \cos y\\ \mathbf{if}\;z \leq -1.85 \cdot 10^{+217}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{+148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+128}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+189}:\\ \;\;\;\;x + 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error19.2
Cost6860
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{+98}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-219}:\\ \;\;\;\;x - \left(-1 + z \cdot y\right)\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-12}:\\ \;\;\;\;\cos y\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 5
Error12.2
Cost6856
\[\begin{array}{l} t_0 := x + \cos y\\ \mathbf{if}\;y \leq -0.072:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.007:\\ \;\;\;\;x - \left(-1 + z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error19.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.1:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;y \leq 0.011:\\ \;\;\;\;x - \left(-1 + z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 7
Error21.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{-11}:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-22}:\\ \;\;\;\;1 - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 8
Error24.4
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+256}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 9
Error25.2
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0225:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error24.7
Cost192
\[x + 1 \]
Alternative 11
Error50.3
Cost64
\[1 \]

Error

Reproduce

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