Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.3% → 98.9%
Time: 8.4s
Alternatives: 15
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 74.3% 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.9% accurate, 0.6× speedup?

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

\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \left(b \cdot b\right) + -1\right)
\end{array}
Derivation
  1. Initial program 73.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+73.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-def73.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. Simplified74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \color{blue}{\left(b \cdot b\right)} - 1\right) \]
  11. Final simplification98.5%

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

Alternative 2: 97.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(b \cdot b + a \cdot a\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}:\\ \;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0
         (+
          (pow (+ (* b b) (* a a)) 2.0)
          (* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
   (if (<= t_0 INFINITY) (+ t_0 -1.0) (* 2.0 (* b (* b (* a a)))))))
double code(double a, double b) {
	double t_0 = pow(((b * b) + (a * a)), 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 = 2.0 * (b * (b * (a * a)));
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((b * b) + (a * a)), 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 = 2.0 * (b * (b * (a * a)));
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(((b * b) + (a * a)), 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 = 2.0 * (b * (b * (a * a)))
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 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(2.0 * Float64(b * Float64(b * Float64(a * a))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((b * b) + (a * a)) ^ 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 = 2.0 * (b * (b * (a * a)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $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[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\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}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (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. Simplified4.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 b around inf 83.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(b \cdot b + a \cdot a\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(b \cdot b + a \cdot a\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}:\\ \;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\ \end{array} \]

Alternative 3: 93.8% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -9.5000000000000003e40 or 6.5000000000000001e40 < a

    1. Initial program 39.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+39.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-def39.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. Simplified42.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 95.3%

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

    if -9.5000000000000003e40 < a < 6.5000000000000001e40

    1. Initial program 98.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+98.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-def98.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. Simplified98.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. Step-by-step derivation
      1. fma-def98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.6% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 81.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+81.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-def81.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. Simplified81.4%

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

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

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

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

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

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

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

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

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

    if 2e46 < (*.f64 b b)

    1. Initial program 65.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+65.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-def65.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. Simplified68.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. Taylor expanded in b around inf 92.5%

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

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

Alternative 5: 93.5% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 81.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+81.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-def81.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. Simplified81.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e46 < (*.f64 b b)

    1. Initial program 65.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+65.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-def65.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. Simplified68.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. Taylor expanded in b around inf 92.5%

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

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

Alternative 6: 67.2% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 10^{+131}:\\
\;\;\;\;{a}^{4}\\

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


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

    1. Initial program 84.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+84.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-def84.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. Simplified84.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 b around 0 84.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+84.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, a \cdot a, \color{blue}{-1}\right) \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. fma-udef78.6%

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

        \[\leadsto \color{blue}{\sqrt{4 \cdot \left(a \cdot a\right)} \cdot \sqrt{4 \cdot \left(a \cdot a\right)}} + -1 \]
      3. difference-of-sqr--178.6%

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

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} + 1\right) \cdot \left(\sqrt{4 \cdot \left(a \cdot a\right)} - 1\right) \]
      7. add-sqr-sqrt64.8%

        \[\leadsto \left(2 \cdot \color{blue}{a} + 1\right) \cdot \left(\sqrt{4 \cdot \left(a \cdot a\right)} - 1\right) \]
      8. *-commutative64.8%

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

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{\sqrt{4} \cdot \sqrt{a \cdot a}} - 1\right) \]
      10. metadata-eval64.8%

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

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} - 1\right) \]
      12. add-sqr-sqrt78.6%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(2 \cdot \color{blue}{a} - 1\right) \]
      13. *-commutative78.6%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{a \cdot 2} - 1\right) \]
    11. Applied egg-rr78.6%

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

    if 2.0000000000000001e-13 < (*.f64 b b) < 9.9999999999999991e130

    1. Initial program 73.3%

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

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

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

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

    if 9.9999999999999991e130 < (*.f64 b b)

    1. Initial program 61.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+61.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-def61.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. Simplified64.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. Taylor expanded in b around inf 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 81.4% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 81.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+81.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-def81.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. Simplified81.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. fma-udef76.3%

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

        \[\leadsto \color{blue}{\sqrt{4 \cdot \left(a \cdot a\right)} \cdot \sqrt{4 \cdot \left(a \cdot a\right)}} + -1 \]
      3. difference-of-sqr--176.3%

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

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} + 1\right) \cdot \left(\sqrt{4 \cdot \left(a \cdot a\right)} - 1\right) \]
      7. add-sqr-sqrt60.0%

        \[\leadsto \left(2 \cdot \color{blue}{a} + 1\right) \cdot \left(\sqrt{4 \cdot \left(a \cdot a\right)} - 1\right) \]
      8. *-commutative60.0%

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

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{\sqrt{4} \cdot \sqrt{a \cdot a}} - 1\right) \]
      10. metadata-eval60.0%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{2} \cdot \sqrt{a \cdot a} - 1\right) \]
      11. sqrt-prod34.0%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} - 1\right) \]
      12. add-sqr-sqrt76.3%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(2 \cdot \color{blue}{a} - 1\right) \]
      13. *-commutative76.3%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{a \cdot 2} - 1\right) \]
    11. Applied egg-rr76.3%

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

    if 2e46 < (*.f64 b b)

    1. Initial program 65.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+65.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-def65.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. Simplified68.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. Taylor expanded in b around inf 92.5%

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

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

