Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.8% → 98.3%
Time: 7.1s
Alternatives: 9
Speedup: 8.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 73.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -680000000000:\\
\;\;\;\;{a}^{4}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -6.8e11 or 2.1e12 < a

    1. Initial program 54.8%

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

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

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

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

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

    if -6.8e11 < a < 2.1e12

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.3% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000009e48 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.6% accurate, 1.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.05e15 or 4e11 < a

    1. Initial program 54.8%

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

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

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

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

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

    if -1.05e15 < a < 4e11

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(\color{blue}{\left(a \cdot -12 + 4\right)} + b \cdot b\right) + -1 \]
      8. fma-def98.7%

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

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

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

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

        \[\leadsto \left(4 + b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} + -1 \]
    13. Simplified98.7%

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

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

Alternative 6: 84.7% accurate, 8.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.6 \cdot 10^{+138} \lor \neg \left(a \leq 6.6 \cdot 10^{+153}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -1.6e+138) (not (<= a 6.6e+153)))
   (+ -1.0 (* (* a a) 4.0))
   (+ -1.0 (* (* b b) (+ (* b b) 4.0)))))
double code(double a, double b) {
	double tmp;
	if ((a <= -1.6e+138) || !(a <= 6.6e+153)) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((a <= (-1.6d+138)) .or. (.not. (a <= 6.6d+153))) then
        tmp = (-1.0d0) + ((a * a) * 4.0d0)
    else
        tmp = (-1.0d0) + ((b * b) * ((b * b) + 4.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((a <= -1.6e+138) || !(a <= 6.6e+153)) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -1.6e+138) or not (a <= 6.6e+153):
		tmp = -1.0 + ((a * a) * 4.0)
	else:
		tmp = -1.0 + ((b * b) * ((b * b) + 4.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -1.6e+138) || !(a <= 6.6e+153))
		tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0));
	else
		tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -1.6e+138) || ~((a <= 6.6e+153)))
		tmp = -1.0 + ((a * a) * 4.0);
	else
		tmp = -1.0 + ((b * b) * ((b * b) + 4.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -1.6e+138], N[Not[LessEqual[a, 6.6e+153]], $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] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.6000000000000001e138 or 6.59999999999999989e153 < a

    1. Initial program 32.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6000000000000001e138 < a < 6.59999999999999989e153

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(\color{blue}{\mathsf{fma}\left(a, -12, 4\right)} + b \cdot b\right) + -1 \]
    10. Applied egg-rr81.2%

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

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

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

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

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

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

Alternative 7: 68.3% accurate, 11.8× speedup?

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

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

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


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

    1. Initial program 80.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999992e227 < (*.f64 b b)

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(a, -12, 4\right)} + -1 \]
      6. associate-*l*58.8%

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

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

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

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

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

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

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

Alternative 8: 50.1% accurate, 18.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(a, -12, 4\right)} + -1 \]
    6. associate-*l*42.9%

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

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

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

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

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

    \[\leadsto b \cdot \color{blue}{\left(4 \cdot b\right)} + -1 \]
  13. Final simplification44.7%

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

Alternative 9: 24.6% accurate, 130.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification21.9%

    \[\leadsto -1 \]

Reproduce

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