Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.2% → 99.9%
Time: 8.4s
Alternatives: 10
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 10 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.2% 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.9% accurate, 0.3× 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 \cdot 3 + -1\right)\right) \leq \infty:\\ \;\;\;\;\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<=
      (-
       (pow (+ (* a a) (* b b)) 2.0)
       (* 4.0 (+ (* (* a a) (- -1.0 a)) (* (* b b) (+ (* a 3.0) -1.0)))))
      INFINITY)
   (+
    (+
     (* 4.0 (fma (* a a) (+ a 1.0) (* b (* b (+ 1.0 (* a -3.0))))))
     (pow (fma a a (* b b)) 2.0))
    -1.0)
   (* (pow a 4.0) (+ 1.0 (/ (+ 4.0 (/ (+ 4.0 (* (* b b) 2.0)) a)) a)))))
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) + -1.0))))) <= ((double) INFINITY)) {
		tmp = ((4.0 * fma((a * a), (a + 1.0), (b * (b * (1.0 + (a * -3.0)))))) + pow(fma(a, a, (b * b)), 2.0)) + -1.0;
	} else {
		tmp = pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
	}
	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(Float64(a * 3.0) + -1.0))))) <= Inf)
		tmp = Float64(Float64(Float64(4.0 * fma(Float64(a * a), Float64(a + 1.0), Float64(b * Float64(b * Float64(1.0 + Float64(a * -3.0)))))) + (fma(a, a, Float64(b * b)) ^ 2.0)) + -1.0);
	else
		tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(Float64(4.0 + Float64(Float64(b * b) * 2.0)) / a)) / a)));
	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[(N[(a * 3.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision] + N[(b * N[(b * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(N[(4.0 + N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $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 \cdot 3 + -1\right)\right) \leq \infty:\\
\;\;\;\;\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) 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 \]
    2. Step-by-step derivation
      1. sub-neg99.8%

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

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

    if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) 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. +-commutative0.0%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative0.0%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg0.0%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+0.0%

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

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

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

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

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

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

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

    \[\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 \cdot 3 + -1\right)\right) \leq \infty:\\ \;\;\;\;\left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right) + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\ \end{array} \]
  5. Add Preprocessing

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) 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 \]
    2. Add Preprocessing

    if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) 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. +-commutative0.0%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative0.0%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg0.0%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+0.0%

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

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

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

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

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

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

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

    \[\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 \cdot 3 + -1\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 \cdot 3 + -1\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 98.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -5.8 \lor \neg \left(a \leq 2.6\right):\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -5.8) (not (<= a 2.6)))
   (* (pow a 4.0) (+ 1.0 (/ (+ 4.0 (/ (+ 4.0 (* (* b b) 2.0)) a)) a)))
   (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))))
