Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.8% → 99.9%
Time: 8.1s
Alternatives: 12
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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.8% 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.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\\ \mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(t\_0, t\_0, 4 \cdot \mathsf{fma}\left({b}^{2}, a + 3, \left(1 - a\right) \cdot {a}^{2}\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{\frac{4 + 2 \cdot {b}^{2}}{a} - 4}{a}\right) + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (pow (hypot a b) 2.0)))
   (if (<=
        (+
         (pow (+ (* a a) (* b b)) 2.0)
         (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
        INFINITY)
     (+
      (fma
       t_0
       t_0
       (* 4.0 (fma (pow b 2.0) (+ a 3.0) (* (- 1.0 a) (pow a 2.0)))))
      -1.0)
     (+
      (* (pow a 4.0) (+ 1.0 (/ (- (/ (+ 4.0 (* 2.0 (pow b 2.0))) a) 4.0) a)))
      -1.0))))
double code(double a, double b) {
	double t_0 = pow(hypot(a, b), 2.0);
	double tmp;
	if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
		tmp = fma(t_0, t_0, (4.0 * fma(pow(b, 2.0), (a + 3.0), ((1.0 - a) * pow(a, 2.0))))) + -1.0;
	} else {
		tmp = (pow(a, 4.0) * (1.0 + ((((4.0 + (2.0 * pow(b, 2.0))) / a) - 4.0) / a))) + -1.0;
	}
	return tmp;
}
function code(a, b)
	t_0 = hypot(a, b) ^ 2.0
	tmp = 0.0
	if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf)
		tmp = Float64(fma(t_0, t_0, Float64(4.0 * fma((b ^ 2.0), Float64(a + 3.0), Float64(Float64(1.0 - a) * (a ^ 2.0))))) + -1.0);
	else
		tmp = Float64(Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(Float64(Float64(4.0 + Float64(2.0 * (b ^ 2.0))) / a) - 4.0) / a))) + -1.0);
	end
	return tmp
end
code[a_, b_] := Block[{t$95$0 = N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$0 * t$95$0 + N[(4.0 * N[(N[Power[b, 2.0], $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(N[(N[(4.0 + N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] - 4.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 99.8%

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

        \[\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 \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 96.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 76.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. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg76.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000006e-9 < (*.f64 b b) < 1.99999999999999999e89

    1. Initial program 80.3%

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

      \[\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 81.7%

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

    if 1.99999999999999999e89 < (*.f64 b b)

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

        \[\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. Simplified71.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. Taylor expanded in a around 0 97.3%

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

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

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

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

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

Alternative 5: 98.1% accurate, 1.0× speedup?

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

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

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


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

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

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

    if 9.9999999999999992e124 < (*.f64 b b)

    1. Initial program 65.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+65.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-define65.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. sqr-neg65.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.6% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 75.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. Step-by-step derivation
      1. sub-neg75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999991e-6 < (*.f64 b b)

    1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 82.0% accurate, 1.1× speedup?

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

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

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

\mathbf{elif}\;a \leq 6.8 \cdot 10^{+22}:\\
\;\;\;\;{b}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.55e10 or 6.8e22 < a

    1. Initial program 43.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+43.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-define43.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{3} \cdot \left(a - 4\right)} \]
    9. Taylor expanded in a around inf 90.9%

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

    if -1.55e10 < a < 3.5000000000000002e-17

    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 98.4%

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

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

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

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

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

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

    if 3.5000000000000002e-17 < a < 6.8e22

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 93.9% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 75.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. Step-by-step derivation
      1. sub-neg75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999991e-6 < (*.f64 b b)

    1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 82.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -10500000000 \lor \neg \left(a \leq 4.4 \cdot 10^{+19}\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 -10500000000.0) (not (<= a 4.4e+19)))
   (pow a 4.0)
   (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -10500000000.0) || !(a <= 4.4e+19)) {
		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 <= (-10500000000.0d0)) .or. (.not. (a <= 4.4d+19))) 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 <= -10500000000.0) || !(a <= 4.4e+19)) {
		tmp = Math.pow(a, 4.0);
	} else {
		tmp = ((b * b) * 12.0) + -1.0;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -10500000000.0) or not (a <= 4.4e+19):
		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 <= -10500000000.0) || !(a <= 4.4e+19))
		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 <= -10500000000.0) || ~((a <= 4.4e+19)))
		tmp = a ^ 4.0;
	else
		tmp = ((b * b) * 12.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -10500000000.0], N[Not[LessEqual[a, 4.4e+19]], $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 -10500000000 \lor \neg \left(a \leq 4.4 \cdot 10^{+19}\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 < -1.05e10 or 4.4e19 < a

    1. Initial program 43.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+43.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-define43.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{3} \cdot \left(a - 4\right)} \]
    9. Taylor expanded in a around inf 90.9%

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

    if -1.05e10 < a < 4.4e19

    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 96.3%

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

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

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

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

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

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

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

Alternative 10: 93.7% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e8 < (*.f64 b b)

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 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 72.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+72.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-define72.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. sqr-neg72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 24.5% 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 72.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+72.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-define72.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. sqr-neg72.9%

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

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

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

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

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

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

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

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

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

Reproduce

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