Bouland and Aaronson, Equation (24)

Percentage Accurate: 74.8% → 98.6%
Time: 8.0s
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: 74.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(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.6% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\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 \]
    2. Step-by-step derivation
      1. associate--l+99.8%

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

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

    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-def9.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. +-commutative9.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-eval9.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. Simplified9.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 inf 96.9%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. metadata-eval96.9%

        \[\leadsto {a}^{\color{blue}{\left(2 + 2\right)}} + -1 \]
      2. pow-prod-up96.9%

        \[\leadsto \color{blue}{{a}^{2} \cdot {a}^{2}} + -1 \]
      3. pow296.9%

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

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      5. difference-of-sqr--196.9%

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

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

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

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:\\ \;\;\;\;t_0 + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\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) (+ t_0 -1.0) (* (+ (* a a) 1.0) (+ (* a a) -1.0)))))
double code(double a, double b) {
	double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0 + -1.0;
	} else {
		tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0 + -1.0;
	} else {
		tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0 + -1.0
	else:
		tmp = ((a * a) + 1.0) * ((a * a) + -1.0)
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0)))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = Float64(t_0 + -1.0);
	else
		tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0 + -1.0;
	else
		tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.0), $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:\\
\;\;\;\;t_0 + -1\\

\mathbf{else}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\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-def9.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. +-commutative9.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-eval9.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. Simplified9.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 inf 96.9%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. metadata-eval96.9%

        \[\leadsto {a}^{\color{blue}{\left(2 + 2\right)}} + -1 \]
      2. pow-prod-up96.9%

        \[\leadsto \color{blue}{{a}^{2} \cdot {a}^{2}} + -1 \]
      3. pow296.9%

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

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      5. difference-of-sqr--196.9%

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

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

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

Alternative 3: 96.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;-1 + {a}^{4}\\

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


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

    1. Initial program 84.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-neg84.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-def84.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-def84.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. +-commutative84.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-eval84.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. Simplified84.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 a around inf 96.7%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]

    if 4e8 < (*.f64 b b)

    1. Initial program 65.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-neg65.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-def65.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-def70.4%

        \[\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. +-commutative70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 96.6% accurate, 6.7× speedup?

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

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

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


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

    1. Initial program 84.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-neg84.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-def84.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-def84.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. +-commutative84.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-eval84.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. Simplified84.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 a around inf 96.7%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. metadata-eval96.7%

        \[\leadsto {a}^{\color{blue}{\left(2 + 2\right)}} + -1 \]
      2. pow-prod-up96.6%

        \[\leadsto \color{blue}{{a}^{2} \cdot {a}^{2}} + -1 \]
      3. pow296.6%

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

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      5. difference-of-sqr--196.6%

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

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

    if 4e8 < (*.f64 b b)

    1. Initial program 65.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-neg65.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-def65.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-def70.4%

        \[\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. +-commutative70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 71.7% accurate, 8.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.000000000000002e-309 or 580 < a

    1. Initial program 68.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-neg68.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-def68.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-def71.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. +-commutative71.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-eval71.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. Simplified71.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 a around inf 76.4%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. metadata-eval76.4%

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

        \[\leadsto \color{blue}{{a}^{2} \cdot {a}^{2}} + -1 \]
      3. pow276.3%

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

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

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

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

    if -1.000000000000002e-309 < a < 580

    1. Initial program 100.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-neg100.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-def100.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-def100.0%

        \[\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. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto b \cdot \color{blue}{\left(4 \cdot \left(a \cdot b\right)\right)} + -1 \]
    11. Step-by-step derivation
      1. associate-*r*57.0%

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

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

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

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

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

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

Alternative 6: 83.7% accurate, 8.5× speedup?

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

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

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


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

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

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

        \[\leadsto {a}^{\color{blue}{\left(2 + 2\right)}} + -1 \]
      2. pow-prod-up92.0%

        \[\leadsto \color{blue}{{a}^{2} \cdot {a}^{2}} + -1 \]
      3. pow292.0%

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

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      5. difference-of-sqr--192.0%

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

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

    if 5.00000000000000018e61 < (*.f64 b b)

    1. Initial program 63.3%

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

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

        \[\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-def68.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. +-commutative68.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-eval68.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. Simplified68.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 inf 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \color{blue}{\left(\left(2 \cdot a\right) \cdot \left(b \cdot b\right)\right)} + -1 \]
      10. *-commutative73.0%

        \[\leadsto a \cdot \left(\color{blue}{\left(a \cdot 2\right)} \cdot \left(b \cdot b\right)\right) + -1 \]
      11. associate-*l*73.0%

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

        \[\leadsto a \cdot \left(a \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot 2\right)}\right) + -1 \]
      13. associate-*l*73.0%

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

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

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

