?

Average Error: 0.1 → 0.1
Time: 8.4s
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 0.1

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

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

    [Start]0.1

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

    +-commutative [=>]0.1

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

    fma-def [=>]0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[\left(x + \sin y\right) + z \cdot \cos y \]
Alternative 2
Error20.8
Cost7385
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;y \leq -2.55 \cdot 10^{+181}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+58}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq -7.5 \cdot 10^{+20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+71}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+197} \lor \neg \left(y \leq 1.7 \cdot 10^{+276}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin y\\ \end{array} \]
Alternative 3
Error9.5
Cost7120
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.66 \cdot 10^{+156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -0.00185:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-9}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+163}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error7.1
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+156} \lor \neg \left(z \leq 1.16 \cdot 10^{+163}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \end{array} \]
Alternative 5
Error21.1
Cost6860
\[\begin{array}{l} \mathbf{if}\;x \leq -1.95 \cdot 10^{-82}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-241}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-109}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 6
Error15.3
Cost6856
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-109}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-103}:\\ \;\;\;\;z + \sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 7
Error19.9
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.2:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-54}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Error21.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.65 \cdot 10^{-110}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-297}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Error31.4
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{+62}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+43}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 10
Error22.1
Cost192
\[z + x \]
Alternative 11
Error37.3
Cost64
\[x \]

Error

Reproduce?

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