Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.5% → 99.2%
Time: 8.1s
Alternatives: 7
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 7 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.5% 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.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (+ (+ (pow (hypot b a) 4.0) (* 4.0 (+ (* a a) (* (* b b) 3.0)))) -1.0))
double code(double a, double b) {
	return (pow(hypot(b, a), 4.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0;
}
public static double code(double a, double b) {
	return (Math.pow(Math.hypot(b, a), 4.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0;
}
def code(a, b):
	return (math.pow(math.hypot(b, a), 4.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0
function code(a, b)
	return Float64(Float64((hypot(b, a) ^ 4.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0)))) + -1.0)
end
function tmp = code(a, b)
	tmp = ((hypot(b, a) ^ 4.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0;
end
code[a_, b_] := N[(N[(N[Power[N[Sqrt[b ^ 2 + a ^ 2], $MachinePrecision], 4.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(\mathsf{hypot}\left(b, a\right)\right)}^{4} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1
\end{array}
Derivation
  1. Initial program 69.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.9%

    \[\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. Step-by-step derivation
    1. unpow299.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(\color{blue}{\left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{2} \cdot {b}^{2} + {\left(\mathsf{hypot}\left(b, a\right)\right)}^{2} \cdot {a}^{2}\right)} + 4 \cdot \left(\left(a \cdot a\right) \cdot 1 + \left(b \cdot b\right) \cdot 3\right)\right) - 1 \]
  7. Step-by-step derivation
    1. distribute-lft-out99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 74.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. Add Preprocessing
    3. Taylor expanded in a around 0 99.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 0 99.8%

      \[\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. Taylor expanded in a around inf 98.3%

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

    if 1.99999999999999995e38 < (*.f64 b b)

    1. Initial program 64.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+64.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-define64.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-neg64.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-define64.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-in64.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-neg64.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-in64.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-define64.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-neg64.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. Simplified69.7%

      \[\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 inf 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.1% accurate, 1.0× speedup?

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

\\
\left(4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + -1
\end{array}
Derivation
  1. Initial program 69.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.9%

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

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

Alternative 4: 94.2% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4e16 or 8e20 < a

    1. Initial program 39.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+39.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-define39.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-neg39.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-define39.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-in39.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-neg39.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-in39.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-define39.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-neg39.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. Simplified45.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 inf 92.5%

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

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

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

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

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

    if -4e16 < a < 8e20

    1. Initial program 99.1%

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

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

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

        \[\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-define99.1%

        \[\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-in99.1%

        \[\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-neg99.1%

        \[\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-in99.1%

        \[\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-define99.1%

        \[\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-neg99.1%

        \[\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. Simplified99.1%

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

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

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

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

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

Alternative 5: 82.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -2.9 \cdot 10^{+19} \lor \neg \left(a \leq 2.3 \cdot 10^{+20}\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.9e+19) (not (<= a 2.3e+20)))
   (pow a 4.0)
   (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -2.9e+19) || !(a <= 2.3e+20)) {
		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.9d+19)) .or. (.not. (a <= 2.3d+20))) 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.9e+19) || !(a <= 2.3e+20)) {
		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.9e+19) or not (a <= 2.3e+20):
		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.9e+19) || !(a <= 2.3e+20))
		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.9e+19) || ~((a <= 2.3e+20)))
		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.9e+19], N[Not[LessEqual[a, 2.3e+20]], $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.9 \cdot 10^{+19} \lor \neg \left(a \leq 2.3 \cdot 10^{+20}\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.9e19 or 2.3e20 < a

    1. Initial program 39.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+39.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-define39.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-neg39.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-define39.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-in39.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-neg39.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-in39.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-define39.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-neg39.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. Simplified45.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 inf 92.5%

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

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

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

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

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

    if -2.9e19 < a < 2.3e20

    1. Initial program 99.1%

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

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

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

        \[\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-define99.1%

        \[\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-in99.1%

        \[\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-neg99.1%

        \[\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-in99.1%

        \[\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-define99.1%

        \[\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-neg99.1%

        \[\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. Simplified99.1%

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

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

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

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

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

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

Alternative 6: 51.8% 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 69.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+69.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-define69.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. sqr-neg69.4%

      \[\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-define69.4%

      \[\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-in69.4%

      \[\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-neg69.4%

      \[\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-in69.4%

      \[\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-define69.4%

      \[\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-neg69.4%

      \[\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. Simplified72.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 70.2%

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

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

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

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

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

Alternative 7: 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 69.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+69.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-define69.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. sqr-neg69.4%

      \[\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-define69.4%

      \[\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-in69.4%

      \[\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-neg69.4%

      \[\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-in69.4%

      \[\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-define69.4%

      \[\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-neg69.4%

      \[\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. Simplified72.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 70.2%

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

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

Reproduce

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