Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.4% → 98.3%
Time: 9.7s
Alternatives: 8
Speedup: 9.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 98.3% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 32.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 93.1% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 83.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 78.7%

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

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

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

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

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

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

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

    if 9.99999999999999995e88 < (*.f64 b b)

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 93.0% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 83.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999995e88 < (*.f64 b b)

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.0% accurate, 8.5× speedup?

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

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

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


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

    1. Initial program 83.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999995e88 < (*.f64 b b)

    1. Initial program 61.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in a around 0 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.6% accurate, 9.8× speedup?

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

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

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


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

    1. Initial program 84.1%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 84.0%

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

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

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

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

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

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

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

    if 1 < (*.f64 b b)

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left(a \cdot \left(b \cdot \left(b \cdot a\right)\right)\right)} \]
    8. Taylor expanded in b around 0 70.4%

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

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

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

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

Alternative 6: 83.1% accurate, 9.8× speedup?

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

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

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


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

    1. Initial program 83.5%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 83.4%

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

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

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

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

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

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

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

    if 500 < (*.f64 b b)

    1. Initial program 64.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in a around 0 61.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.4% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 79.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0 67.0%

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

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

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

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

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

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

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

    if 2.00000000000000011e301 < (*.f64 b b)

    1. Initial program 58.7%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Taylor expanded in a around 0 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 52.8% accurate, 18.3× speedup?

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

\\
\left(a \cdot a\right) \cdot 4 + -1
\end{array}
Derivation
  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(3 + a\right)\right)\right) - 1 \]
  2. Taylor expanded in b around 0 55.1%

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

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

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

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

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

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

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

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

Reproduce

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