Bouland and Aaronson, Equation (24)

Percentage Accurate: 74.0% → 98.2%
Time: 6.7s
Alternatives: 11
Speedup: 8.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.0% accurate, 1.0× speedup?

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

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

Alternative 1: 98.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\ \;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<=
      (+
       (pow (+ (* a a) (* b b)) 2.0)
       (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
      INFINITY)
   (+
    (pow (hypot a b) 4.0)
    (fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
   (+ -1.0 (pow a 4.0))))
double code(double a, double b) {
	double tmp;
	if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
		tmp = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
	} else {
		tmp = -1.0 + pow(a, 4.0);
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (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(a + 3.0))))) <= Inf)
		tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0));
	else
		tmp = Float64(-1.0 + (a ^ 4.0));
	end
	return tmp
end
code[a_, b_] := If[LessEqual[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[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\

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


\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 3 a))))) < +inf.0

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) \leq \infty:\\ \;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\ \mathbf{if}\;t_0 \leq \infty:\\ \;\;\;\;t_0 + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0
         (+
          (pow (+ (* a a) (* b b)) 2.0)
          (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
   (if (<= t_0 INFINITY) (+ t_0 -1.0) (+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
	double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0 + -1.0;
	} else {
		tmp = -1.0 + pow(a, 4.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) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0 + -1.0;
	} else {
		tmp = -1.0 + Math.pow(a, 4.0);
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0 + -1.0
	else:
		tmp = -1.0 + math.pow(a, 4.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(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0)))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = Float64(t_0 + -1.0);
	else
		tmp = Float64(-1.0 + (a ^ 4.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0 + -1.0;
	else
		tmp = -1.0 + (a ^ 4.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[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[Power[a, 4.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(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\

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


\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 3 a))))) < +inf.0

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

Alternative 3: 93.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 150:\\
\;\;\;\;-1 + {a}^{4}\\

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]

    if 150 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 126:\\
\;\;\;\;-1 + {a}^{4}\\

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]

    if 126 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{12 \cdot \left(b \cdot b\right)} + {b}^{4}\right) + -1 \]
    10. Step-by-step derivation
      1. sqr-pow89.1%

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

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

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

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

        \[\leadsto \left(12 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) + -1 \]
      6. distribute-rgt-out89.1%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(12 + b \cdot b\right)} + -1 \]
    11. Applied egg-rr89.1%

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

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

Alternative 5: 93.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 1000000:\\
\;\;\;\;-1 + {a}^{4}\\

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


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

    1. Initial program 84.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]

    if 1e6 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

Alternative 6: 88.3% accurate, 6.7× speedup?

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

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

\mathbf{elif}\;a \leq 3.9 \cdot 10^{+130}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\

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


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

    1. Initial program 63.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \left(-\color{blue}{{\left(a \cdot 2\right)}^{2}}\right) \cdot a\right) + -1 \]
      15. distribute-lft-neg-in92.9%

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

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \left(-\color{blue}{a \cdot {\left(a \cdot 2\right)}^{2}}\right)\right) + -1 \]
      17. distribute-lft-neg-out92.9%

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \color{blue}{\left(-a\right) \cdot {\left(a \cdot 2\right)}^{2}}\right) + -1 \]
      18. distribute-rgt-in92.9%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 2\right) \cdot \left(a \cdot 2\right)\right)} \cdot \left(1 + \left(-a\right)\right) + -1 \]
      20. swap-sqr92.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot \left(2 \cdot 2\right)\right)} \cdot \left(1 + \left(-a\right)\right) + -1 \]
      21. metadata-eval92.9%

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

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

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

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

        \[\leadsto 4 \cdot \left(1 \cdot \left(a \cdot a\right) - \color{blue}{a \cdot \left(a \cdot a\right)}\right) + -1 \]
      3. distribute-rgt-out--92.9%

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

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

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

        \[\leadsto \left(4 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\frac{1 \cdot 1 - a \cdot a}{1 + a}} + -1 \]
      3. associate-*r/97.5%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(1 - a \cdot a\right) \cdot \left(\left(a \cdot a\right) \cdot 4\right)}}{a + 1} + -1 \]
      2. associate-*l*97.5%

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

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

    if -8.8000000000000005e74 < a < 3.9000000000000002e130

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{12 \cdot \left(b \cdot b\right)} + {b}^{4}\right) + -1 \]
    10. Step-by-step derivation
      1. sqr-pow87.5%

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

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

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

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

        \[\leadsto \left(12 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) + -1 \]
      6. distribute-rgt-out87.5%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(12 + b \cdot b\right)} + -1 \]
    11. Applied egg-rr87.5%

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

    if 3.9000000000000002e130 < 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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -8.8 \cdot 10^{+74}:\\ \;\;\;\;-1 + \frac{\left(1 - a \cdot a\right) \cdot \left(a \cdot \left(a \cdot 4\right)\right)}{a + 1}\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{+130}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \end{array} \]

