?

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

?

\[\left(x + \sin y\right) + z \cdot \cos y \]
\[\mathsf{fma}\left(z, \cos y, x\right) + \sin y \]
(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 Float64(fma(z, cos(y), 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[(N[(z * N[Cos[y], $MachinePrecision] + x), $MachinePrecision] + N[Sin[y], $MachinePrecision]), $MachinePrecision]
\left(x + \sin y\right) + z \cdot \cos y
\mathsf{fma}\left(z, \cos y, x\right) + \sin y

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. Applied egg-rr99.9%

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

    [Start]99.9

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

    fma-udef [=>]99.9

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

    associate-+r+ [=>]99.9

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

    fma-def [=>]99.9

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

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

Alternatives

Alternative 1
Accuracy99.9%
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 2
Accuracy99.9%
Cost13248
\[\sin y + \left(x + z \cdot \cos y\right) \]
Alternative 3
Accuracy83.6%
Cost6988
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.92 \cdot 10^{+59}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-59}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 430000:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy94.9%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{-61} \lor \neg \left(z \leq 2.8 \cdot 10^{-15}\right):\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
Alternative 5
Accuracy72.0%
Cost6857
\[\begin{array}{l} \mathbf{if}\;z \leq -3.1 \cdot 10^{+63} \lor \neg \left(z \leq 2.9 \cdot 10^{+32}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 6
Accuracy69.8%
Cost1096
\[\begin{array}{l} \mathbf{if}\;y \leq -2600000:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 24500:\\ \;\;\;\;\left(y + \left(z + x\right)\right) + \left(y \cdot \left(z \cdot y\right)\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 7
Accuracy53.3%
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-107}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-131}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-98}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-52}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy69.6%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+76}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+28}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Accuracy50.7%
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+52}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 12500000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 10
Accuracy65.4%
Cost192
\[z + x \]
Alternative 11
Accuracy42.1%
Cost64
\[x \]

Error

Reproduce?

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