Bouland and Aaronson, Equation (24)

Percentage Accurate: 74.0% → 98.6%
Time: 7.9s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 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.6% 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.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. associate--l+99.8%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(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-def6.3%

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

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

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

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

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

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

    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-def6.3%

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

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

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

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

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

    \[\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: 96.3% accurate, 1.1× speedup?

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

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

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

\mathbf{elif}\;a \leq -4.6:\\
\;\;\;\;-1 + \left({a}^{4} + \left(1 - a\right) \cdot t_0\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if a < -1.50000000000000013e154

    1. Initial program 58.1%

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

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

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

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

    if -1.50000000000000013e154 < a < -8.5e7

    1. Initial program 71.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-neg71.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-def71.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-def71.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. +-commutative71.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-eval71.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. Simplified71.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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.5e7 < a < -4.5999999999999996

    1. Initial program 100.0%

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

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

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

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

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

    if -4.5999999999999996 < a < 5e16

    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. sub-neg99.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-def99.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-def99.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. +-commutative99.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-eval99.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. Simplified99.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 87.4%

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

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

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

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

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

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

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

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

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

      \[\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 99.9%

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

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

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

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

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

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

    if 5e16 < a

    1. Initial program 32.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-neg32.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-def32.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-def39.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. +-commutative39.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-eval39.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. Simplified39.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 inf 95.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.5 \cdot 10^{+154}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{elif}\;a \leq -85000000:\\ \;\;\;\;-1 + \left({a}^{4} + \left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot 2\right)\right)\\ \mathbf{elif}\;a \leq -4.6:\\ \;\;\;\;-1 + \left({a}^{4} + \left(1 - a\right) \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right)\\ \mathbf{elif}\;a \leq 5 \cdot 10^{+16}:\\ \;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \]

Alternative 4: 94.9% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 65.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-neg65.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-def65.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-def65.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. +-commutative65.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-eval65.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. Simplified65.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 0 93.9%

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

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

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

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

    if -0.69999999999999996 < a < 1.32e16

    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. sub-neg99.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-def99.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-def99.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. +-commutative99.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-eval99.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. Simplified99.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 87.4%

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

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

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

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

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

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

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

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

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

      \[\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 99.9%

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

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

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

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

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

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

    if 1.32e16 < a

    1. Initial program 32.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-neg32.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-def32.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-def39.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. +-commutative39.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-eval39.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. Simplified39.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 inf 95.4%

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

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

Alternative 5: 94.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -9.5 \cdot 10^{+21} \lor \neg \left(a \leq 7 \cdot 10^{+16}\right):\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -9.5e+21) (not (<= a 7e+16)))
   (+ -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 ((a <= -9.5e+21) || !(a <= 7e+16)) {
		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 ((a <= (-9.5d+21)) .or. (.not. (a <= 7d+16))) 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 ((a <= -9.5e+21) || !(a <= 7e+16)) {
		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 (a <= -9.5e+21) or not (a <= 7e+16):
		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 ((a <= -9.5e+21) || !(a <= 7e+16))
		tmp = Float64(-1.0 + (a ^ 4.0));
	else
		tmp = Float64(-1.0 + Float64(Float64(b * Float64(b * 12.0)) + (b ^ 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -9.5e+21) || ~((a <= 7e+16)))
		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[Or[LessEqual[a, -9.5e+21], N[Not[LessEqual[a, 7e+16]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.5 \cdot 10^{+21} \lor \neg \left(a \leq 7 \cdot 10^{+16}\right):\\
\;\;\;\;-1 + {a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -9.500000000000001e21 or 7e16 < a

    1. Initial program 49.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-neg49.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-def49.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-def53.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. +-commutative53.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-eval53.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. Simplified53.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 a around inf 95.3%

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

    if -9.500000000000001e21 < a < 7e16

    1. Initial program 99.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-neg99.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-def99.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-def99.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. +-commutative99.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-eval99.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. Simplified99.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 86.0%

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

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

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

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

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

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

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

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

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

      \[\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 99.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -9.5 \cdot 10^{+21} \lor \neg \left(a \leq 7 \cdot 10^{+16}\right):\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\ \end{array} \]

Alternative 6: 94.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -8.2 \cdot 10^{+21} \lor \neg \left(a \leq 41000000000000\right):\\ \;\;\;\;-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 (or (<= a -8.2e+21) (not (<= a 41000000000000.0)))
   (+ -1.0 (pow a 4.0))
   (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
	double tmp;
	if ((a <= -8.2e+21) || !(a <= 41000000000000.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 ((a <= (-8.2d+21)) .or. (.not. (a <= 41000000000000.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 ((a <= -8.2e+21) || !(a <= 41000000000000.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 (a <= -8.2e+21) or not (a <= 41000000000000.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 ((a <= -8.2e+21) || !(a <= 41000000000000.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 ((a <= -8.2e+21) || ~((a <= 41000000000000.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[Or[LessEqual[a, -8.2e+21], N[Not[LessEqual[a, 41000000000000.0]], $MachinePrecision]], 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}\;a \leq -8.2 \cdot 10^{+21} \lor \neg \left(a \leq 41000000000000\right):\\
\;\;\;\;-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 a < -8.2e21 or 4.1e13 < a

    1. Initial program 49.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-neg49.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-def49.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-def53.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. +-commutative53.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-eval53.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. Simplified53.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 a around inf 95.3%

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

    if -8.2e21 < a < 4.1e13

    1. Initial program 99.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-neg99.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-def99.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-def99.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. +-commutative99.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-eval99.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. Simplified99.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 86.0%

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

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

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

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

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

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

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

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

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

      \[\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 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot b, b \cdot b, b \cdot \left(12 \cdot b\right)\right)} + -1 \]
    12. Step-by-step derivation
      1. fma-udef99.0%

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

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

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

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

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

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

Alternative 7: 84.1% accurate, 8.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.8 \cdot 10^{+148} \lor \neg \left(a \leq 6.6 \cdot 10^{+145}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 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 (or (<= a -1.8e+148) (not (<= a 6.6e+145)))
   (+ -1.0 (* (* a a) 4.0))
   (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
	double tmp;
	if ((a <= -1.8e+148) || !(a <= 6.6e+145)) {
		tmp = -1.0 + ((a * 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 ((a <= (-1.8d+148)) .or. (.not. (a <= 6.6d+145))) then
        tmp = (-1.0d0) + ((a * 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 ((a <= -1.8e+148) || !(a <= 6.6e+145)) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -1.8e+148) or not (a <= 6.6e+145):
		tmp = -1.0 + ((a * a) * 4.0)
	else:
		tmp = -1.0 + ((b * b) * ((b * b) + 12.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -1.8e+148) || !(a <= 6.6e+145))
		tmp = Float64(-1.0 + Float64(Float64(a * 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 ((a <= -1.8e+148) || ~((a <= 6.6e+145)))
		tmp = -1.0 + ((a * a) * 4.0);
	else
		tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -1.8e+148], N[Not[LessEqual[a, 6.6e+145]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 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}\;a \leq -1.8 \cdot 10^{+148} \lor \neg \left(a \leq 6.6 \cdot 10^{+145}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 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 a < -1.80000000000000003e148 or 6.60000000000000054e145 < a

    1. Initial program 33.3%

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

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

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

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

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

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

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

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

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

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

    if -1.80000000000000003e148 < a < 6.60000000000000054e145

    1. Initial program 90.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-neg90.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-def90.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-def92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 81.0%

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

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

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

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

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

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

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

        \[\leadsto \left({b}^{\color{blue}{\left(2 + 2\right)}} + b \cdot \left(12 \cdot b\right)\right) + -1 \]
      3. pow-prod-up80.9%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot b, b \cdot b, b \cdot \left(12 \cdot b\right)\right)} + -1 \]
    11. Applied egg-rr80.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot b, b \cdot b, b \cdot \left(12 \cdot b\right)\right)} + -1 \]
    12. Step-by-step derivation
      1. fma-udef80.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.8 \cdot 10^{+148} \lor \neg \left(a \leq 6.6 \cdot 10^{+145}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\ \end{array} \]

Alternative 8: 68.0% accurate, 11.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+284}:\\ \;\;\;\;-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) 5e+284) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 5e+284) {
		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) <= 5d+284) 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) <= 5e+284) {
		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) <= 5e+284:
		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) <= 5e+284)
		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) <= 5e+284)
		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], 5e+284], 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 5 \cdot 10^{+284}:\\
\;\;\;\;-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) < 4.9999999999999999e284

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left({a}^{4} + \left(4 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot \left(1 - a\right)\right) + -1 \]
    6. Simplified66.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 57.0%

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

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

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

    if 4.9999999999999999e284 < (*.f64 b b)

    1. Initial program 53.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-neg53.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-def53.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-def59.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 50.8% 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 74.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-neg74.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-def74.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-def76.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. +-commutative76.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-eval76.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. Simplified76.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 55.0%

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

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

      \[\leadsto \left({a}^{4} + \left(4 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot \left(1 - a\right)\right) + -1 \]
  6. Simplified55.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 50.0%

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

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

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

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

Reproduce

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