Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.4% → 99.1%
Time: 7.7s
Alternatives: 8
Speedup: 1.1×

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: 73.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: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (+
  (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* (* b b) 3.0))))
  -1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -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) + ((b * b) * 3.0d0)))) + (-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) + ((b * b) * 3.0)))) + -1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0)))) + -1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -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[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1
\end{array}
Derivation
  1. Initial program 76.4%

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

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

    \[\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}{3}\right)\right) - 1 \]
  5. Final simplification99.1%

    \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1 \]
  6. Add Preprocessing

Alternative 2: 94.0% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 67.0%

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

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

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg67.0%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in67.0%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified67.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 94.9%

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

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

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

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

    if -10500 < a < 4.5e17

    1. Initial program 99.9%

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

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

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

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified99.9%

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

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

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

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

    if 4.5e17 < a

    1. Initial program 21.4%

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

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

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg21.4%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in21.4%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified27.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 inf 96.4%

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

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

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

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

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

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

Alternative 3: 82.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -490 \lor \neg \left(a \leq 215\right):\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\

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


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

    1. Initial program 47.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+47.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-define47.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. distribute-rgt-in47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified50.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 inf 93.7%

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

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

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

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

    if -490 < a < 215

    1. Initial program 99.9%

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

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

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

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified99.9%

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

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

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

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} - 1 \]
    8. Simplified72.5%

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

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

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

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

Alternative 4: 82.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -380 \lor \neg \left(a \leq 1720\right):\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\

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


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

    1. Initial program 47.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+47.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-define47.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. distribute-rgt-in47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified50.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 inf 93.7%

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

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

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

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

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

    if -380 < a < 1720

    1. Initial program 99.9%

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

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

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

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified99.9%

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

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

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

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} - 1 \]
    8. Simplified72.5%

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

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

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

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

Alternative 5: 81.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -50000 \lor \neg \left(a \leq 54000\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 -50000.0) (not (<= a 54000.0)))
   (pow a 4.0)
   (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -50000.0) || !(a <= 54000.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 <= (-50000.0d0)) .or. (.not. (a <= 54000.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 <= -50000.0) || !(a <= 54000.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 <= -50000.0) or not (a <= 54000.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 <= -50000.0) || !(a <= 54000.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 <= -50000.0) || ~((a <= 54000.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, -50000.0], N[Not[LessEqual[a, 54000.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 -50000 \lor \neg \left(a \leq 54000\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 < -5e4 or 54000 < a

    1. Initial program 47.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+47.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-define47.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. distribute-rgt-in47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in47.7%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified50.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 inf 93.7%

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

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

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

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

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

    if -5e4 < a < 54000

    1. Initial program 99.9%

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

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

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

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in99.9%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified99.9%

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

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

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

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} - 1 \]
    8. Simplified72.5%

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

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

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

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

Alternative 6: 63.1% accurate, 8.0× speedup?

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

    1. Initial program 53.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+53.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-define53.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. distribute-rgt-in53.8%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg53.8%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in53.8%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified53.8%

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

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

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

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\frac{\left(a \cdot a\right) \cdot \left(a \cdot a\right) - \left(b \cdot b\right) \cdot \left(b \cdot b\right)}{a \cdot a - b \cdot b}} + \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. associate-*r/5.1%

        \[\leadsto \color{blue}{\frac{\left(a \cdot a + b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) - \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right)}{a \cdot a - b \cdot b}} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right) - 1\right) \]
    6. Applied egg-rr5.1%

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left({a}^{4} - {b}^{4}\right)}{{a}^{2} - {b}^{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) \]
    7. Taylor expanded in a around 0 48.7%

      \[\leadsto \frac{\color{blue}{-1 \cdot {b}^{6}}}{{a}^{2} - {b}^{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) \]
    8. Step-by-step derivation
      1. mul-1-neg48.7%

        \[\leadsto \frac{\color{blue}{-{b}^{6}}}{{a}^{2} - {b}^{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) \]
    9. Simplified48.7%

      \[\leadsto \frac{\color{blue}{-{b}^{6}}}{{a}^{2} - {b}^{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) \]
    10. Taylor expanded in b around 0 97.7%

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

        \[\leadsto 4 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right)\right) - 1 \]
    12. Applied egg-rr97.7%

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

    if -4.2000000000000002e99 < a

    1. Initial program 80.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+80.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-define80.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. distribute-rgt-in80.5%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      4. sqr-neg80.5%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
      5. distribute-rgt-in80.5%

        \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    3. Simplified81.9%

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

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

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

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} - 1 \]
    8. Simplified51.9%

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

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

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

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

Alternative 7: 51.3% 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 76.4%

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

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

      \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    4. sqr-neg76.4%

      \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    5. distribute-rgt-in76.4%

      \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
  3. Simplified77.6%

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

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

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

      \[\leadsto \color{blue}{{b}^{2} \cdot 12} - 1 \]
  8. Simplified48.5%

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

      \[\leadsto \left(12 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
  10. Applied egg-rr48.5%

    \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot 12 - 1 \]
  11. Final simplification48.5%

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

Alternative 8: 25.1% accurate, 128.0× speedup?

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

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

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

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

      \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    4. sqr-neg76.4%

      \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
    5. distribute-rgt-in76.4%

      \[\leadsto {\left(\mathsf{fma}\left(a, a, b \cdot 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) \]
  3. Simplified77.6%

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

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

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

Reproduce

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