Average Error: 3.9 → 2.1
Time: 2.5s
Precision: binary64
\[x \cdot x - y \cdot y \]
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 3.6361091965505894 \cdot 10^{+301}:\\ \;\;\;\;x \cdot x - y \cdot y\\ \mathbf{else}:\\ \;\;\;\;{x}^{2}\\ \end{array} \]
x \cdot x - y \cdot y
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 3.6361091965505894 \cdot 10^{+301}:\\
\;\;\;\;x \cdot x - y \cdot y\\

\mathbf{else}:\\
\;\;\;\;{x}^{2}\\


\end{array}
(FPCore (x y) :precision binary64 (- (* x x) (* y y)))
(FPCore (x y)
 :precision binary64
 (if (<= (* x x) 3.6361091965505894e+301) (- (* x x) (* y y)) (pow x 2.0)))
double code(double x, double y) {
	return (x * x) - (y * y);
}
double code(double x, double y) {
	double tmp;
	if ((x * x) <= 3.6361091965505894e+301) {
		tmp = (x * x) - (y * y);
	} else {
		tmp = pow(x, 2.0);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 x x) < 3.63610919655058944e301

    1. Initial program 0.0

      \[x \cdot x - y \cdot y \]

    if 3.63610919655058944e301 < (*.f64 x x)

    1. Initial program 15.4

      \[x \cdot x - y \cdot y \]
    2. Taylor expanded in x around inf 8.3

      \[\leadsto \color{blue}{{x}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 3.6361091965505894 \cdot 10^{+301}:\\ \;\;\;\;x \cdot x - y \cdot y\\ \mathbf{else}:\\ \;\;\;\;{x}^{2}\\ \end{array} \]

Reproduce

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