?

Average Accuracy: 99.9% → 99.9%
Time: 8.7s
Precision: binary64
Cost: 19520

?

\[\left(x + \sin y\right) + z \cdot \cos y \]
\[\mathsf{fma}\left(z, \cos y, x + \sin y\right) \]
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma z (cos y) (+ x (sin y))))
double code(double x, double y, double z) {
	return (x + sin(y)) + (z * cos(y));
}
double code(double x, double y, double z) {
	return fma(z, cos(y), (x + sin(y)));
}
function code(x, y, z)
	return Float64(Float64(x + sin(y)) + Float64(z * cos(y)))
end
function code(x, y, z)
	return fma(z, cos(y), Float64(x + sin(y)))
end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + \sin y\right) + z \cdot \cos y
\mathsf{fma}\left(z, \cos y, x + \sin y\right)

Error?

Derivation?

  1. Initial program 99.9%

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

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

    [Start]99.9

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

    +-commutative [=>]99.9

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

    fma-def [=>]99.9

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

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

Alternatives

Alternative 1
Accuracy88.7%
Cost13384
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;x \leq -14000000000000:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-27}:\\ \;\;\;\;\sin y + t_0\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+55}:\\ \;\;\;\;t_0 + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 2
Accuracy99.9%
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 3
Accuracy69.6%
Cost7516
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;x \leq -8 \cdot 10^{-65}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-175}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-277}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-280}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-224}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-192}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-78}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 4
Accuracy85.3%
Cost7120
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.4 \cdot 10^{+112}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-29}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-27}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{+210}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy84.5%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{-29} \lor \neg \left(z \leq 1.6 \cdot 10^{-57}\right):\\ \;\;\;\;z \cdot \cos y + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
Alternative 6
Accuracy65.1%
Cost6992
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-65}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-288}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-222}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-192}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 7
Accuracy55.0%
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -8:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 105:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{+28}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{+55}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy70.4%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+69}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-6}:\\ \;\;\;\;x + \left(z + y\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Accuracy68.0%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-67}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-164}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 10
Accuracy44.5%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-53}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-145}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy66.6%
Cost192
\[z + x \]
Alternative 12
Accuracy42.8%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023147 
(FPCore (x y z)
  :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
  :precision binary64
  (+ (+ x (sin y)) (* z (cos y))))