Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.8% → 98.2%
Time: 8.0s
Alternatives: 14
Speedup: 1.1×

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 14 alternatives:

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

Initial Program: 73.8% accurate, 1.0× speedup?

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

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

Alternative 1: 98.2% accurate, 0.2× speedup?

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

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

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


\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.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. sub-neg99.7%

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

Alternative 2: 98.1% accurate, 0.5× speedup?

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

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

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


\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.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 \]

    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. Simplified7.7%

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

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

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

Alternative 3: 84.8% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(4, a \cdot a, -1\right)\\

\mathbf{elif}\;b \cdot b \leq 1000000:\\
\;\;\;\;{a}^{4}\\

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


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

    1. Initial program 86.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+86.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-def86.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. Simplified86.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 0 86.5%

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

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

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

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

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

    if 4.0000000000000003e-130 < (*.f64 b b) < 9.99999999999999928e-35

    1. Initial program 70.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+70.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-def70.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. Simplified70.8%

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

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

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

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

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

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

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

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

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

    if 9.99999999999999928e-35 < (*.f64 b b) < 1e6

    1. Initial program 62.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+62.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-def62.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. Simplified62.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 75.8%

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

    if 1e6 < (*.f64 b b)

    1. Initial program 65.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+65.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-def65.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. Simplified69.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 97.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. *-commutative97.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-def97.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. unpow297.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. +-commutative97.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. +-commutative97.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-def97.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. unpow297.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-in97.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-eval97.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*97.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-eval97.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. Simplified97.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 0 90.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow290.6%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified90.6%

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

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

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

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

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

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

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

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

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

Alternative 4: 79.7% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 10^{-180}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;b \cdot b \leq 1000000:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 b b) < 1.00000000000000005e-286 or 1e-180 < (*.f64 b b) < 1e6

    1. Initial program 82.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+82.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-def82.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. Simplified82.0%

      \[\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 82.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+82.0%

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-286 < (*.f64 b b) < 1e-180

    1. Initial program 83.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+83.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-def83.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. Simplified83.0%

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

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

    if 1e6 < (*.f64 b b)

    1. Initial program 65.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+65.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-def65.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. Simplified69.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 97.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. *-commutative97.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-def97.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. unpow297.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. +-commutative97.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. +-commutative97.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-def97.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. unpow297.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-in97.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-eval97.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*97.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-eval97.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. Simplified97.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 0 90.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow290.6%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified90.6%

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

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

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

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

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

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

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

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

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

Alternative 5: 47.0% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.2 \cdot 10^{-286}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 8.5 \cdot 10^{-232}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;b \leq 3.6 \cdot 10^{-208}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 3200:\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 1.19999999999999997e-286 or 8.5e-232 < b < 3.5999999999999998e-208

    1. Initial program 78.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+78.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-def78.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. Simplified79.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 59.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+59.8%

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 1.19999999999999997e-286 < b < 8.5e-232 or 3.5999999999999998e-208 < b < 3200

    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 a around inf 68.3%

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

    if 3200 < b

    1. Initial program 60.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+60.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-def60.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. Simplified65.0%

      \[\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 0 91.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow291.6%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified91.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.2 \cdot 10^{-286}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \leq 8.5 \cdot 10^{-232}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;b \leq 3.6 \cdot 10^{-208}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \leq 3200:\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\ \end{array} \]

Alternative 6: 45.6% accurate, 5.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-112}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 3400:\\
\;\;\;\;\left(b \cdot b\right) \cdot \frac{a \cdot \left(144 - \left(a \cdot a\right) \cdot 4\right)}{-12 + a \cdot -2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 3.0999999999999998e-112

    1. Initial program 79.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+79.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-def79.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. Simplified81.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 3.0999999999999998e-112 < b < 3400

    1. Initial program 73.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+73.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-def73.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. Simplified73.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 44.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. *-commutative44.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-def44.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. unpow244.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. +-commutative44.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. +-commutative44.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-def44.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. unpow244.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-in44.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-eval44.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*44.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-eval44.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. Simplified44.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 44.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot \left(-12 + a \cdot 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutative44.3%

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(\color{blue}{144} - \left(a \cdot 2\right) \cdot \left(a \cdot 2\right)\right) \cdot a}{-12 - a \cdot 2} \]
      5. *-commutative49.1%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \color{blue}{\left(2 \cdot a\right)} \cdot \left(a \cdot 2\right)\right) \cdot a}{-12 - a \cdot 2} \]
      6. *-commutative49.1%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \left(2 \cdot a\right) \cdot \color{blue}{\left(2 \cdot a\right)}\right) \cdot a}{-12 - a \cdot 2} \]
      7. swap-sqr49.1%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \color{blue}{\left(2 \cdot 2\right) \cdot \left(a \cdot a\right)}\right) \cdot a}{-12 - a \cdot 2} \]
      8. metadata-eval49.1%

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

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - 4 \cdot \left(a \cdot a\right)\right) \cdot a}{-12 - \color{blue}{2 \cdot a}} \]
      10. cancel-sign-sub-inv49.1%

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

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - 4 \cdot \left(a \cdot a\right)\right) \cdot a}{-12 + \color{blue}{-2} \cdot a} \]
    11. Applied egg-rr49.1%

      \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\frac{\left(144 - 4 \cdot \left(a \cdot a\right)\right) \cdot a}{-12 + -2 \cdot a}} \]

    if 3400 < b

    1. Initial program 60.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+60.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-def60.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. Simplified65.0%

      \[\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 0 91.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow291.6%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified91.6%

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

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

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

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

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

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

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

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

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

Alternative 7: 41.1% accurate, 8.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2.05 \cdot 10^{-68}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \leq 1.08 \cdot 10^{-51}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot \left(a \cdot 2\right)\right)\\ \mathbf{elif}\;b \leq 9.8 \cdot 10^{-45}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot \left(a \cdot 2\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 2.05e-68)
   -1.0
   (if (<= b 1.08e-51)
     (* (* b b) (* a (* a 2.0)))
     (if (<= b 9.8e-45) -1.0 (* a (* (* b b) (* a 2.0)))))))
