?

Average Error: 0.1 → 0.1
Time: 12.5s
Precision: binary64
Cost: 19520

?

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

    [Start]0.1

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

    associate-+l+ [=>]0.1

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

    +-commutative [=>]0.1

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

    fma-def [=>]0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[\left(x + \sin y\right) + z \cdot \cos y \]
Alternative 2
Error19.2
Cost7648
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;x \leq -7.4 \cdot 10^{-28}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;x \leq -1.82 \cdot 10^{-124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{-181}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq -1.08 \cdot 10^{-240}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-282}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-248}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-222}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-107}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \]
Alternative 3
Error10.2
Cost6988
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-41}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+17}:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error2.9
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{-41} \lor \neg \left(z \leq 9.5 \cdot 10^{-12}\right):\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
Alternative 5
Error0.4
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -0.92 \lor \neg \left(z \leq 7.5\right):\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;\sin y + \left(x + z\right)\\ \end{array} \]
Alternative 6
Error14.7
Cost6856
\[\begin{array}{l} \mathbf{if}\;x \leq -1.76 \cdot 10^{-9}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-127}:\\ \;\;\;\;z + \sin y\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \]
Alternative 7
Error22.8
Cost6728
\[\begin{array}{l} \mathbf{if}\;x \leq -1.32 \cdot 10^{-48}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-208}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \]
Alternative 8
Error31.0
Cost592
\[\begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{+141}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -76000:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{-16}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{+63}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 9
Error18.7
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+46}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;y \leq 0.65:\\ \;\;\;\;x + \left(z + y\right)\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \]
Alternative 10
Error21.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq 6.2 \cdot 10^{-62}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{-12}:\\ \;\;\;\;z + y\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \]
Alternative 11
Error37.0
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq 4.9 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-9}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error21.2
Cost192
\[x + z \]
Alternative 13
Error36.5
Cost64
\[x \]

Error

Reproduce?

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