Alternative 7: 61.6% accurate, 9.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -4.999999999999985e-310

    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 72.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(a \cdot \left(a \cdot 4\right) + \left(\color{blue}{\left(-4\right)} \cdot a\right) \cdot \left(a \cdot a\right)\right) + -1 \]
      7. distribute-lft-neg-in59.9%

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

        \[\leadsto \left(a \cdot \left(a \cdot 4\right) + \left(-\color{blue}{a \cdot 4}\right) \cdot \left(a \cdot a\right)\right) + -1 \]
      9. distribute-lft-neg-in59.9%

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

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

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

        \[\leadsto \left(a \cdot \left(a \cdot 4\right) + \left(-a\right) \cdot \color{blue}{\left(a \cdot \left(a \cdot 4\right)\right)}\right) + -1 \]
      13. distribute-rgt1-in59.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < a < 6.79999999999999965e150

    1. Initial program 90.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-neg90.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-def90.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-def96.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. +-commutative96.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-eval96.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. Simplified96.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 b around inf 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto b \cdot \color{blue}{\left(4 \cdot \left(a \cdot b\right)\right)} + -1 \]
    11. Step-by-step derivation
      1. associate-*r*51.5%

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

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

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

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

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

    if 6.79999999999999965e150 < 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-def0.0%

        \[\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. +-commutative0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 54.4% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 72.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-neg72.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-def72.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-def72.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. +-commutative72.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-eval72.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. Simplified72.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 95.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(a \cdot \left(a \cdot 4\right) + \left(\color{blue}{\left(-4\right)} \cdot a\right) \cdot \left(a \cdot a\right)\right) + -1 \]
      7. distribute-lft-neg-in71.8%

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

        \[\leadsto \left(a \cdot \left(a \cdot 4\right) + \left(-\color{blue}{a \cdot 4}\right) \cdot \left(a \cdot a\right)\right) + -1 \]
      9. distribute-lft-neg-in71.8%

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

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

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

        \[\leadsto \left(a \cdot \left(a \cdot 4\right) + \left(-a\right) \cdot \color{blue}{\left(a \cdot \left(a \cdot 4\right)\right)}\right) + -1 \]
      13. distribute-rgt1-in71.8%

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

        \[\leadsto \color{blue}{\left(1 + \left(-a\right)\right)} \cdot \left(a \cdot \left(a \cdot 4\right)\right) + -1 \]
      15. sub-neg71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < a

    1. Initial program 76.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-neg76.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-def76.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-def80.0%

        \[\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. +-commutative80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 50.6% accurate, 14.0× speedup?

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

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

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


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

    1. Initial program 53.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-neg53.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-def53.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-def58.0%

        \[\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. +-commutative58.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.419999999999999984 < a < 0.0800000000000000017

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg99.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-def99.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-def99.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. +-commutative99.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-eval99.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. Simplified99.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 98.3%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 50.7% accurate, 18.3× speedup?

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

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

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

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

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

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

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

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

    \[\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 53.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*53.5%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 25.1% 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 75.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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