Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.2% → 98.3%
Time: 9.3s
Alternatives: 9
Speedup: 8.1×

Specification

?
\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (-
  (+
   (pow (+ (* a a) (* b b)) 2.0)
   (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
  1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 73.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (-
  (+
   (pow (+ (* a a) (* b b)) 2.0)
   (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
  1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}

Alternative 1: 98.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\ \mathbf{if}\;t\_0 \leq \infty:\\ \;\;\;\;t\_0 + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0
         (+
          (pow (+ (* a a) (* b b)) 2.0)
          (* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
   (if (<= t_0 INFINITY) (+ t_0 -1.0) (+ (* (* a a) (+ (* a a) 4.0)) -1.0))))
double code(double a, double b) {
	double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0 + -1.0;
	} else {
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0;
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0 + -1.0;
	} else {
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0;
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0 + -1.0
	else:
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0))))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = Float64(t_0 + -1.0);
	else
		tmp = Float64(Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0)) + -1.0);
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0 + -1.0;
	else
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\

\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) < +inf.0

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Add Preprocessing

    if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a))))))

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative0.0%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define5.2%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative5.2%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*5.2%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv5.2%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval5.2%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define5.2%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval5.2%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified5.2%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 26.2%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 96.3%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. unpow296.3%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    8. Applied egg-rr96.3%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    9. Taylor expanded in a around inf 96.3%

      \[\leadsto \left(a \cdot a\right) \cdot \left(4 + a \cdot \color{blue}{a}\right) + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 81.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.8 \cdot 10^{+28}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 1.8e+28)
   (+ -1.0 (* (* a a) (+ 4.0 (* a (+ a 4.0)))))
   (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))))
double code(double a, double b) {
	double tmp;
	if (b <= 1.8e+28) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	} else {
		tmp = -1.0 + (((b * b) * 4.0) + pow(b, 4.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 1.8d+28) then
        tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a + 4.0d0))))
    else
        tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 1.8e+28) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	} else {
		tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 1.8e+28:
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))))
	else:
		tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 1.8e+28)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))));
	else
		tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 1.8e+28)
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	else
		tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 1.8e+28], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{+28}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.8e28

    1. Initial program 73.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg73.6%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative73.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define73.6%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified73.6%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 59.2%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 79.8%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. unpow279.8%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    8. Applied egg-rr79.8%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]

    if 1.8e28 < b

    1. Initial program 58.1%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+58.1%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative58.1%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
      3. +-commutative58.1%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg58.1%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+58.1%

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
      6. +-commutative58.1%

        \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. associate-+l+58.1%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
    3. Simplified58.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 97.0%

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Step-by-step derivation
      1. unpow297.0%

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    7. Applied egg-rr97.0%

      \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.8 \cdot 10^{+28}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 4.3 \cdot 10^{+27}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 4.3e+27) (+ -1.0 (* (* a a) (+ 4.0 (* a (+ a 4.0))))) (pow b 4.0)))
double code(double a, double b) {
	double tmp;
	if (b <= 4.3e+27) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	} else {
		tmp = pow(b, 4.0);
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 4.3d+27) then
        tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a + 4.0d0))))
    else
        tmp = b ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 4.3e+27) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	} else {
		tmp = Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 4.3e+27:
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))))
	else:
		tmp = math.pow(b, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 4.3e+27)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))));
	else
		tmp = b ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 4.3e+27)
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	else
		tmp = b ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 4.3e+27], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.3 \cdot 10^{+27}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;{b}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 4.30000000000000008e27

    1. Initial program 73.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg73.6%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative73.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define73.6%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval73.6%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified73.6%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 59.2%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 79.8%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. unpow279.8%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    8. Applied egg-rr79.8%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]

    if 4.30000000000000008e27 < b

    1. Initial program 58.1%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+58.1%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative58.1%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
      3. +-commutative58.1%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg58.1%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+58.1%

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
      6. +-commutative58.1%

        \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. associate-+l+58.1%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
    3. Simplified58.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 97.0%

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around inf 97.0%

      \[\leadsto \color{blue}{{b}^{4}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 4.3 \cdot 10^{+27}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.3% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{+153}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{elif}\;a \leq 1.16 \cdot 10^{+87}:\\ \;\;\;\;\left(1 + b \cdot 2\right) \cdot \left(-1 + b \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot 4\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -5.8e+153)
   (+ -1.0 (* (* a a) 4.0))
   (if (<= a 1.16e+87)
     (* (+ 1.0 (* b 2.0)) (+ -1.0 (* b 2.0)))
     (+ -1.0 (* (* a a) (+ 4.0 (* a 4.0)))))))