double code(double a, double b) {
	double tmp;
	if ((a <= -5.8) || !(a <= 2.6)) {
		tmp = pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
	} else {
		tmp = -1.0 + (((b * b) * 4.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 ((a <= (-5.8d0)) .or. (.not. (a <= 2.6d0))) then
        tmp = (a ** 4.0d0) * (1.0d0 + ((4.0d0 + ((4.0d0 + ((b * b) * 2.0d0)) / a)) / a))
    else
        tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((a <= -5.8) || !(a <= 2.6)) {
		tmp = Math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
	} else {
		tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -5.8) or not (a <= 2.6):
		tmp = math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a))
	else:
		tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -5.8) || !(a <= 2.6))
		tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(Float64(4.0 + Float64(Float64(b * b) * 2.0)) / a)) / a)));
	else
		tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -5.8) || ~((a <= 2.6)))
		tmp = (a ^ 4.0) * (1.0 + ((4.0 + ((4.0 + ((b * b) * 2.0)) / a)) / a));
	else
		tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -5.8], N[Not[LessEqual[a, 2.6]], $MachinePrecision]], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(N[(4.0 + N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.8 \lor \neg \left(a \leq 2.6\right):\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\

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


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

    1. Initial program 52.2%

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

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

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative52.2%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg52.2%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+52.2%

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

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

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

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

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

        \[\leadsto {a}^{4} \cdot \left(1 + -1 \cdot \frac{-1 \cdot \frac{4 + 2 \cdot \color{blue}{\left(b \cdot b\right)}}{a} - 4}{a}\right) \]
    7. Applied egg-rr97.0%

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

    if -5.79999999999999982 < a < 2.60000000000000009

    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. +-commutative99.9%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative99.9%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg99.9%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+99.9%

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

        \[\leadsto 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) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. fma-define99.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.8 \lor \neg \left(a \leq 2.6\right):\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + \left(b \cdot b\right) \cdot 2}{a}}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 94.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\

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

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


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

    1. Initial program 17.2%

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

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

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative17.2%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg17.2%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+17.2%

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + -1 \cdot \frac{-1 \cdot \frac{4 + 2 \cdot {b}^{2}}{a} - 4}{a}\right)} \]
    6. Taylor expanded in a around inf 94.6%

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

    if -1.8e22 < a < 5e5

    1. Initial program 98.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+98.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. +-commutative98.4%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative98.4%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg98.4%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+98.4%

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

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

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

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

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

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

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

    if 5e5 < a

    1. Initial program 75.3%

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

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

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative75.3%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg75.3%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+75.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} - 1\right)} \]
    9. Applied egg-rr95.3%

      \[\leadsto {a}^{4} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. sub-neg95.3%

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

        \[\leadsto {a}^{4} \cdot \left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} + \color{blue}{-1}\right) \]
      3. +-commutative95.3%

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)}\right)} \]
      4. log1p-undefine95.3%

        \[\leadsto {a}^{4} \cdot \left(-1 + e^{\color{blue}{\log \left(1 + \left(1 + \frac{4}{a}\right)\right)}}\right) \]
      5. rem-exp-log95.3%

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

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

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

      \[\leadsto {a}^{4} \cdot \color{blue}{\left(-1 + \left(2 + \frac{4}{a}\right)\right)} \]
    12. Step-by-step derivation
      1. expm1-log1p-u94.9%

        \[\leadsto {a}^{4} \cdot \left(-1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(2 + \frac{4}{a}\right)\right)}\right) \]
      2. expm1-undefine94.9%

        \[\leadsto {a}^{4} \cdot \left(-1 + \color{blue}{\left(e^{\mathsf{log1p}\left(2 + \frac{4}{a}\right)} - 1\right)}\right) \]
    13. Applied egg-rr94.9%

      \[\leadsto {a}^{4} \cdot \left(-1 + \color{blue}{\left(e^{\mathsf{log1p}\left(2 + \frac{4}{a}\right)} - 1\right)}\right) \]
    14. Step-by-step derivation
      1. sub-neg94.9%

        \[\leadsto {a}^{4} \cdot \left(-1 + \color{blue}{\left(e^{\mathsf{log1p}\left(2 + \frac{4}{a}\right)} + \left(-1\right)\right)}\right) \]
      2. log1p-undefine94.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.8 \cdot 10^{+22}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 500000:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(-1 + \left(-1 + \left(3 + \frac{4}{a}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 140000000000:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(-1 + \left(2 + \frac{4}{a}\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -1.6e+22)
   (pow a 4.0)
   (if (<= a 140000000000.0)
     (+ -1.0 (+ (* (* b b) 4.0) (pow b 4.0)))
     (* (pow a 4.0) (+ -1.0 (+ 2.0 (/ 4.0 a)))))))
double code(double a, double b) {
	double tmp;
	if (a <= -1.6e+22) {
		tmp = pow(a, 4.0);
	} else if (a <= 140000000000.0) {
		tmp = -1.0 + (((b * b) * 4.0) + pow(b, 4.0));
	} else {
		tmp = pow(a, 4.0) * (-1.0 + (2.0 + (4.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 <= (-1.6d+22)) then
        tmp = a ** 4.0d0
    else if (a <= 140000000000.0d0) then
        tmp = (-1.0d0) + (((b * b) * 4.0d0) + (b ** 4.0d0))
    else
        tmp = (a ** 4.0d0) * ((-1.0d0) + (2.0d0 + (4.0d0 / a)))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (a <= -1.6e+22) {
		tmp = Math.pow(a, 4.0);
	} else if (a <= 140000000000.0) {
		tmp = -1.0 + (((b * b) * 4.0) + Math.pow(b, 4.0));
	} else {
		tmp = Math.pow(a, 4.0) * (-1.0 + (2.0 + (4.0 / a)));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -1.6e+22:
		tmp = math.pow(a, 4.0)
	elif a <= 140000000000.0:
		tmp = -1.0 + (((b * b) * 4.0) + math.pow(b, 4.0))
	else:
		tmp = math.pow(a, 4.0) * (-1.0 + (2.0 + (4.0 / a)))
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -1.6e+22)
		tmp = a ^ 4.0;
	elseif (a <= 140000000000.0)
		tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 4.0) + (b ^ 4.0)));
	else
		tmp = Float64((a ^ 4.0) * Float64(-1.0 + Float64(2.0 + Float64(4.0 / a))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -1.6e+22)
		tmp = a ^ 4.0;
	elseif (a <= 140000000000.0)
		tmp = -1.0 + (((b * b) * 4.0) + (b ^ 4.0));
	else
		tmp = (a ^ 4.0) * (-1.0 + (2.0 + (4.0 / a)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -1.6e+22], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 140000000000.0], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(-1.0 + N[(2.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\

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

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


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

    1. Initial program 17.2%

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

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

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative17.2%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg17.2%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+17.2%

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + -1 \cdot \frac{-1 \cdot \frac{4 + 2 \cdot {b}^{2}}{a} - 4}{a}\right)} \]
    6. Taylor expanded in a around inf 94.6%

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

    if -1.6e22 < a < 1.4e11

    1. Initial program 98.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+98.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. +-commutative98.4%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative98.4%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg98.4%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+98.4%

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

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

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

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

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

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

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

    if 1.4e11 < a

    1. Initial program 75.3%

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

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

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative75.3%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg75.3%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+75.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} - 1\right)} \]
    9. Applied egg-rr95.3%

      \[\leadsto {a}^{4} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. sub-neg95.3%

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

        \[\leadsto {a}^{4} \cdot \left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} + \color{blue}{-1}\right) \]
      3. +-commutative95.3%

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)}\right)} \]
      4. log1p-undefine95.3%

        \[\leadsto {a}^{4} \cdot \left(-1 + e^{\color{blue}{\log \left(1 + \left(1 + \frac{4}{a}\right)\right)}}\right) \]
      5. rem-exp-log95.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 140000000000:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 4 + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(-1 + \left(2 + \frac{4}{a}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\
\;\;\;\;{a}^{4}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.6e22 or 5.4e8 < a

    1. Initial program 49.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+49.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. +-commutative49.5%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative49.5%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg49.5%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+49.5%

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

        \[\leadsto 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) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. fma-define49.5%

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

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

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

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

    if -1.6e22 < a < 3.29999999999999998e-152

    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. +-commutative99.9%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative99.9%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg99.9%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+99.9%

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

        \[\leadsto 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) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. fma-define99.9%

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

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

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

      \[\leadsto \color{blue}{4 \cdot {b}^{2}} - 1 \]
    7. Step-by-step derivation
      1. metadata-eval76.3%

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

        \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      3. swap-sqr76.3%

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

        \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    8. Simplified76.3%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. unpow-prod-down76.3%

        \[\leadsto \color{blue}{{2}^{2} \cdot {b}^{2}} - 1 \]
      2. metadata-eval76.3%

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

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

        \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
    10. Applied egg-rr76.3%

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

    if 3.29999999999999998e-152 < a < 5.4e8

    1. Initial program 93.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+93.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. +-commutative93.8%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative93.8%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg93.8%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+93.8%

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

        \[\leadsto 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) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. fma-define93.8%

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

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

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around inf 73.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.6 \cdot 10^{+22}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-152}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{elif}\;a \leq 540000000:\\ \;\;\;\;{b}^{4}\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 81.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+22} \lor \neg \left(a \leq 1150000\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.6e22 or 1.15e6 < a

    1. Initial program 49.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+49.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. +-commutative49.5%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative49.5%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg49.5%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+49.5%

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

        \[\leadsto 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) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. fma-define49.5%

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

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

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

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

    if -1.6e22 < a < 1.15e6

    1. Initial program 98.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+98.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. +-commutative98.4%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative98.4%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg98.4%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+98.4%

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
      3. swap-sqr72.0%

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

        \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    8. Simplified72.0%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
    9. Step-by-step derivation
      1. unpow-prod-down72.0%

        \[\leadsto \color{blue}{{2}^{2} \cdot {b}^{2}} - 1 \]
      2. metadata-eval72.0%

        \[\leadsto \color{blue}{4} \cdot {b}^{2} - 1 \]
      3. pow272.0%

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

        \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
    10. Applied egg-rr72.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.6 \cdot 10^{+22} \lor \neg \left(a \leq 1150000\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.1% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 78.5%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt78.5%

        \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\color{blue}{\left(\sqrt{a \cdot a} \cdot \sqrt{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. sqrt-unprod77.6%

        \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\color{blue}{\sqrt{\left(a \cdot a\right) \cdot \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 \]
      3. pow277.6%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + -1 \cdot \frac{-1 \cdot \frac{4 + 2 \cdot {b}^{2}}{a} - 4}{a}\right)} - 1 \]
    6. Taylor expanded in a around inf 75.7%

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

    if 3.3e7 < b

    1. Initial program 65.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+65.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. +-commutative65.8%

        \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative65.8%

        \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
      4. sub-neg65.8%

        \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+65.8%

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

        \[\leadsto 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) + \color{blue}{\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(-1\right)\right)} \]
      7. fma-define65.8%

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

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

      \[\leadsto \color{blue}{\left(4 \cdot {b}^{2} + {b}^{4}\right) - 1} \]
    6. Taylor expanded in b around inf 86.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 33000000:\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 51.0% accurate, 18.6× speedup?

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

\\
-1 + b \cdot \left(b \cdot 4\right)
\end{array}
Derivation
  1. Initial program 76.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+76.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. +-commutative76.0%

      \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative76.0%

      \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
    4. sub-neg76.0%

      \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
    5. associate-+l+76.0%

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

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

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

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

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

    \[\leadsto \color{blue}{4 \cdot {b}^{2}} - 1 \]
  7. Step-by-step derivation
    1. metadata-eval46.8%

      \[\leadsto \color{blue}{\left(2 \cdot 2\right)} \cdot {b}^{2} - 1 \]
    2. unpow246.8%

      \[\leadsto \left(2 \cdot 2\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
    3. swap-sqr46.8%

      \[\leadsto \color{blue}{\left(2 \cdot b\right) \cdot \left(2 \cdot b\right)} - 1 \]
    4. unpow246.8%

      \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
  8. Simplified46.8%

    \[\leadsto \color{blue}{{\left(2 \cdot b\right)}^{2}} - 1 \]
  9. Step-by-step derivation
    1. unpow-prod-down46.8%

      \[\leadsto \color{blue}{{2}^{2} \cdot {b}^{2}} - 1 \]
    2. metadata-eval46.8%

      \[\leadsto \color{blue}{4} \cdot {b}^{2} - 1 \]
    3. pow246.8%

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

      \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
  10. Applied egg-rr46.8%

    \[\leadsto \color{blue}{\left(4 \cdot b\right) \cdot b} - 1 \]
  11. Final simplification46.8%

    \[\leadsto -1 + b \cdot \left(b \cdot 4\right) \]
  12. Add Preprocessing

Alternative 10: 24.7% 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 76.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+76.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. +-commutative76.0%

      \[\leadsto {\color{blue}{\left(b \cdot b + a \cdot a\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. +-commutative76.0%

      \[\leadsto \color{blue}{\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) + {\left(b \cdot b + a \cdot a\right)}^{2}} \]
    4. sub-neg76.0%

      \[\leadsto \color{blue}{\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) + \left(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
    5. associate-+l+76.0%

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  7. Add Preprocessing

Reproduce

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