Average Error: 0.1 → 0.1
Time: 10.7s
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
Error0.1
Cost13248
\[\left(x + \cos y\right) - z \cdot \sin y \]
Alternative 2
Error0.7
Cost7112
\[\begin{array}{l} t_0 := \left(x - -1\right) - z \cdot \sin y\\ \mathbf{if}\;z \leq -614791937.1989021:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.1072306921276967 \cdot 10^{-32}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error4.9
Cost6984
\[\begin{array}{l} t_0 := x - z \cdot \sin y\\ \mathbf{if}\;z \leq -568613727178653060:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.5881906886631743 \cdot 10^{-18}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error11.1
Cost6920
\[\begin{array}{l} t_0 := z \cdot \left(-\sin y\right)\\ \mathbf{if}\;z \leq -1.0587155270379382 \cdot 10^{+161}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.797683519758154 \cdot 10^{+135}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error12.5
Cost6856
\[\begin{array}{l} t_0 := x + \cos y\\ \mathbf{if}\;y \leq -2.8690080106936887 \cdot 10^{+23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.5142123445323665 \cdot 10^{-17}:\\ \;\;\;\;x + \left(1 - z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error17.8
Cost6728
\[\begin{array}{l} \mathbf{if}\;x \leq -159.91304654616962:\\ \;\;\;\;x - -1\\ \mathbf{elif}\;x \leq 8.547385684383715 \cdot 10^{-8}:\\ \;\;\;\;\cos y\\ \mathbf{else}:\\ \;\;\;\;x - -1\\ \end{array} \]
Alternative 7
Error19.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -9.90523742314053 \cdot 10^{+73}:\\ \;\;\;\;x - -1\\ \mathbf{elif}\;y \leq 5.165649929716244 \cdot 10^{+25}:\\ \;\;\;\;x + \left(1 - z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - -1\\ \end{array} \]
Alternative 8
Error25.2
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0416977273217796 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.11310062791475402:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error24.5
Cost192
\[x - -1 \]
Alternative 10
Error50.6
Cost64
\[1 \]

Error

Reproduce

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