double code(double a, double b) {
	double tmp;
	if (a <= -5.8e+153) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else if (a <= 1.16e+87) {
		tmp = (1.0 + (b * 2.0)) * (-1.0 + (b * 2.0));
	} else {
		tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0)));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (a <= (-5.8d+153)) then
        tmp = (-1.0d0) + ((a * a) * 4.0d0)
    else if (a <= 1.16d+87) then
        tmp = (1.0d0 + (b * 2.0d0)) * ((-1.0d0) + (b * 2.0d0))
    else
        tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * 4.0d0)))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (a <= -5.8e+153) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else if (a <= 1.16e+87) {
		tmp = (1.0 + (b * 2.0)) * (-1.0 + (b * 2.0));
	} else {
		tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0)));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -5.8e+153:
		tmp = -1.0 + ((a * a) * 4.0)
	elif a <= 1.16e+87:
		tmp = (1.0 + (b * 2.0)) * (-1.0 + (b * 2.0))
	else:
		tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0)))
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -5.8e+153)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0));
	elseif (a <= 1.16e+87)
		tmp = Float64(Float64(1.0 + Float64(b * 2.0)) * Float64(-1.0 + Float64(b * 2.0)));
	else
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * 4.0))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -5.8e+153)
		tmp = -1.0 + ((a * a) * 4.0);
	elseif (a <= 1.16e+87)
		tmp = (1.0 + (b * 2.0)) * (-1.0 + (b * 2.0));
	else
		tmp = -1.0 + ((a * a) * (4.0 + (a * 4.0)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -5.8e+153], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.16e+87], N[(N[(1.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.8 \cdot 10^{+153}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\

\mathbf{elif}\;a \leq 1.16 \cdot 10^{+87}:\\
\;\;\;\;\left(1 + b \cdot 2\right) \cdot \left(-1 + b \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot 4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -5.80000000000000004e153

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative0.0%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define0.0%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative0.0%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*0.0%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv0.0%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval0.0%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define0.0%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval0.0%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified0.0%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 0.0%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 100.0%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Taylor expanded in a around 0 100.0%

      \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
    8. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    9. Applied egg-rr100.0%

      \[\leadsto 4 \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]

    if -5.80000000000000004e153 < a < 1.15999999999999996e87

    1. Initial program 90.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+90.6%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative90.6%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
      3. +-commutative90.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg90.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+90.6%

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
      6. +-commutative90.6%

        \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. associate-+l+90.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 77.3%

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around 0 54.3%

      \[\leadsto \color{blue}{4 \cdot {b}^{2}} - 1 \]
    7. Step-by-step derivation
      1. metadata-eval54.3%

        \[\leadsto \color{blue}{\left(2 \cdot 2\right)} \cdot {b}^{2} - 1 \]
      2. unpow254.3%

        \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      3. swap-sqr54.3%

        \[\leadsto \color{blue}{\left(2 \cdot b\right) \cdot \left(2 \cdot b\right)} - 1 \]
      4. unpow254.3%

        \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    8. Simplified54.3%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. unpow254.3%

        \[\leadsto \color{blue}{\left(2 \cdot b\right) \cdot \left(2 \cdot b\right)} - 1 \]
      2. difference-of-sqr-154.3%

        \[\leadsto \color{blue}{\left(2 \cdot b + 1\right) \cdot \left(2 \cdot b - 1\right)} \]
    10. Applied egg-rr54.3%

      \[\leadsto \color{blue}{\left(2 \cdot b + 1\right) \cdot \left(2 \cdot b - 1\right)} \]

    if 1.15999999999999996e87 < a

    1. Initial program 54.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg54.8%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative54.8%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define54.8%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative54.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*54.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv54.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval54.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define54.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval54.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified54.8%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 100.0%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 100.0%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    8. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    9. Taylor expanded in a around 0 95.6%

      \[\leadsto \left(a \cdot a\right) \cdot \left(4 + a \cdot \color{blue}{4}\right) + -1 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{+153}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{elif}\;a \leq 1.16 \cdot 10^{+87}:\\ \;\;\;\;\left(1 + b \cdot 2\right) \cdot \left(-1 + b \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot 4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.8% accurate, 7.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2.1 \cdot 10^{+143}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 2.1e+143)
   (+ -1.0 (* (* a a) (+ 4.0 (* a (+ a 4.0)))))
   (+ -1.0 (* b (* b 4.0)))))
double code(double a, double b) {
	double tmp;
	if (b <= 2.1e+143) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	} else {
		tmp = -1.0 + (b * (b * 4.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 2.1d+143) then
        tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a + 4.0d0))))
    else
        tmp = (-1.0d0) + (b * (b * 4.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 2.1e+143) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	} else {
		tmp = -1.0 + (b * (b * 4.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 2.1e+143:
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))))
	else:
		tmp = -1.0 + (b * (b * 4.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 2.1e+143)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))));
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 2.1e+143)
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + 4.0))));
	else
		tmp = -1.0 + (b * (b * 4.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 2.1e+143], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{+143}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.09999999999999988e143

    1. Initial program 72.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg72.8%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative72.8%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define72.8%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified72.8%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 54.7%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 75.2%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. unpow275.2%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    8. Applied egg-rr75.2%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]

    if 2.09999999999999988e143 < b

    1. Initial program 52.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+52.6%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative52.6%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
      3. +-commutative52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+52.6%

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
      6. +-commutative52.6%

        \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. associate-+l+52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
    3. Simplified52.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 100.0%

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around 0 100.0%

      \[\leadsto \color{blue}{4 \cdot {b}^{2}} - 1 \]
    7. Step-by-step derivation
      1. metadata-eval100.0%

        \[\leadsto \color{blue}{\left(2 \cdot 2\right)} \cdot {b}^{2} - 1 \]
      2. unpow2100.0%

        \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      3. swap-sqr100.0%

        \[\leadsto \color{blue}{\left(2 \cdot b\right) \cdot \left(2 \cdot b\right)} - 1 \]
      4. unpow2100.0%

        \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. unpow-prod-down100.0%

        \[\leadsto \color{blue}{{2}^{2} \cdot {b}^{2}} - 1 \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{4} \cdot {b}^{2} - 1 \]
      3. unpow2100.0%

        \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      4. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
    10. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2.1 \cdot 10^{+143}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.0% accurate, 8.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2.1 \cdot 10^{+143}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 2.1e+143)
   (+ (* (* a a) (+ (* a a) 4.0)) -1.0)
   (+ -1.0 (* b (* b 4.0)))))
