Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.9% → 92.0%
Time: 8.7s
Alternatives: 7
Speedup: 8.5×

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(3 + 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) (+ 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) * (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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + 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 7 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.9% 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(3 + 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) (+ 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) * (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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}

Alternative 1: 92.0% accurate, 1.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 1.00000000000000004e154

    1. Initial program 77.7%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+77.7%

        \[\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(3 + a\right)\right) - 1\right)} \]
      2. fma-def77.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} + \left(4 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right)\right) - 1\right) \]
    6. Simplified77.0%

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

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

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

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

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

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

    if 1.00000000000000004e154 < (*.f64 b b)

    1. Initial program 51.5%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg51.5%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def51.5%

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

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

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

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

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

      \[\leadsto \color{blue}{{b}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

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

Alternative 2: 92.0% accurate, 1.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 1.00000000000000004e154

    1. Initial program 77.7%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+77.7%

        \[\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(3 + a\right)\right) - 1\right)} \]
      2. fma-def77.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} + \left(4 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right)\right) - 1\right) \]
    6. Simplified77.0%

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

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

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

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

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

      \[\leadsto {a}^{4} + \left(\color{blue}{a \cdot \left(a \cdot 4\right)} - 1\right) \]
    10. Step-by-step derivation
      1. associate-+r-94.6%

        \[\leadsto \color{blue}{\left({a}^{4} + a \cdot \left(a \cdot 4\right)\right) - 1} \]
      2. sqr-pow94.5%

        \[\leadsto \left(\color{blue}{{a}^{\left(\frac{4}{2}\right)} \cdot {a}^{\left(\frac{4}{2}\right)}} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      3. metadata-eval94.5%

        \[\leadsto \left({a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      4. pow294.5%

        \[\leadsto \left(\color{blue}{\left(a \cdot a\right)} \cdot {a}^{\left(\frac{4}{2}\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      5. metadata-eval94.5%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      7. associate-*r*94.5%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(a \cdot a\right) \cdot 4}\right) - 1 \]
      8. distribute-lft-out94.5%

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

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

    if 1.00000000000000004e154 < (*.f64 b b)

    1. Initial program 51.5%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg51.5%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def51.5%

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

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

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

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

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

      \[\leadsto \color{blue}{{b}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

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

Alternative 3: 83.6% accurate, 8.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2.00000000000000012e290

    1. Initial program 73.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg73.1%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def73.1%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. metadata-eval86.4%

        \[\leadsto {a}^{\color{blue}{\left(2 + 2\right)}} + -1 \]
      2. pow-prod-up86.4%

        \[\leadsto \color{blue}{{a}^{2} \cdot {a}^{2}} + -1 \]
      3. pow286.4%

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

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      5. fma-def86.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)} \]
    6. Applied egg-rr86.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot a, a \cdot a, -1\right)} \]
    7. Step-by-step derivation
      1. fma-udef86.4%

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

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

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

    if 2.00000000000000012e290 < (*.f64 b b)

    1. Initial program 51.4%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg51.4%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def51.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+38.6%

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

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

        \[\leadsto \left({b}^{4} + \left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right)\right) + -1 \]
      4. distribute-rgt-out65.7%

        \[\leadsto \left({b}^{4} + \color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)}\right) + -1 \]
      5. unpow265.7%

        \[\leadsto \left({b}^{4} + \color{blue}{\left(b \cdot b\right)} \cdot \left(12 + 4 \cdot a\right)\right) + -1 \]
    6. Simplified65.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \mathsf{fma}\left(a, 4, 12\right) + -1 \]
    9. Simplified62.0%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(a, 4, 12\right)} + -1 \]
    10. Taylor expanded in a around 0 96.3%

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    11. Step-by-step derivation
      1. unpow296.3%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
      2. *-commutative96.3%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 12} + -1 \]
      3. associate-*l*96.3%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    12. Simplified96.3%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    13. Taylor expanded in b around 0 96.3%

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    14. Step-by-step derivation
      1. unpow296.3%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
    15. Simplified96.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+290}:\\ \;\;\;\;\left(1 + a \cdot a\right) \cdot \left(a \cdot a + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\ \end{array} \]