double code(double a, double b) {
	double tmp;
	if (b <= 2.05e-68) {
		tmp = -1.0;
	} else if (b <= 1.08e-51) {
		tmp = (b * b) * (a * (a * 2.0));
	} else if (b <= 9.8e-45) {
		tmp = -1.0;
	} else {
		tmp = a * ((b * b) * (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 <= 2.05d-68) then
        tmp = -1.0d0
    else if (b <= 1.08d-51) then
        tmp = (b * b) * (a * (a * 2.0d0))
    else if (b <= 9.8d-45) then
        tmp = -1.0d0
    else
        tmp = a * ((b * b) * (a * 2.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (b <= 2.05e-68) {
		tmp = -1.0;
	} else if (b <= 1.08e-51) {
		tmp = (b * b) * (a * (a * 2.0));
	} else if (b <= 9.8e-45) {
		tmp = -1.0;
	} else {
		tmp = a * ((b * b) * (a * 2.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if b <= 2.05e-68:
		tmp = -1.0
	elif b <= 1.08e-51:
		tmp = (b * b) * (a * (a * 2.0))
	elif b <= 9.8e-45:
		tmp = -1.0
	else:
		tmp = a * ((b * b) * (a * 2.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (b <= 2.05e-68)
		tmp = -1.0;
	elseif (b <= 1.08e-51)
		tmp = Float64(Float64(b * b) * Float64(a * Float64(a * 2.0)));
	elseif (b <= 9.8e-45)
		tmp = -1.0;
	else
		tmp = Float64(a * Float64(Float64(b * b) * Float64(a * 2.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 2.05e-68)
		tmp = -1.0;
	elseif (b <= 1.08e-51)
		tmp = (b * b) * (a * (a * 2.0));
	elseif (b <= 9.8e-45)
		tmp = -1.0;
	else
		tmp = a * ((b * b) * (a * 2.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 2.05e-68], -1.0, If[LessEqual[b, 1.08e-51], N[(N[(b * b), $MachinePrecision] * N[(a * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.8e-45], -1.0, N[(a * N[(N[(b * b), $MachinePrecision] * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.05 \cdot 10^{-68}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 1.08 \cdot 10^{-51}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot \left(a \cdot 2\right)\right)\\

\mathbf{elif}\;b \leq 9.8 \cdot 10^{-45}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 2.05000000000000011e-68 or 1.08000000000000004e-51 < b < 9.7999999999999996e-45

    1. Initial program 79.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+79.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-def79.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. Simplified80.7%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 2.05000000000000011e-68 < b < 1.08000000000000004e-51

    1. Initial program 74.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+74.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-def74.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. Simplified74.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 51.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.7999999999999996e-45 < b

    1. Initial program 61.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+61.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-def61.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. Simplified65.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 95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2.05 \cdot 10^{-68}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \leq 1.08 \cdot 10^{-51}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot \left(a \cdot 2\right)\right)\\ \mathbf{elif}\;b \leq 9.8 \cdot 10^{-45}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot \left(a \cdot 2\right)\right)\\ \end{array} \]

Alternative 8: 45.8% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-68}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot \left(a \cdot 2\right)\right)\\

\mathbf{elif}\;b \leq 0.48:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 2.10000000000000008e-68 or 6.7999999999999997e-9 < b < 0.47999999999999998

    1. Initial program 79.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+79.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-def79.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. Simplified80.7%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 2.10000000000000008e-68 < b < 6.7999999999999997e-9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.47999999999999998 < b

    1. Initial program 59.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+59.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-def59.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. Simplified64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 0 90.3%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow290.3%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified90.3%

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

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

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

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

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

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

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

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

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

Alternative 9: 45.9% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.1 \cdot 10^{-69}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;b \leq 0.48:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 4.0999999999999999e-69 or 8.00000000000000029e-10 < b < 0.47999999999999998

    1. Initial program 79.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+79.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-def79.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. Simplified80.7%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 4.0999999999999999e-69 < b < 8.00000000000000029e-10

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 47.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*47.5%

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

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

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

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

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

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

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

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

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

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

    if 0.47999999999999998 < b

    1. Initial program 59.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+59.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-def59.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. Simplified64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 0 90.3%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow290.3%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified90.3%

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

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

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

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

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

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

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

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

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

Alternative 10: 41.4% accurate, 9.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.8 \cdot 10^{-45}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 6.8 \cdot 10^{+153}:\\
\;\;\;\;2 \cdot \left(a \cdot \left(b \cdot \left(a \cdot b\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 9.7999999999999996e-45

    1. Initial program 79.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+79.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-def79.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. Simplified80.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 65.2%

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 9.7999999999999996e-45 < b < 6.7999999999999995e153

    1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 37.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*37.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot \left(-12 + a \cdot 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutative39.6%

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\frac{\left(-12 \cdot -12 - \left(a \cdot 2\right) \cdot \left(a \cdot 2\right)\right) \cdot a}{-12 - a \cdot 2}} \]
      4. metadata-eval41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(\color{blue}{144} - \left(a \cdot 2\right) \cdot \left(a \cdot 2\right)\right) \cdot a}{-12 - a \cdot 2} \]
      5. *-commutative41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \color{blue}{\left(2 \cdot a\right)} \cdot \left(a \cdot 2\right)\right) \cdot a}{-12 - a \cdot 2} \]
      6. *-commutative41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \left(2 \cdot a\right) \cdot \color{blue}{\left(2 \cdot a\right)}\right) \cdot a}{-12 - a \cdot 2} \]
      7. swap-sqr41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \color{blue}{\left(2 \cdot 2\right) \cdot \left(a \cdot a\right)}\right) \cdot a}{-12 - a \cdot 2} \]
      8. metadata-eval41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - \color{blue}{4} \cdot \left(a \cdot a\right)\right) \cdot a}{-12 - a \cdot 2} \]
      9. *-commutative41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - 4 \cdot \left(a \cdot a\right)\right) \cdot a}{-12 - \color{blue}{2 \cdot a}} \]
      10. cancel-sign-sub-inv41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - 4 \cdot \left(a \cdot a\right)\right) \cdot a}{\color{blue}{-12 + \left(-2\right) \cdot a}} \]
      11. metadata-eval41.9%

        \[\leadsto \left(b \cdot b\right) \cdot \frac{\left(144 - 4 \cdot \left(a \cdot a\right)\right) \cdot a}{-12 + \color{blue}{-2} \cdot a} \]
    11. Applied egg-rr41.9%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(a \cdot \color{blue}{\left(b \cdot \left(b \cdot a\right)\right)}\right) \]
    14. Simplified40.0%

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

    if 6.7999999999999995e153 < b

    1. Initial program 40.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+40.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-def40.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. Simplified46.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow2100.0%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, b \cdot b, {b}^{4}\right)} \]
    10. Taylor expanded in b around 0 100.0%

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

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

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

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

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

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

