Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.5% → 98.5%
Time: 7.6s
Alternatives: 11
Speedup: 1.2×

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 11 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: 74.5% 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.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+106}:\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.00000000000000018e106

    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. associate--l+0.0%

        \[\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. fma-def0.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified4.4%

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

      \[\leadsto \color{blue}{{a}^{4}} \]

    if -2.00000000000000018e106 < a

    1. Initial program 85.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+85.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. fma-def85.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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified85.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)\right)} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right) \]
      9. expm1-udef83.4%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)} - 1\right)} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right) \]
    5. Applied egg-rr83.4%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)} - 1\right)} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right) \]
    6. Step-by-step derivation
      1. expm1-def83.4%

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \color{blue}{{a}^{3}} - 1\right) \]
    9. Step-by-step derivation
      1. unpow398.4%

        \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} - 1\right) \]
    10. Applied egg-rr98.4%

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

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

Alternative 2: 98.1% 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}:\\ \;\;\;\;{a}^{4} + \left(4 \cdot \left(a \cdot a\right) + -1\right)\\ \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)
     (+ (pow a 4.0) (+ (* 4.0 (* a a)) -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 = pow(a, 4.0) + ((4.0 * (a * a)) + -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 = Math.pow(a, 4.0) + ((4.0 * (a * a)) + -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 = math.pow(a, 4.0) + ((4.0 * (a * a)) + -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((a ^ 4.0) + Float64(Float64(4.0 * Float64(a * a)) + -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 ^ 4.0) + ((4.0 * (a * a)) + -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[Power[a, 4.0], $MachinePrecision] + N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $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}:\\
\;\;\;\;{a}^{4} + \left(4 \cdot \left(a \cdot a\right) + -1\right)\\


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

    1. Initial program 99.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(1 - 3 \cdot a\right)\right)\right) - 1 \]

    if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.f64 3 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. associate--l+0.0%

        \[\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. fma-def0.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified2.6%

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

      \[\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+35.9%

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

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

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

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

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

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

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

    \[\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}:\\ \;\;\;\;{a}^{4} + \left(4 \cdot \left(a \cdot a\right) + -1\right)\\ \end{array} \]

Alternative 3: 93.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 400000000:\\ \;\;\;\;{a}^{4} + \left(4 \cdot \left(a \cdot a\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 400000000.0)
   (+ (pow a 4.0) (+ (* 4.0 (* a a)) -1.0))
   (pow b 4.0)))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 400000000.0) {
		tmp = pow(a, 4.0) + ((4.0 * (a * a)) + -1.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 * b) <= 400000000.0d0) then
        tmp = (a ** 4.0d0) + ((4.0d0 * (a * a)) + (-1.0d0))
    else
        tmp = b ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 400000000.0) {
		tmp = Math.pow(a, 4.0) + ((4.0 * (a * a)) + -1.0);
	} else {
		tmp = Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 400000000.0:
		tmp = math.pow(a, 4.0) + ((4.0 * (a * a)) + -1.0)
	else:
		tmp = math.pow(b, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 400000000.0)
		tmp = Float64((a ^ 4.0) + Float64(Float64(4.0 * Float64(a * a)) + -1.0));
	else
		tmp = b ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 400000000.0)
		tmp = (a ^ 4.0) + ((4.0 * (a * a)) + -1.0);
	else
		tmp = b ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}

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

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


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

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

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified76.6%

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

      \[\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.5%

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

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

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

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

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

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

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

    if 4e8 < (*.f64 b b)

    1. Initial program 63.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. associate--l+63.0%

        \[\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. fma-def63.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified64.6%

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

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

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

Alternative 4: 67.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_0 := -1 + 4 \cdot \left(a \cdot a + a \cdot \left(a \cdot a\right)\right)\\
\mathbf{if}\;a \leq -2.4:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq -3 \cdot 10^{-101}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;a \leq -5.4 \cdot 10^{-155}:\\
\;\;\;\;a \cdot \left(b \cdot \left(b \cdot -12\right)\right)\\

\mathbf{elif}\;a \leq 0.08:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -2.39999999999999991 or 0.0800000000000000017 < a

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

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

      \[\leadsto \color{blue}{{a}^{4}} \]

    if -2.39999999999999991 < a < -3.0000000000000003e-101 or -5.39999999999999962e-155 < a < 0.0800000000000000017

    1. Initial program 99.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+99.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. fma-def99.8%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified99.8%

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

      \[\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+50.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} - 1\right) \]
    11. Applied egg-rr48.8%

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

    if -3.0000000000000003e-101 < a < -5.39999999999999962e-155

    1. Initial program 100.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. associate--l+100.0%

        \[\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. fma-def100.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{b}^{2} \cdot \left(a \cdot -12 + 2 \cdot {a}^{2}\right)} \]
      5. *-commutative67.9%

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(2 \cdot \color{blue}{\left(a \cdot a\right)} + -12 \cdot a\right) \]
      9. associate-*r*67.9%

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(\color{blue}{\left(a \cdot 2\right)} \cdot a + -12 \cdot a\right) \]
      11. distribute-rgt-out67.9%

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

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

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot \left(2 \cdot a + -12\right)\right)} \]
    10. Taylor expanded in a around 0 67.9%

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

        \[\leadsto -12 \cdot \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
    12. Simplified67.9%

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

      \[\leadsto \color{blue}{-12 \cdot \left(a \cdot {b}^{2}\right)} \]
    14. Step-by-step derivation
      1. *-commutative67.9%

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

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

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

        \[\leadsto a \cdot \color{blue}{\left(b \cdot \left(b \cdot -12\right)\right)} \]
    15. Simplified78.4%

      \[\leadsto \color{blue}{a \cdot \left(b \cdot \left(b \cdot -12\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2.4:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -3 \cdot 10^{-101}:\\ \;\;\;\;-1 + 4 \cdot \left(a \cdot a + a \cdot \left(a \cdot a\right)\right)\\ \mathbf{elif}\;a \leq -5.4 \cdot 10^{-155}:\\ \;\;\;\;a \cdot \left(b \cdot \left(b \cdot -12\right)\right)\\ \mathbf{elif}\;a \leq 0.08:\\ \;\;\;\;-1 + 4 \cdot \left(a \cdot a + a \cdot \left(a \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 5: 82.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 400000000:\\ \;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 400000000.0) (+ (* 4.0 (* a a)) -1.0) (pow b 4.0)))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 400000000.0) {
		tmp = (4.0 * (a * a)) + -1.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 * b) <= 400000000.0d0) then
        tmp = (4.0d0 * (a * a)) + (-1.0d0)
    else
        tmp = b ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 400000000.0) {
		tmp = (4.0 * (a * a)) + -1.0;
	} else {
		tmp = Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 400000000.0:
		tmp = (4.0 * (a * a)) + -1.0
	else:
		tmp = math.pow(b, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 400000000.0)
		tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0);
	else
		tmp = b ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 400000000.0)
		tmp = (4.0 * (a * a)) + -1.0;
	else
		tmp = b ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}

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

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


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

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

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified76.6%

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

      \[\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.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4e8 < (*.f64 b b)

    1. Initial program 63.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. associate--l+63.0%

        \[\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. fma-def63.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified64.6%

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

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

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

Alternative 6: 62.2% accurate, 10.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 1e-34) (+ (* 4.0 (* a a)) -1.0) (* 2.0 (* b (* b (* a a))))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e-34) {
		tmp = (4.0 * (a * a)) + -1.0;
	} else {
		tmp = 2.0 * (b * (b * (a * a)));
	}
	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-34) then
        tmp = (4.0d0 * (a * a)) + (-1.0d0)
    else
        tmp = 2.0d0 * (b * (b * (a * a)))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e-34) {
		tmp = (4.0 * (a * a)) + -1.0;
	} else {
		tmp = 2.0 * (b * (b * (a * a)));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 1e-34:
		tmp = (4.0 * (a * a)) + -1.0
	else:
		tmp = 2.0 * (b * (b * (a * a)))
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 1e-34)
		tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0);
	else
		tmp = Float64(2.0 * Float64(b * Float64(b * Float64(a * a))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 1e-34)
		tmp = (4.0 * (a * a)) + -1.0;
	else
		tmp = 2.0 * (b * (b * (a * a)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-34], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 9.99999999999999928e-35

    1. Initial program 77.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+77.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. fma-def77.6%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified77.6%

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

      \[\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+78.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999928e-35 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\left({b}^{2} \cdot {a}^{2}\right)} \]
      2. unpow257.4%

        \[\leadsto 2 \cdot \left(\color{blue}{\left(b \cdot b\right)} \cdot {a}^{2}\right) \]
      3. associate-*l*49.3%

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

        \[\leadsto 2 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a \cdot a\right)}\right)\right) \]
    9. Simplified49.3%

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

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

