?

Average Accuracy: 99.9% → 99.9%
Time: 9.3s
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. Simplified100.0%

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

    [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 [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy89.0%
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-18}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{+36}:\\ \;\;\;\;\sin y + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 2
Accuracy99.9%
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 3
Accuracy84.2%
Cost7244
\[\begin{array}{l} t_0 := z \cdot \cos y\\ t_1 := t_0 + \left(y + x\right)\\ \mathbf{if}\;z \leq -4400:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.26 \cdot 10^{+33}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+104}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy81.9%
Cost7121
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.5 \cdot 10^{+222}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.56 \cdot 10^{+106}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq -2600000 \lor \neg \left(z \leq 2.45 \cdot 10^{+33}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
Alternative 5
Accuracy70.2%
Cost7120
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+222}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-174}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-131}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+33}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Accuracy70.1%
Cost6860
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+20}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+38}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+119}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 7
Accuracy70.5%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{+18}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-30}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Accuracy68.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-110}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 6.9 \cdot 10^{-220}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Accuracy44.8%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-218}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy54.6%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{-45}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-72}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy66.6%
Cost192
\[z + x \]
Alternative 12
Accuracy42.7%
Cost64
\[x \]

Error

Reproduce?

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