Alternative 7: 86.3% accurate, 8.5× speedup?

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

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

\mathbf{elif}\;a \leq 3.9 \cdot 10^{+130}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\

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


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

    1. Initial program 63.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \left(-\color{blue}{{\left(a \cdot 2\right)}^{2}}\right) \cdot a\right) + -1 \]
      15. distribute-lft-neg-in92.9%

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

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \left(-\color{blue}{a \cdot {\left(a \cdot 2\right)}^{2}}\right)\right) + -1 \]
      17. distribute-lft-neg-out92.9%

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \color{blue}{\left(-a\right) \cdot {\left(a \cdot 2\right)}^{2}}\right) + -1 \]
      18. distribute-rgt-in92.9%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 2\right) \cdot \left(a \cdot 2\right)\right)} \cdot \left(1 + \left(-a\right)\right) + -1 \]
      20. swap-sqr92.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot \left(2 \cdot 2\right)\right)} \cdot \left(1 + \left(-a\right)\right) + -1 \]
      21. metadata-eval92.9%

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

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

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

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

        \[\leadsto 4 \cdot \left(1 \cdot \left(a \cdot a\right) - \color{blue}{a \cdot \left(a \cdot a\right)}\right) + -1 \]
      3. distribute-rgt-out--92.9%

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

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

    if -8.8000000000000005e74 < a < 3.9000000000000002e130

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{12 \cdot \left(b \cdot b\right)} + {b}^{4}\right) + -1 \]
    10. Step-by-step derivation
      1. sqr-pow87.5%

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

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

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

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

        \[\leadsto \left(12 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) + -1 \]
      6. distribute-rgt-out87.5%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(12 + b \cdot b\right)} + -1 \]
    11. Applied egg-rr87.5%

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

    if 3.9000000000000002e130 < 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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 71.8% accurate, 9.8× speedup?

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

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

\mathbf{elif}\;a \leq 6.2 \cdot 10^{+124}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\

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


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

    1. Initial program 64.1%

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

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

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

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

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

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

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

      \[\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-*r*97.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \left(-\left(a \cdot a\right) \cdot \color{blue}{\left(2 \cdot 2\right)}\right) \cdot a\right) + -1 \]
      13. swap-sqr90.7%

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

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

        \[\leadsto \left(1 \cdot {\left(a \cdot 2\right)}^{2} + \color{blue}{\left(-{\left(a \cdot 2\right)}^{2} \cdot a\right)}\right) + -1 \]
      16. *-commutative90.7%

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

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

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 2\right) \cdot \left(a \cdot 2\right)\right)} \cdot \left(1 + \left(-a\right)\right) + -1 \]
      20. swap-sqr90.7%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot \left(2 \cdot 2\right)\right)} \cdot \left(1 + \left(-a\right)\right) + -1 \]
      21. metadata-eval90.7%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \color{blue}{4}\right) \cdot \left(1 + \left(-a\right)\right) + -1 \]
      22. sub-neg90.7%

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

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

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

        \[\leadsto 4 \cdot \left(1 \cdot \left(a \cdot a\right) - \color{blue}{a \cdot \left(a \cdot a\right)}\right) + -1 \]
      3. distribute-rgt-out--90.7%

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

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

    if -7.5999999999999997e74 < a < 6.2000000000000004e124

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(12 \cdot \left(b \cdot b\right) + \color{blue}{{b}^{\left(\frac{4}{2}\right)} \cdot {b}^{\left(\frac{4}{2}\right)}}\right) + -1 \]
      2. metadata-eval87.8%

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

        \[\leadsto \left(12 \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right)} \cdot {b}^{\left(\frac{4}{2}\right)}\right) + -1 \]
      4. metadata-eval87.8%

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

        \[\leadsto \left(12 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) + -1 \]
      6. distribute-rgt-out87.8%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(12 + b \cdot b\right)} + -1 \]
    11. Applied egg-rr87.8%

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

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

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

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

    if 6.2000000000000004e124 < 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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 69.2% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

      \[\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-*r*61.7%

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

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

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

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

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

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

    if 1.4999999999999999e307 < (*.f64 b b)

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{12 \cdot \left(b \cdot b\right)} + {b}^{4}\right) + -1 \]
    10. Step-by-step derivation
      1. sqr-pow100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 51.1% accurate, 18.3× speedup?

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

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

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

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

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

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

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

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

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

    \[\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-*r*52.2%

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

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

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

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

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

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

    \[\leadsto -1 + \left(a \cdot a\right) \cdot 4 \]

Alternative 11: 24.7% accurate, 128.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  11. Final simplification28.5%

    \[\leadsto -1 \]

Reproduce

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