Bouland and Aaronson, Equation (24)

Percentage Accurate: 74.6% → 98.5%
Time: 5.6s
Alternatives: 9
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(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 9 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.6% 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.5% 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}:\\ \;\;\;\;-1 + {a}^{4}\\ \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))
   (+ -1.0 (pow a 4.0))))
double code(double a, double b) {
	double tmp;
	if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (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 = -1.0 + pow(a, 4.0);
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(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(-1.0 + (a ^ 4.0));
	end
	return tmp
end
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(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[(-1.0 + N[Power[a, 4.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}:\\
\;\;\;\;-1 + {a}^{4}\\


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

    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. associate--l+99.9%

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

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

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

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

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

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

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

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

Alternative 2: 98.4% 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}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0
         (+
          (pow (+ (* a a) (* b b)) 2.0)
          (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
   (if (<= t_0 INFINITY) (+ t_0 -1.0) (+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
	double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0 + -1.0;
	} else {
		tmp = -1.0 + pow(a, 4.0);
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0 + -1.0;
	} else {
		tmp = -1.0 + Math.pow(a, 4.0);
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0 + -1.0
	else:
		tmp = -1.0 + math.pow(a, 4.0)
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(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(-1.0 + (a ^ 4.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0 + -1.0;
	else
		tmp = -1.0 + (a ^ 4.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(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[(-1.0 + N[Power[a, 4.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}:\\
\;\;\;\;-1 + {a}^{4}\\


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

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

    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-def6.8%

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

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

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

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

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

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

Alternative 3: 80.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 72.4%

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

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

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

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

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

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

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

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

    if 1.3000000000000001e51 < b

    1. Initial program 68.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-neg68.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-def68.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-def70.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. +-commutative70.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-eval70.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. Simplified70.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.3 \cdot 10^{+51}:\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]

Alternative 4: 68.7% accurate, 1.2× speedup?

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

\\
-1 + {a}^{4}
\end{array}
Derivation
  1. Initial program 71.4%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  5. Final simplification67.4%

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

Alternative 5: 61.1% accurate, 4.7× speedup?

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

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

\mathbf{elif}\;a \leq 2.4:\\
\;\;\;\;-1 + a \cdot \left(4 \cdot \frac{a \cdot a - \left(a \cdot a\right) \cdot \left(a \cdot a\right)}{a + a \cdot a}\right)\\

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


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

    1. Initial program 40.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-neg40.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-def40.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-def40.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. +-commutative40.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-eval40.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. Simplified40.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 100.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*100.0%

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

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

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

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

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

    if -2.00000000000000007e154 < a < 2.39999999999999991

    1. Initial program 93.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-neg93.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-def93.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-def93.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \left(a \cdot 4 + \color{blue}{\left(-a\right) \cdot \left(a \cdot 4\right)}\right) + -1 \]
      18. distribute-rgt1-in43.5%

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

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

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

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

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

      \[\leadsto \color{blue}{a \cdot \left(4 \cdot \left(a - a \cdot a\right)\right)} + -1 \]
    10. Step-by-step derivation
      1. sub-neg43.5%

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

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

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

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

        \[\leadsto a \cdot \left(4 \cdot \frac{a \cdot a - \left(a \cdot \left(-a\right)\right) \cdot \left(a \cdot \left(-a\right)\right)}{a - \color{blue}{a \cdot \left(-a\right)}}\right) + -1 \]
    11. Applied egg-rr47.0%

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

    if 2.39999999999999991 < a

    1. Initial program 35.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-neg35.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-def35.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-def42.3%

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

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

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

      \[\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 26.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*26.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {\left(a \cdot a\right)}^{\color{blue}{\left(\sqrt{4}\right)}}\right)}{a + a \cdot a} + -1 \]
      6. pow-prod-down0.1%

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - \color{blue}{{a}^{\left(\sqrt{4}\right)} \cdot {a}^{\left(\sqrt{4}\right)}}\right)}{a + a \cdot a} + -1 \]
      7. pow-prod-up0.1%

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

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

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

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {a}^{\color{blue}{4}}\right)}{a + a \cdot a} + -1 \]
      11. distribute-rgt1-in0.1%

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {a}^{4}\right)}{\color{blue}{\left(a + 1\right) \cdot a}} + -1 \]
    11. Applied egg-rr0.1%

      \[\leadsto \color{blue}{\frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {a}^{4}\right)}{\left(a + 1\right) \cdot a}} + -1 \]
    12. Step-by-step derivation
      1. associate-/l*0.1%

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

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

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

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

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

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

        \[\leadsto \frac{4}{\frac{\frac{\left(a + 1\right) \cdot a}{a \cdot a - \color{blue}{\left(a \cdot a\right) \cdot \left(a \cdot a\right)}}}{a}} + -1 \]
      8. difference-of-squares0.1%

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

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

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

        \[\leadsto \frac{4}{\frac{\frac{\color{blue}{1}}{a - a \cdot a}}{a}} + -1 \]
    13. Simplified0.1%

      \[\leadsto \color{blue}{\frac{4}{\frac{\frac{1}{a - a \cdot a}}{a}}} + -1 \]
    14. Step-by-step derivation
      1. div-inv0.1%

        \[\leadsto \color{blue}{4 \cdot \frac{1}{\frac{\frac{1}{a - a \cdot a}}{a}}} + -1 \]
      2. associate-/l/0.1%

        \[\leadsto 4 \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot \left(a - a \cdot a\right)}}} + -1 \]
      3. remove-double-div0.1%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(4 \cdot a\right) \cdot \color{blue}{\left(\sqrt{-a} \cdot \sqrt{-a}\right)}\right) \cdot \left(1 - a\right) + -1 \]
      12. add-sqr-sqrt66.9%

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

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

        \[\leadsto \left(4 \cdot \color{blue}{\left(\left(-a\right) \cdot a\right)}\right) \cdot \left(1 - a\right) + -1 \]
      15. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto \left(4 \cdot \left(\color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} \cdot a\right)\right) \cdot \left(1 - a\right) + -1 \]
      19. add-sqr-sqrt0.1%

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

        \[\leadsto \left(4 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(1 + \left(-a\right)\right)} + -1 \]
      21. add-sqr-sqrt0.0%

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

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

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

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

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