Alternative 8: 65.9% accurate, 8.6× speedup?

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

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

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


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

    1. Initial program 84.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+84.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-def84.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. Simplified84.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 b around 0 84.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+84.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, a \cdot a, \color{blue}{-1}\right) \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. metadata-eval78.6%

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

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

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

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

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

    if 2.0000000000000001e-13 < (*.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 65.9% accurate, 8.6× speedup?

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

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

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


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

    1. Initial program 84.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+84.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-def84.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. Simplified84.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 b around 0 84.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+84.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, a \cdot a, \color{blue}{-1}\right) \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. fma-udef78.6%

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

        \[\leadsto \color{blue}{\sqrt{4 \cdot \left(a \cdot a\right)} \cdot \sqrt{4 \cdot \left(a \cdot a\right)}} + -1 \]
      3. difference-of-sqr--178.6%

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

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} + 1\right) \cdot \left(\sqrt{4 \cdot \left(a \cdot a\right)} - 1\right) \]
      7. add-sqr-sqrt64.8%

        \[\leadsto \left(2 \cdot \color{blue}{a} + 1\right) \cdot \left(\sqrt{4 \cdot \left(a \cdot a\right)} - 1\right) \]
      8. *-commutative64.8%

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

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{\sqrt{4} \cdot \sqrt{a \cdot a}} - 1\right) \]
      10. metadata-eval64.8%

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

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} - 1\right) \]
      12. add-sqr-sqrt78.6%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(2 \cdot \color{blue}{a} - 1\right) \]
      13. *-commutative78.6%

        \[\leadsto \left(a \cdot 2 + 1\right) \cdot \left(\color{blue}{a \cdot 2} - 1\right) \]
    11. Applied egg-rr78.6%

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

    if 2.0000000000000001e-13 < (*.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.2% accurate, 10.0× speedup?

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

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

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


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

    1. Initial program 84.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+84.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-def84.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. Simplified84.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 b around 0 84.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+84.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, a \cdot a, \color{blue}{-1}\right) \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. metadata-eval78.6%

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

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

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

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

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

    if 2.0000000000000001e-13 < (*.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 66.3% accurate, 10.0× speedup?

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

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

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


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

    1. Initial program 84.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+84.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-def84.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. Simplified84.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 b around 0 84.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+84.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, a \cdot a, \color{blue}{-1}\right) \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. metadata-eval78.6%

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

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

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

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

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

    if 2.0000000000000001e-13 < (*.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 54.0% accurate, 11.6× speedup?

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

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

\mathbf{elif}\;a \leq -0.00136:\\
\;\;\;\;-12 \cdot \left(a \cdot \left(b \cdot b\right)\right)\\

\mathbf{elif}\;a \leq 0.42:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.39999999999999996e141 or 0.419999999999999984 < a

    1. Initial program 37.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+37.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-def37.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. Simplified37.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 b around 0 54.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+54.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, a \cdot a, \color{blue}{-1}\right) \]
    9. Simplified63.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Taylor expanded in a around inf 64.1%

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

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

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

    if -1.39999999999999996e141 < a < -0.00136

    1. Initial program 72.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+72.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-def72.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. Simplified81.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.00136 < a < 0.419999999999999984

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification53.7%

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

Alternative 13: 50.8% accurate, 14.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.005 \lor \neg \left(a \leq 0.42\right):\\
\;\;\;\;4 \cdot \left(a \cdot a\right)\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.0050000000000000001 or 0.419999999999999984 < a

    1. Initial program 46.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+46.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-def46.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. Simplified49.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. Taylor expanded in b around 0 50.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Taylor expanded in a around inf 48.7%

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

        \[\leadsto 4 \cdot \color{blue}{\left(a \cdot a\right)} \]
    12. Simplified48.7%

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

    if -0.0050000000000000001 < a < 0.419999999999999984

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.005 \lor \neg \left(a \leq 0.42\right):\\ \;\;\;\;4 \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 14: 54.0% accurate, 14.3× speedup?

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

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

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, a \cdot a, -1\right)} \]
    10. Step-by-step derivation
      1. metadata-eval50.9%

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

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

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

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

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

    if 9.50000000000000021e162 < b

    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. Simplified58.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. Taylor expanded in b around inf 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 25.0% 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 73.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+73.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-def73.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. Simplified74.9%

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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