?

Average Error: 0.08% → 0.08%
Time: 9.8s
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
Error11.72%
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -20000000:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-47}:\\ \;\;\;\;\sin y + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 2
Error0.08%
Cost13248
\[z \cdot \cos y + \left(x + \sin y\right) \]
Alternative 3
Error17.6%
Cost7244
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -470:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+54}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+181}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 + \left(y + x\right)\\ \end{array} \]
Alternative 4
Error28.59%
Cost7120
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -7.5 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-270}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-181}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+61}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error30%
Cost6992
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+256}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{+218}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq -9.2 \cdot 10^{+38}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq -122000:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+82}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 6
Error17.67%
Cost6857
\[\begin{array}{l} \mathbf{if}\;z \leq -3100 \lor \neg \left(z \leq 5.5 \cdot 10^{+58}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
Alternative 7
Error29.04%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -70000:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+82}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 8
Error30.99%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-79}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-166}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
Alternative 9
Error54.97%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-79}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-133}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error43.76%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.1 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-35}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error32.56%
Cost192
\[z + x \]
Alternative 12
Error56.97%
Cost64
\[x \]

Error

Reproduce?

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