?

Average Accuracy: 99.9% → 99.9%
Time: 11.1s
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 99.9%

    \[\left(x + \cos y\right) - z \cdot \sin y \]
  2. Simplified99.9%

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

    [Start]99.9

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

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

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

    +-commutative [=>]99.9

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

    *-commutative [=>]99.9

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

    fma-def [=>]99.9

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

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

Alternatives

Alternative 1
Accuracy99.9%
Cost13248
\[\left(x + \cos y\right) - \sin y \cdot z \]
Alternative 2
Accuracy99.4%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -246000 \lor \neg \left(z \leq 7.4 \cdot 10^{-6}\right):\\ \;\;\;\;\left(x + 1\right) - \sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \cos y\\ \end{array} \]
Alternative 3
Accuracy70.7%
Cost6992
\[\begin{array}{l} \mathbf{if}\;x \leq -0.017:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-278}:\\ \;\;\;\;\cos y\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-254}:\\ \;\;\;\;1 - y \cdot z\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-6}:\\ \;\;\;\;\cos y\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 4
Accuracy84.8%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{+106} \lor \neg \left(z \leq 4.9 \cdot 10^{+126}\right):\\ \;\;\;\;1 - \sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \cos y\\ \end{array} \]
Alternative 5
Accuracy93.4%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -15500000000000 \lor \neg \left(z \leq 4.5 \cdot 10^{+18}\right):\\ \;\;\;\;x - \sin y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \cos y\\ \end{array} \]
Alternative 6
Accuracy82.0%
Cost6921
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{+107} \lor \neg \left(z \leq 2.6 \cdot 10^{+175}\right):\\ \;\;\;\;\sin y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \cos y\\ \end{array} \]
Alternative 7
Accuracy80.4%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \lor \neg \left(y \leq 14500\right):\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;1 + \left(x - y \cdot z\right)\\ \end{array} \]
Alternative 8
Accuracy69.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -260:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;y \leq 39000:\\ \;\;\;\;1 + \left(x - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 9
Accuracy65.5%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-6} \lor \neg \left(x \leq 2 \cdot 10^{-96}\right):\\ \;\;\;\;x + 1\\ \mathbf{else}:\\ \;\;\;\;1 - y \cdot z\\ \end{array} \]
Alternative 10
Accuracy60.4%
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -3.3 \cdot 10^{-279}:\\ \;\;\;\;x + 1\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-304}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
Alternative 11
Accuracy60.1%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -0.8:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.0006:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy60.8%
Cost192
\[x + 1 \]
Alternative 13
Accuracy21.7%
Cost64
\[1 \]

Error

Reproduce?

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