double code(double a, double b) {
	double tmp;
	if (b <= 2.1e+143) {
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0;
	} else {
		tmp = -1.0 + (b * (b * 4.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 2.1d+143) then
        tmp = ((a * a) * ((a * a) + 4.0d0)) + (-1.0d0)
    else
        tmp = (-1.0d0) + (b * (b * 4.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 2.1e+143) {
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0;
	} else {
		tmp = -1.0 + (b * (b * 4.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 2.1e+143:
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0
	else:
		tmp = -1.0 + (b * (b * 4.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 2.1e+143)
		tmp = Float64(Float64(Float64(a * a) * Float64(Float64(a * a) + 4.0)) + -1.0);
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 2.1e+143)
		tmp = ((a * a) * ((a * a) + 4.0)) + -1.0;
	else
		tmp = -1.0 + (b * (b * 4.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 2.1e+143], N[(N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{+143}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.09999999999999988e143

    1. Initial program 72.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg72.8%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative72.8%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define72.8%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified72.8%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 54.7%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 75.2%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. unpow275.2%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    8. Applied egg-rr75.2%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    9. Taylor expanded in a around inf 74.2%

      \[\leadsto \left(a \cdot a\right) \cdot \left(4 + a \cdot \color{blue}{a}\right) + -1 \]

    if 2.09999999999999988e143 < b

    1. Initial program 52.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+52.6%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative52.6%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
      3. +-commutative52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+52.6%

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
      6. +-commutative52.6%

        \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. associate-+l+52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
    3. Simplified52.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 100.0%

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around 0 100.0%

      \[\leadsto \color{blue}{4 \cdot {b}^{2}} - 1 \]
    7. Step-by-step derivation
      1. metadata-eval100.0%

        \[\leadsto \color{blue}{\left(2 \cdot 2\right)} \cdot {b}^{2} - 1 \]
      2. unpow2100.0%

        \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      3. swap-sqr100.0%

        \[\leadsto \color{blue}{\left(2 \cdot b\right) \cdot \left(2 \cdot b\right)} - 1 \]
      4. unpow2100.0%

        \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. unpow-prod-down100.0%

        \[\leadsto \color{blue}{{2}^{2} \cdot {b}^{2}} - 1 \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{4} \cdot {b}^{2} - 1 \]
      3. unpow2100.0%

        \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      4. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
    10. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2.1 \cdot 10^{+143}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 60.8% accurate, 10.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.76 \cdot 10^{+143}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 1.76e+143) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* b (* b 4.0)))))
double code(double a, double b) {
	double tmp;
	if (b <= 1.76e+143) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + (b * (b * 4.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 1.76d+143) then
        tmp = (-1.0d0) + ((a * a) * 4.0d0)
    else
        tmp = (-1.0d0) + (b * (b * 4.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 1.76e+143) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + (b * (b * 4.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 1.76e+143:
		tmp = -1.0 + ((a * a) * 4.0)
	else:
		tmp = -1.0 + (b * (b * 4.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 1.76e+143)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0));
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 1.76e+143)
		tmp = -1.0 + ((a * a) * 4.0);
	else
		tmp = -1.0 + (b * (b * 4.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 1.76e+143], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.76 \cdot 10^{+143}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.75999999999999989e143

    1. Initial program 72.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg72.8%

        \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
      2. +-commutative72.8%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define72.8%

        \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      4. +-commutative72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      5. associate-*l*72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      6. cancel-sign-sub-inv72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      7. metadata-eval72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
      8. fma-define72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
      9. metadata-eval72.8%

        \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
    3. Simplified72.8%

      \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 54.7%

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
    6. Taylor expanded in a around 0 75.2%

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
    7. Taylor expanded in a around 0 52.8%

      \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
    8. Step-by-step derivation
      1. unpow275.2%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
    9. Applied egg-rr52.8%

      \[\leadsto 4 \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]

    if 1.75999999999999989e143 < b

    1. Initial program 52.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+52.6%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative52.6%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
      3. +-commutative52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+52.6%

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
      6. +-commutative52.6%

        \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. associate-+l+52.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
    3. Simplified52.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 100.0%

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around 0 100.0%

      \[\leadsto \color{blue}{4 \cdot {b}^{2}} - 1 \]
    7. Step-by-step derivation
      1. metadata-eval100.0%

        \[\leadsto \color{blue}{\left(2 \cdot 2\right)} \cdot {b}^{2} - 1 \]
      2. unpow2100.0%

        \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      3. swap-sqr100.0%

        \[\leadsto \color{blue}{\left(2 \cdot b\right) \cdot \left(2 \cdot b\right)} - 1 \]
      4. unpow2100.0%

        \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. unpow-prod-down100.0%

        \[\leadsto \color{blue}{{2}^{2} \cdot {b}^{2}} - 1 \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{4} \cdot {b}^{2} - 1 \]
      3. unpow2100.0%

        \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      4. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
    10. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.76 \cdot 10^{+143}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 51.7% accurate, 18.6× speedup?

\[\begin{array}{l} \\ -1 + \left(a \cdot a\right) \cdot 4 \end{array} \]
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
	return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
	return -1.0 + ((a * a) * 4.0);
}
def code(a, b):
	return -1.0 + ((a * a) * 4.0)
function code(a, b)
	return Float64(-1.0 + Float64(Float64(a * a) * 4.0))
end
function tmp = code(a, b)
	tmp = -1.0 + ((a * a) * 4.0);
end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. sub-neg69.8%

      \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
    2. +-commutative69.8%

      \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
    3. fma-define71.4%

      \[\leadsto \left(4 \cdot \color{blue}{\mathsf{fma}\left(a \cdot a, 1 + a, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
    4. +-commutative71.4%

      \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, \color{blue}{a + 1}, \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
    5. associate-*l*71.4%

      \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \color{blue}{b \cdot \left(b \cdot \left(1 - 3 \cdot a\right)\right)}\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
    6. cancel-sign-sub-inv71.4%

      \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \color{blue}{\left(1 + \left(-3\right) \cdot a\right)}\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
    7. metadata-eval71.4%

      \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + \color{blue}{-3} \cdot a\right)\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + \left(-1\right) \]
    8. fma-define71.4%

      \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2}\right) + \left(-1\right) \]
    9. metadata-eval71.4%

      \[\leadsto \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + \color{blue}{-1} \]
  3. Simplified71.4%

    \[\leadsto \color{blue}{\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + -3 \cdot a\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
  4. Add Preprocessing
  5. Taylor expanded in b around 0 50.5%

    \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right) + {a}^{4}\right)} + -1 \]
  6. Taylor expanded in a around 0 71.5%

    \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right)} + -1 \]
  7. Taylor expanded in a around 0 49.6%

    \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
  8. Step-by-step derivation
    1. unpow271.5%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(4 + a \cdot \left(4 + a\right)\right) + -1 \]
  9. Applied egg-rr49.6%

    \[\leadsto 4 \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
  10. Final simplification49.6%

    \[\leadsto -1 + \left(a \cdot a\right) \cdot 4 \]
  11. Add Preprocessing

Alternative 9: 24.8% accurate, 130.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
	return -1.0;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -1.0d0
end function
public static double code(double a, double b) {
	return -1.0;
}
def code(a, b):
	return -1.0
function code(a, b)
	return -1.0
end
function tmp = code(a, b)
	tmp = -1.0;
end
code[a_, b_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+69.8%

      \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right)} \]
    2. +-commutative69.8%

      \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. +-commutative69.8%

      \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
    4. sub-neg69.8%

      \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
    5. associate-+l+69.8%

      \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \left(\left(-1\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right)} \]
    6. +-commutative69.8%

      \[\leadsto 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
    7. associate-+l+69.8%

      \[\leadsto \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + \left(-1\right)} \]
  3. Simplified70.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
  4. Add Preprocessing
  5. Taylor expanded in a around 0 67.4%

    \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
  6. Taylor expanded in b around 0 20.7%

    \[\leadsto \color{blue}{-1} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024138 
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (25)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))