Alternative 6: 55.3% accurate, 9.8× speedup?

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

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

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


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

    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 58.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*58.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.39999999999999991 < a

    1. Initial program 35.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-neg35.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-def35.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-def42.3%

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

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

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

      \[\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 26.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*26.6%

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

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

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

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

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

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

Alternative 7: 59.4% accurate, 9.8× speedup?

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

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

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


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

    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 58.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*58.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.39999999999999991 < a

    1. Initial program 35.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-neg35.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-def35.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-def42.3%

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

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

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

      \[\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 26.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*26.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {\left(a \cdot a\right)}^{\color{blue}{\left(\sqrt{4}\right)}}\right)}{a + a \cdot a} + -1 \]
      6. pow-prod-down0.1%

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - \color{blue}{{a}^{\left(\sqrt{4}\right)} \cdot {a}^{\left(\sqrt{4}\right)}}\right)}{a + a \cdot a} + -1 \]
      7. pow-prod-up0.1%

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

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

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

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {a}^{\color{blue}{4}}\right)}{a + a \cdot a} + -1 \]
      11. distribute-rgt1-in0.1%

        \[\leadsto \frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {a}^{4}\right)}{\color{blue}{\left(a + 1\right) \cdot a}} + -1 \]
    11. Applied egg-rr0.1%

      \[\leadsto \color{blue}{\frac{\left(a \cdot 4\right) \cdot \left(a \cdot a - {a}^{4}\right)}{\left(a + 1\right) \cdot a}} + -1 \]
    12. Step-by-step derivation
      1. associate-/l*0.1%

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

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

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

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

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

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

        \[\leadsto \frac{4}{\frac{\frac{\left(a + 1\right) \cdot a}{a \cdot a - \color{blue}{\left(a \cdot a\right) \cdot \left(a \cdot a\right)}}}{a}} + -1 \]
      8. difference-of-squares0.1%

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

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

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

        \[\leadsto \frac{4}{\frac{\frac{\color{blue}{1}}{a - a \cdot a}}{a}} + -1 \]
    13. Simplified0.1%

      \[\leadsto \color{blue}{\frac{4}{\frac{\frac{1}{a - a \cdot a}}{a}}} + -1 \]
    14. Step-by-step derivation
      1. div-inv0.1%

        \[\leadsto \color{blue}{4 \cdot \frac{1}{\frac{\frac{1}{a - a \cdot a}}{a}}} + -1 \]
      2. associate-/l/0.1%

        \[\leadsto 4 \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot \left(a - a \cdot a\right)}}} + -1 \]
      3. remove-double-div0.1%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(4 \cdot a\right) \cdot \color{blue}{\left(\sqrt{-a} \cdot \sqrt{-a}\right)}\right) \cdot \left(1 - a\right) + -1 \]
      12. add-sqr-sqrt66.9%

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

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

        \[\leadsto \left(4 \cdot \color{blue}{\left(\left(-a\right) \cdot a\right)}\right) \cdot \left(1 - a\right) + -1 \]
      15. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto \left(4 \cdot \left(\color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} \cdot a\right)\right) \cdot \left(1 - a\right) + -1 \]
      19. add-sqr-sqrt0.1%

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

        \[\leadsto \left(4 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(1 + \left(-a\right)\right)} + -1 \]
      21. add-sqr-sqrt0.0%

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

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

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

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

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

Alternative 8: 55.2% 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 + \left(a \cdot a\right) \cdot 4\\ \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(Float64(a * 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[(N[(a * a), $MachinePrecision] * 4.0), $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 + \left(a \cdot a\right) \cdot 4\\


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

    1. Initial program 55.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-neg55.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-def55.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-def55.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. +-commutative55.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-eval55.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. Simplified55.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 88.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \left(a \cdot 4 + \color{blue}{\left(-a\right) \cdot \left(a \cdot 4\right)}\right) + -1 \]
      18. distribute-rgt1-in68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < a

    1. Initial program 76.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-neg76.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-def76.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-def78.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. +-commutative78.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-eval78.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. Simplified78.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 37.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \left(a \cdot a\right)} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.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 + \left(a \cdot a\right) \cdot 4\\ \end{array} \]

Alternative 9: 51.3% accurate, 18.3× speedup?

\[\begin{array}{l} \\ -1 + \left(a \cdot a\right) \cdot 4 \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(Float64(a * a) * 4.0))
end
function tmp = code(a, b)
	tmp = -1.0 + ((a * a) * 4.0);
end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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