Alternative 11: 39.2% accurate, 11.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.48:\\
\;\;\;\;-1\\

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

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


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

    1. Initial program 79.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+79.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-def79.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. Simplified80.7%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 0.47999999999999998 < b < 6.7999999999999995e153

    1. Initial program 75.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+75.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-def75.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. Simplified78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.7999999999999995e153 < b

    1. Initial program 40.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+40.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-def40.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. Simplified46.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow2100.0%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, b \cdot b, {b}^{4}\right)} \]
    10. Taylor expanded in b around 0 100.0%

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

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

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

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

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

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

Alternative 12: 41.3% accurate, 11.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.8 \cdot 10^{-45}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 9.7999999999999996e-45

    1. Initial program 79.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+79.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-def79.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. Simplified80.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 65.2%

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 9.7999999999999996e-45 < b

    1. Initial program 61.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+61.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-def61.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. Simplified65.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 95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 38.1% accurate, 18.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.48:\\
\;\;\;\;-1\\

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


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

    1. Initial program 79.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+79.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-def79.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. Simplified80.7%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 0.47999999999999998 < b

    1. Initial program 59.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+59.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-def59.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. Simplified64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 0 90.3%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, {b}^{4}\right)} \]
      2. unpow290.3%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4}\right) \]
    9. Simplified90.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, b \cdot b, {b}^{4}\right)} \]
    10. Taylor expanded in b around 0 48.2%

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

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

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

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

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

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

Alternative 14: 25.1% 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 74.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+74.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-def74.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. Simplified76.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 0 55.0%

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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