Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.6% → 99.2%
Time: 6.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(1 - 3 \cdot a\right)\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (-
  (+
   (pow (+ (* a a) (* b b)) 2.0)
   (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
  1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

Alternative 1: 99.2% accurate, 0.4× speedup?

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

\\
\mathsf{fma}\left(2, b \cdot \left(b \cdot \left(a \cdot a\right)\right), {b}^{4} + {a}^{4}\right) + \left(4 \cdot \left(b \cdot b\right) + -1\right)
\end{array}
Derivation
  1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

Alternative 3: 99.2% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000005e-196 < (*.f64 b b)

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.4% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.299999999999999989 < a < 6.50000000000000043e-22

    1. Initial program 99.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4} - 1\right) \]
      4. sub-neg100.0%

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

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

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

        \[\leadsto \color{blue}{4 \cdot \left(b \cdot b\right) + \left({b}^{4} + -1\right)} \]
    8. Applied egg-rr100.0%

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

    if 6.50000000000000043e-22 < a

    1. Initial program 56.6%

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

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

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

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

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

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

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

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

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

Alternative 5: 94.0% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.299999999999999989 < a < 3.5e21

    1. Initial program 99.1%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, {b}^{4} - 1\right) \]
      4. sub-neg98.9%

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

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

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

        \[\leadsto \color{blue}{4 \cdot \left(b \cdot b\right) + \left({b}^{4} + -1\right)} \]
    8. Applied egg-rr98.9%

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

    if 3.5e21 < a

    1. Initial program 53.3%

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

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

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

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

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

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

Alternative 6: 70.2% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -19000000000000:\\
\;\;\;\;{a}^{4}\\

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

\mathbf{elif}\;a \leq 1.2 \cdot 10^{-246}:\\
\;\;\;\;-1\\

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

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

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


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

    1. Initial program 45.6%

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

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

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

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

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

    if -1.9e13 < a < -9.1999999999999993e-249 or 1.1999999999999999e-246 < a < 2.20000000000000004e-113

    1. Initial program 99.8%

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

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

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

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

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

    if -9.1999999999999993e-249 < a < 1.1999999999999999e-246 or 2.20000000000000004e-113 < a < 0.419999999999999984

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -19000000000000:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -9.2 \cdot 10^{-249}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-246}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq 2.2 \cdot 10^{-113}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 0.42:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 7: 93.6% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999999e64 < (*.f64 b b)

    1. Initial program 60.5%

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

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

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

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

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

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

Alternative 8: 69.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5:\\
\;\;\;\;{a}^{4}\\

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

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


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

    1. Initial program 45.6%

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

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

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

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

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

    if -2.5 < a < 0.419999999999999984

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2.5:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 0.42:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 9: 25.1% accurate, 130.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
	return -1.0;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -1.0d0
end function
public static double code(double a, double b) {
	return -1.0;
}
def code(a, b):
	return -1.0
function code(a, b)
	return -1.0
end
function tmp = code(a, b)
	tmp = -1.0;
end
code[a_, b_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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