Bouland and Aaronson, Equation (24)

Percentage Accurate: 74.4% → 97.7%
Time: 7.4s
Alternatives: 8
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 97.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 79.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 96.5%

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

    if 1.0000000000000001e128 < (*.f64 b b)

    1. Initial program 63.2%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+63.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(3 + a\right)\right) - 1\right)} \]
      2. fma-define63.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 79.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 96.5%

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

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

    if 1.0000000000000001e128 < (*.f64 b b)

    1. Initial program 63.2%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+63.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(3 + a\right)\right) - 1\right)} \]
      2. fma-define63.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.4% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 81.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+81.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(3 + a\right)\right) - 1\right)} \]
      2. fma-define81.3%

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000001e55 < (*.f64 b b)

    1. Initial program 63.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.5% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 46.5%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+46.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(3 + a\right)\right) - 1\right)} \]
      2. fma-define46.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 - \frac{4}{a}\right)} \]
    8. Taylor expanded in a around inf 89.4%

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

    if -2.2e22 < a < 70

    1. Initial program 96.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+96.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(3 + a\right)\right) - 1\right)} \]
      2. fma-define96.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{12 \cdot {b}^{2} - 1} \]
    7. Step-by-step derivation
      1. pow276.2%

        \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
    8. Applied egg-rr76.2%

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

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

Alternative 5: 93.4% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 81.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 96.8%

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

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

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

    if 1.00000000000000001e55 < (*.f64 b b)

    1. Initial program 63.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 63.4% accurate, 8.0× speedup?

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

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

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


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

    1. Initial program 70.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+70.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(3 + a\right)\right) - 1\right)} \]
      2. fma-define70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7000000000000001e102 < a

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 51.4% accurate, 18.3× speedup?

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

\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Derivation
  1. Initial program 73.3%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+73.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(3 + a\right)\right) - 1\right)} \]
    2. fma-define73.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 12 \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
  9. Final simplification52.4%

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

Alternative 8: 24.6% accurate, 128.0× speedup?

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

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

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+73.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(3 + a\right)\right) - 1\right)} \]
    2. fma-define73.3%

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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