?

Average Error: 0.08% → 0.08%
Time: 9.5s
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.08

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

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

    [Start]0.08

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

    +-commutative [=>]0.08

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

    fma-def [=>]0.08

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

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

Alternatives

Alternative 1
Error4.91%
Cost13385
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;x \leq -26 \lor \neg \left(x \leq 6.2 \cdot 10^{-10}\right):\\ \;\;\;\;x + t_0\\ \mathbf{else}:\\ \;\;\;\;\sin y + t_0\\ \end{array} \]
Alternative 2
Error0.08%
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 3
Error29.86%
Cost7384
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.02 \cdot 10^{-226}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-247}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-104}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{-55}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{+65}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.58%
Cost7376
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+68}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{+163}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 + \left(y + x\right)\\ \end{array} \]
Alternative 5
Error16.87%
Cost6988
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{+57}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{+68}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error5.14%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{-31} \lor \neg \left(z \leq 6\right):\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
Alternative 7
Error32.01%
Cost6860
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{-43}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-217}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-58}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Error29.38%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{+33}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 1.72 \cdot 10^{+50}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Error31.38%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-134}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-126}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 10
Error44.21%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-55}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-6}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error33.53%
Cost192
\[z + x \]
Alternative 12
Error57.22%
Cost64
\[x \]

Error

Reproduce?

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