Alternative 4: 83.7% accurate, 8.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2.00000000000000012e290

    1. Initial program 73.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+73.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(3 + a\right)\right) - 1\right)} \]
      2. fma-def73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} + \left(\color{blue}{a \cdot \left(a \cdot 4\right)} - 1\right) \]
    9. Simplified86.5%

      \[\leadsto {a}^{4} + \left(\color{blue}{a \cdot \left(a \cdot 4\right)} - 1\right) \]
    10. Step-by-step derivation
      1. associate-+r-86.5%

        \[\leadsto \color{blue}{\left({a}^{4} + a \cdot \left(a \cdot 4\right)\right) - 1} \]
      2. sqr-pow86.5%

        \[\leadsto \left(\color{blue}{{a}^{\left(\frac{4}{2}\right)} \cdot {a}^{\left(\frac{4}{2}\right)}} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      3. metadata-eval86.5%

        \[\leadsto \left({a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      4. pow286.5%

        \[\leadsto \left(\color{blue}{\left(a \cdot a\right)} \cdot {a}^{\left(\frac{4}{2}\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      5. metadata-eval86.5%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      7. associate-*r*86.5%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(a \cdot a\right) \cdot 4}\right) - 1 \]
      8. distribute-lft-out86.5%

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

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

    if 2.00000000000000012e290 < (*.f64 b b)

    1. Initial program 51.4%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg51.4%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def51.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+38.6%

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

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

        \[\leadsto \left({b}^{4} + \left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right)\right) + -1 \]
      4. distribute-rgt-out65.7%

        \[\leadsto \left({b}^{4} + \color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)}\right) + -1 \]
      5. unpow265.7%

        \[\leadsto \left({b}^{4} + \color{blue}{\left(b \cdot b\right)} \cdot \left(12 + 4 \cdot a\right)\right) + -1 \]
    6. Simplified65.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \mathsf{fma}\left(a, 4, 12\right) + -1 \]
    9. Simplified62.0%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(a, 4, 12\right)} + -1 \]
    10. Taylor expanded in a around 0 96.3%

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    11. Step-by-step derivation
      1. unpow296.3%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
      2. *-commutative96.3%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 12} + -1 \]
      3. associate-*l*96.3%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    12. Simplified96.3%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    13. Taylor expanded in b around 0 96.3%

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    14. Step-by-step derivation
      1. unpow296.3%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
    15. Simplified96.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+290}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\ \end{array} \]

Alternative 5: 69.4% accurate, 11.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2.0000000000000001e281

    1. Initial program 73.3%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+73.3%

        \[\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(3 + a\right)\right) - 1\right)} \]
      2. fma-def73.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} + \left(4 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right)\right) - 1\right) \]
    6. Simplified68.0%

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

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

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

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

        \[\leadsto {a}^{4} + \left(\color{blue}{a \cdot \left(a \cdot 4\right)} - 1\right) \]
    9. Simplified86.9%

      \[\leadsto {a}^{4} + \left(\color{blue}{a \cdot \left(a \cdot 4\right)} - 1\right) \]
    10. Step-by-step derivation
      1. associate-+r-86.9%

        \[\leadsto \color{blue}{\left({a}^{4} + a \cdot \left(a \cdot 4\right)\right) - 1} \]
      2. sqr-pow86.9%

        \[\leadsto \left(\color{blue}{{a}^{\left(\frac{4}{2}\right)} \cdot {a}^{\left(\frac{4}{2}\right)}} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      3. metadata-eval86.9%

        \[\leadsto \left({a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      4. pow286.9%

        \[\leadsto \left(\color{blue}{\left(a \cdot a\right)} \cdot {a}^{\left(\frac{4}{2}\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      5. metadata-eval86.9%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + a \cdot \left(a \cdot 4\right)\right) - 1 \]
      7. associate-*r*86.9%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(a \cdot a\right) \cdot 4}\right) - 1 \]
      8. distribute-lft-out86.9%

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

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

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

        \[\leadsto 4 \cdot \color{blue}{\left(a \cdot a\right)} - 1 \]
    14. Simplified74.2%

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

    if 2.0000000000000001e281 < (*.f64 b b)

    1. Initial program 51.4%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg51.4%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def51.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+38.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \mathsf{fma}\left(a, 4, 12\right) + -1 \]
    9. Simplified60.4%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(a, 4, 12\right)} + -1 \]
    10. Taylor expanded in a around 0 93.9%

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    11. Step-by-step derivation
      1. unpow293.9%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
      2. *-commutative93.9%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 12} + -1 \]
      3. associate-*l*93.9%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    12. Simplified93.9%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    13. Taylor expanded in b around 0 93.9%

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    14. Step-by-step derivation
      1. unpow293.9%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
    15. Simplified93.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+281}:\\ \;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\ \end{array} \]

Alternative 6: 52.0% accurate, 18.3× speedup?

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

\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Derivation
  1. Initial program 67.2%

    \[\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(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. sub-neg67.2%

      \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
    2. fma-def67.2%

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

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

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

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

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

    \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
  5. Step-by-step derivation
    1. associate-+r+52.2%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(a, 4, 12\right)} + -1 \]
  10. Taylor expanded in a around 0 57.0%

    \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
  11. Step-by-step derivation
    1. unpow257.0%

      \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
    2. *-commutative57.0%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 12} + -1 \]
    3. associate-*l*57.0%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
  12. Simplified57.0%

    \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
  13. Taylor expanded in b around 0 57.0%

    \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
  14. Step-by-step derivation
    1. unpow257.0%

      \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
  15. Simplified57.0%

    \[\leadsto \color{blue}{12 \cdot \left(b \cdot b\right)} + -1 \]
  16. Final simplification57.0%

    \[\leadsto \left(b \cdot b\right) \cdot 12 + -1 \]

Alternative 7: 24.9% accurate, 128.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 67.2%

    \[\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(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. sub-neg67.2%

      \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
    2. fma-def67.2%

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

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

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

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

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

    \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  5. Taylor expanded in a around 0 29.4%

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification29.4%

    \[\leadsto -1 \]

Reproduce

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