?

Average Error: 0.09% → 0.08%
Time: 8.6s
Precision: binary64
Cost: 19584

?

\[\left(x + \cos y\right) - z \cdot \sin y \]
\[\mathsf{fma}\left(\sin y, -z, x + \cos y\right) \]
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (+ x (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 fma(sin(y), -z, (x + cos(y)));
}
function code(x, y, z)
	return Float64(Float64(x + cos(y)) - Float64(z * sin(y)))
end
function code(x, y, z)
	return fma(sin(y), Float64(-z), Float64(x + 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[(N[Sin[y], $MachinePrecision] * (-z) + N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + \cos y\right) - z \cdot \sin y
\mathsf{fma}\left(\sin y, -z, x + \cos y\right)

Error?

Derivation?

  1. Initial program 0.09

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

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

    [Start]0.09

    \[ \left(x + \cos y\right) - z \cdot \sin y \]

    cancel-sign-sub-inv [=>]0.09

    \[ \color{blue}{\left(x + \cos y\right) + \left(-z\right) \cdot \sin y} \]

    +-commutative [=>]0.09

    \[ \color{blue}{\left(-z\right) \cdot \sin y + \left(x + \cos y\right)} \]

    *-commutative [=>]0.09

    \[ \color{blue}{\sin y \cdot \left(-z\right)} + \left(x + \cos y\right) \]

    fma-def [=>]0.08

    \[ \color{blue}{\mathsf{fma}\left(\sin y, -z, x + \cos y\right)} \]
  3. Final simplification0.08

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

Alternatives

Alternative 1
Error1.41%
Cost13385
\[\begin{array}{l} t_0 := \sin y \cdot z\\ \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.92\right):\\ \;\;\;\;x - t_0\\ \mathbf{else}:\\ \;\;\;\;\cos y - t_0\\ \end{array} \]
Alternative 2
Error0.09%
Cost13248
\[\left(x + \cos y\right) - \sin y \cdot z \]
Alternative 3
Error20.19%
Cost7185
\[\begin{array}{l} t_0 := x + \cos y\\ \mathbf{if}\;y \leq -240000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.112:\\ \;\;\;\;1 + \left(x - y \cdot z\right)\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+102} \lor \neg \left(y \leq 1.02 \cdot 10^{+140}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin y \cdot \left(-z\right)\\ \end{array} \]
Alternative 4
Error28.44%
Cost6992
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-11}:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-252}:\\ \;\;\;\;\cos y\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-174}:\\ \;\;\;\;\left(x + 1\right) + y \cdot \left(y \cdot -0.5 - z\right)\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-13}:\\ \;\;\;\;\cos y\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 5
Error7.32%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{+20} \lor \neg \left(z \leq 1.02 \cdot 10^{+40}\right):\\ \;\;\;\;x - \sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \cos y\\ \end{array} \]
Alternative 6
Error19.4%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -240000000000 \lor \neg \left(y \leq 0.00048\right):\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;1 + \left(x - y \cdot z\right)\\ \end{array} \]
Alternative 7
Error30.02%
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+39}:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;y \leq 42:\\ \;\;\;\;\left(x + 1\right) + y \cdot \left(y \cdot -0.5 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 8
Error29.98%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -15000000000000:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;y \leq 3.1:\\ \;\;\;\;1 + \left(x - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 9
Error33.64%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-11}:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-88}:\\ \;\;\;\;1 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 10
Error39.21%
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-215}:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-172}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 11
Error36.16%
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8 \cdot 10^{+182}:\\ \;\;\;\;x - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 12
Error39.08%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -0.85:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.11:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error38.22%
Cost192
\[x + 1 \]
Alternative 14
Error77.76%
Cost64
\[1 \]

Error

Reproduce?

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