Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.7% → 98.9%
Time: 7.3s
Alternatives: 11
Speedup: 8.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 98.9% accurate, 0.4× speedup?

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

\\
\left({\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8} + b \cdot \left(b \cdot 12\right)\right) + -1
\end{array}
Derivation
  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(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. sub-neg74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8} + \color{blue}{\left(b \cdot b\right) \cdot 12}\right) + -1 \]
    3. associate-*r*99.1%

      \[\leadsto \left({\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8} + \color{blue}{b \cdot \left(b \cdot 12\right)}\right) + -1 \]
  13. Simplified99.1%

    \[\leadsto \left({\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8} + \color{blue}{b \cdot \left(b \cdot 12\right)}\right) + -1 \]
  14. Final simplification99.1%

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

Alternative 2: 98.5% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a, a \cdot a, \color{blue}{\left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)}\right) + -1 \]
    8. Applied egg-rr25.4%

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

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

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

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(a \cdot a + \left(1 - a\right) \cdot 4\right)} + -1 \]
    10. Applied egg-rr94.2%

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

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

Alternative 3: 94.9% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a, a \cdot a, \color{blue}{\left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)}\right) + -1 \]
    8. Applied egg-rr84.4%

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

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

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

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

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

    if 1e7 < (*.f64 b b)

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 94.7% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a, a \cdot a, \color{blue}{\left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)}\right) + -1 \]
    8. Applied egg-rr83.1%

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

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

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

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

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

    if 1e12 < (*.f64 b b)

    1. Initial program 64.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg64.4%

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

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

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

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

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

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

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

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

Alternative 5: 94.8% accurate, 6.7× speedup?

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

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

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


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

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a, a \cdot a, \color{blue}{\left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)}\right) + -1 \]
    8. Applied egg-rr84.4%

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

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

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

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

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

    if 1e7 < (*.f64 b b)

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.2% accurate, 8.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -6.9999999999999998e153 or 6.7999999999999995e153 < a

    1. Initial program 27.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.9999999999999998e153 < a < 6.7999999999999995e153

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 57.0% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.50000000000000006e89 < b

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(3 + a\right) \cdot \left(4 \cdot \left(b \cdot b\right)\right)} \]
    13. Simplified71.0%

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

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

Alternative 8: 60.2% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3500000000000001e127 < b

    1. Initial program 69.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right)\right)} + -1 \]
    11. Taylor expanded in a around 0 84.8%

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

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

Alternative 9: 33.9% accurate, 14.1× speedup?

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

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

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


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

    1. Initial program 77.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3100 < b

    1. Initial program 67.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{a \cdot \left(4 \cdot \left(b \cdot b\right)\right)} \]
    13. Simplified38.1%

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

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

Alternative 10: 54.0% accurate, 14.1× speedup?

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

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.3999999999999997e88 < b

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 25.7% accurate, 128.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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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