Alternative 7: 65.4% accurate, 10.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 1e-34) (+ (* 4.0 (* a a)) -1.0) (* (* b b) (* (* a a) 2.0))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e-34) {
		tmp = (4.0 * (a * a)) + -1.0;
	} else {
		tmp = (b * b) * ((a * a) * 2.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-34) then
        tmp = (4.0d0 * (a * a)) + (-1.0d0)
    else
        tmp = (b * b) * ((a * a) * 2.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e-34) {
		tmp = (4.0 * (a * a)) + -1.0;
	} else {
		tmp = (b * b) * ((a * a) * 2.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 1e-34:
		tmp = (4.0 * (a * a)) + -1.0
	else:
		tmp = (b * b) * ((a * a) * 2.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 1e-34)
		tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0);
	else
		tmp = Float64(Float64(b * b) * Float64(Float64(a * a) * 2.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 1e-34)
		tmp = (4.0 * (a * a)) + -1.0;
	else
		tmp = (b * b) * ((a * a) * 2.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-34], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 9.99999999999999928e-35

    1. Initial program 77.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+77.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. fma-def77.6%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified77.6%

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

      \[\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+78.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999928e-35 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left({a}^{2} \cdot {b}^{2}\right)} \]
    8. Step-by-step derivation
      1. associate-*r*57.4%

        \[\leadsto \color{blue}{\left(2 \cdot {a}^{2}\right) \cdot {b}^{2}} \]
      2. unpow257.4%

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

        \[\leadsto \left(2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    9. Simplified57.4%

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

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

Alternative 8: 39.6% accurate, 11.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 7.5 \cdot 10^{-28}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 7.5000000000000003e-28

    1. Initial program 77.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+77.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. fma-def77.6%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified77.6%

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

      \[\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+78.5%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 7.5000000000000003e-28 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(2 \cdot \color{blue}{\left(a \cdot a\right)} + -12 \cdot a\right) \]
      9. associate-*r*56.4%

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

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

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

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

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot \left(2 \cdot a + -12\right)\right)} \]
    10. Taylor expanded in a around 0 28.1%

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

        \[\leadsto -12 \cdot \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
    12. Simplified28.1%

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

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

Alternative 9: 33.0% accurate, 14.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2.7 \cdot 10^{-14}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(b \cdot \left(b \cdot -12\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 2.7e-14) -1.0 (* a (* b (* b -12.0)))))
double code(double a, double b) {
	double tmp;
	if (b <= 2.7e-14) {
		tmp = -1.0;
	} else {
		tmp = a * (b * (b * -12.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.7d-14) then
        tmp = -1.0d0
    else
        tmp = a * (b * (b * (-12.0d0)))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 2.7e-14) {
		tmp = -1.0;
	} else {
		tmp = a * (b * (b * -12.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 2.7e-14:
		tmp = -1.0
	else:
		tmp = a * (b * (b * -12.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 2.7e-14)
		tmp = -1.0;
	else
		tmp = Float64(a * Float64(b * Float64(b * -12.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 2.7e-14)
		tmp = -1.0;
	else
		tmp = a * (b * (b * -12.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 2.7e-14], -1.0, N[(a * N[(b * N[(b * -12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-14}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.6999999999999999e-14

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

        \[\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. fma-def73.2%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified74.2%

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right)} \]
    4. Taylor expanded in b around 0 57.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+57.8%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 2.6999999999999999e-14 < b

    1. Initial program 57.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. associate--l+57.0%

        \[\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. fma-def57.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified57.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{b}^{2} \cdot \left(a \cdot -12 + 2 \cdot {a}^{2}\right)} \]
      5. *-commutative65.8%

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(2 \cdot \color{blue}{\left(a \cdot a\right)} + -12 \cdot a\right) \]
      9. associate-*r*65.8%

        \[\leadsto \left(b \cdot b\right) \cdot \left(\color{blue}{\left(2 \cdot a\right) \cdot a} + -12 \cdot a\right) \]
      10. *-commutative65.8%

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot \left(a \cdot 2 + -12\right)\right)} \]
      12. *-commutative65.8%

        \[\leadsto \left(b \cdot b\right) \cdot \left(a \cdot \left(\color{blue}{2 \cdot a} + -12\right)\right) \]
    9. Simplified65.8%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot \left(2 \cdot a + -12\right)\right)} \]
    10. Taylor expanded in a around 0 29.2%

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

        \[\leadsto -12 \cdot \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
    12. Simplified29.2%

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

      \[\leadsto \color{blue}{-12 \cdot \left(a \cdot {b}^{2}\right)} \]
    14. Step-by-step derivation
      1. *-commutative29.2%

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

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

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

        \[\leadsto a \cdot \color{blue}{\left(b \cdot \left(b \cdot -12\right)\right)} \]
    15. Simplified29.2%

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

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

Alternative 10: 53.2% accurate, 14.3× speedup?

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

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

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


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

    1. Initial program 70.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+70.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. fma-def70.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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified71.0%

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right)} \]
    4. Taylor expanded in b around 0 55.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+55.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(4 \cdot {a}^{2} + 4 \cdot {a}^{3}\right) + \left(-1\right)} \]
      2. distribute-lft-out41.7%

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

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

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

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

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

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

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

    if 1.05999999999999994e203 < b

    1. Initial program 70.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. associate--l+70.0%

        \[\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. fma-def70.0%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \left(2 \cdot {a}^{2} + -12 \cdot a\right) \]
      8. unpow265.0%

        \[\leadsto \left(b \cdot b\right) \cdot \left(2 \cdot \color{blue}{\left(a \cdot a\right)} + -12 \cdot a\right) \]
      9. associate-*r*65.0%

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(a \cdot \left(\color{blue}{2 \cdot a} + -12\right)\right) \]
    9. Simplified65.0%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot \left(2 \cdot a + -12\right)\right)} \]
    10. Taylor expanded in a around 0 40.0%

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

        \[\leadsto -12 \cdot \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
    12. Simplified40.0%

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

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

Alternative 11: 25.1% 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 70.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+70.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. fma-def70.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(1 - 3 \cdot a\right)\right) - 1\right) \]
  3. Simplified70.9%

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

    \[\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+53.1%

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification22.5%

    \[\leadsto -1 \]

Reproduce

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