Average Error: 0.0 → 0.0
Time: 1.3s
Precision: binary64
Cost: 6784
\[x \cdot x - y \cdot y \]
\[\mathsf{fma}\left(x, x, y \cdot \left(-y\right)\right) \]
(FPCore (x y) :precision binary64 (- (* x x) (* y y)))
(FPCore (x y) :precision binary64 (fma x x (* y (- y))))
double code(double x, double y) {
	return (x * x) - (y * y);
}
double code(double x, double y) {
	return fma(x, x, (y * -y));
}
function code(x, y)
	return Float64(Float64(x * x) - Float64(y * y))
end
function code(x, y)
	return fma(x, x, Float64(y * Float64(-y)))
end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(x * x + N[(y * (-y)), $MachinePrecision]), $MachinePrecision]
x \cdot x - y \cdot y
\mathsf{fma}\left(x, x, y \cdot \left(-y\right)\right)

Error

Derivation

  1. Initial program 0.0

    \[x \cdot x - y \cdot y \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(-y\right)\right)} \]
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(-y\right)\right) \]

Alternatives

Alternative 1
Error14.5
Cost1556
\[\begin{array}{l} t_0 := y \cdot \left(-y\right)\\ \mathbf{if}\;x \cdot x \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2.4 \cdot 10^{-226}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \cdot x \leq 2.6 \cdot 10^{-168}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2.2 \cdot 10^{-120}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \cdot x \leq 6.8 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 2
Error0.0
Cost448
\[x \cdot x - y \cdot y \]
Alternative 3
Error27.8
Cost192
\[x \cdot x \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x y)
  :name "Examples.Basics.BasicTests:f2 from sbv-4.4"
  :precision binary64
  (- (* x x) (* y y)))