Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.9% → 99.5%
Time: 7.5s
Alternatives: 9
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 99.5% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, -1 + {a}^{3} \cdot \left(a + 4\right)\right)\right)}^{3}}\\


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

    1. Initial program 99.8%

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

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

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

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

    1. Initial program 0.0%

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

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
    5. Step-by-step derivation
      1. associate--l+31.5%

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

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

        \[\leadsto {a}^{4} + \left(\left(4 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot \left(1 + a\right) - 1\right) \]
    6. Simplified31.5%

      \[\leadsto \color{blue}{{a}^{4} + \left(\left(4 \cdot \left(a \cdot a\right)\right) \cdot \left(1 + a\right) - 1\right)} \]
    7. Step-by-step derivation
      1. add-cbrt-cube38.1%

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left({a}^{4} + \mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(a + 1\right), -1\right)\right) \cdot \left({a}^{4} + \mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(a + 1\right), -1\right)\right)\right) \cdot \left({a}^{4} + \mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(a + 1\right), -1\right)\right)}} \]
    9. Step-by-step derivation
      1. unpow338.1%

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, \mathsf{fma}\left({a}^{3}, 4 + a, -1\right)\right)\right)}^{3}}} \]
    11. Step-by-step derivation
      1. fma-udef98.6%

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

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, {a}^{3} \cdot \color{blue}{\left(a + 4\right)} + -1\right)\right)}^{3}} \]
    12. Applied egg-rr98.6%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, \color{blue}{{a}^{3} \cdot \left(a + 4\right) + -1}\right)\right)}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

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

Alternative 2: 99.4% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, -1 + {a}^{3} \cdot \left(a + 4\right)\right)\right)}^{3}}\\


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

    1. Initial program 99.8%

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

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

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

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

    1. Initial program 0.0%

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

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
    5. Step-by-step derivation
      1. associate--l+31.5%

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

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

        \[\leadsto {a}^{4} + \left(\left(4 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot \left(1 + a\right) - 1\right) \]
    6. Simplified31.5%

      \[\leadsto \color{blue}{{a}^{4} + \left(\left(4 \cdot \left(a \cdot a\right)\right) \cdot \left(1 + a\right) - 1\right)} \]
    7. Step-by-step derivation
      1. add-cbrt-cube38.1%

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left({a}^{4} + \mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(a + 1\right), -1\right)\right) \cdot \left({a}^{4} + \mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(a + 1\right), -1\right)\right)\right) \cdot \left({a}^{4} + \mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(a + 1\right), -1\right)\right)}} \]
    9. Step-by-step derivation
      1. unpow338.1%

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, \mathsf{fma}\left({a}^{3}, 4 + a, -1\right)\right)\right)}^{3}}} \]
    11. Step-by-step derivation
      1. fma-udef98.6%

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

        \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, {a}^{3} \cdot \color{blue}{\left(a + 4\right)} + -1\right)\right)}^{3}} \]
    12. Applied egg-rr98.6%

      \[\leadsto \sqrt[3]{{\left(\mathsf{fma}\left(4, a \cdot a, \color{blue}{{a}^{3} \cdot \left(a + 4\right) + -1}\right)\right)}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

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

Alternative 3: 98.9% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(-1 + 4 \cdot {a}^{3}\right)\\


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

    1. Initial program 0.0%

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} \]
    5. Step-by-step derivation
      1. sqr-pow100.0%

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

        \[\leadsto {a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} \]
      3. pow2100.0%

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

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} \]
      5. pow2100.0%

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

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

    if -1e103 < a

    1. Initial program 86.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+86.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. fma-def86.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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1 \cdot 10^{+103}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(-1 + 4 \cdot {a}^{3}\right)\\ \end{array} \]

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

\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

      \[\leadsto \color{blue}{{a}^{4}} \]
    5. Step-by-step derivation
      1. sqr-pow92.0%

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

        \[\leadsto {a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} \]
      3. pow292.0%

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

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} \]
      5. pow292.0%

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} \]
    6. Applied egg-rr92.0%

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

    \[\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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \end{array} \]

Alternative 5: 94.0% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 85.3%

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

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

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
    5. Step-by-step derivation
      1. associate--l+84.1%

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

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

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

      \[\leadsto \color{blue}{{a}^{4} + \left(\left(4 \cdot \left(a \cdot a\right)\right) \cdot \left(1 + a\right) - 1\right)} \]
    7. Step-by-step derivation
      1. sqr-pow47.3%

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

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

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

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} \]
      5. pow247.3%

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} \]
    8. Applied egg-rr83.9%

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

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

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

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

    if 2e20 < (*.f64 b b)

    1. Initial program 58.4%

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

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

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

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

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

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

Alternative 6: 71.2% accurate, 6.8× speedup?

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

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

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


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

    1. Initial program 79.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+79.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. fma-def79.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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified80.3%

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
    5. Step-by-step derivation
      1. associate--l+66.7%

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

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

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

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

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

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

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

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} \]
      5. pow246.1%

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} \]
    8. Applied egg-rr66.6%

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

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

        \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a\right) + \left(4 \cdot \color{blue}{\left(a \cdot a\right)} - 1\right) \]
    11. Simplified80.7%

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

    if 1.0000000000000001e289 < (*.f64 b b)

    1. Initial program 52.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{8}} \cdot \sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right) \]
    6. Taylor expanded in a around 0 51.4%

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

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

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

        \[\leadsto \left(\left(-12 \cdot \left(a \cdot {b}^{2}\right) + 4 \cdot {b}^{2}\right) + {b}^{4}\right) + \color{blue}{-1} \]
      4. associate-+l+51.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-12 \cdot \left(a \cdot {b}^{2}\right)} \]
    10. Step-by-step derivation
      1. *-commutative50.1%

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

        \[\leadsto \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot -12 \]
      3. *-commutative50.1%

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

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot -12\right)} \]
      5. associate-*l*39.9%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(a \cdot -12\right)\right)} \]
    11. Simplified39.9%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(a \cdot -12\right)\right)} \]
    12. Taylor expanded in b around 0 50.1%

      \[\leadsto \color{blue}{-12 \cdot \left(a \cdot {b}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative50.1%

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

        \[\leadsto \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot -12 \]
      3. associate-*l*50.1%

        \[\leadsto \color{blue}{a \cdot \left(\left(b \cdot b\right) \cdot -12\right)} \]
    14. Simplified50.1%

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

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

Alternative 7: 68.7% accurate, 11.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 0.41\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -2.4) (not (<= a 0.41))) (* (* a a) (* a a)) -1.0))
double code(double a, double b) {
	double tmp;
	if ((a <= -2.4) || !(a <= 0.41)) {
		tmp = (a * a) * (a * a);
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((a <= (-2.4d0)) .or. (.not. (a <= 0.41d0))) then
        tmp = (a * a) * (a * a)
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((a <= -2.4) || !(a <= 0.41)) {
		tmp = (a * a) * (a * a);
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -2.4) or not (a <= 0.41):
		tmp = (a * a) * (a * a)
	else:
		tmp = -1.0
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -2.4) || !(a <= 0.41))
		tmp = Float64(Float64(a * a) * Float64(a * a));
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -2.4) || ~((a <= 0.41)))
		tmp = (a * a) * (a * a);
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -2.4], N[Not[LessEqual[a, 0.41]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 0.41\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\

\mathbf{else}:\\
\;\;\;\;-1\\


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

    1. Initial program 45.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+45.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. fma-def45.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(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified50.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, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right)} \]
    4. Taylor expanded in a around inf 85.6%

      \[\leadsto \color{blue}{{a}^{4}} \]
    5. Step-by-step derivation
      1. sqr-pow85.5%

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

        \[\leadsto {a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} \]
      3. pow285.5%

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

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} \]
      5. pow285.5%

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} \]
    6. Applied egg-rr85.5%

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

    if -2.39999999999999991 < a < 0.409999999999999976

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
    5. Step-by-step derivation
      1. associate--l+53.5%

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

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

        \[\leadsto {a}^{4} + \left(\left(4 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot \left(1 + a\right) - 1\right) \]
    6. Simplified53.5%

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 0.41\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 8: 40.7% accurate, 11.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.004:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot -12\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 0.004) -1.0 (* a (* (* b b) -12.0))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 0.004) {
		tmp = -1.0;
	} else {
		tmp = a * ((b * b) * -12.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) <= 0.004d0) then
        tmp = -1.0d0
    else
        tmp = a * ((b * b) * (-12.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 0.004) {
		tmp = -1.0;
	} else {
		tmp = a * ((b * b) * -12.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 0.004:
		tmp = -1.0
	else:
		tmp = a * ((b * b) * -12.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 0.004)
		tmp = -1.0;
	else
		tmp = Float64(a * Float64(Float64(b * b) * -12.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 0.004)
		tmp = -1.0;
	else
		tmp = a * ((b * b) * -12.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.004], -1.0, N[(a * N[(N[(b * b), $MachinePrecision] * -12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.004:\\
\;\;\;\;-1\\

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


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

    1. Initial program 86.3%

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

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

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
    5. Step-by-step derivation
      1. associate--l+85.3%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 0.0040000000000000001 < (*.f64 b b)

    1. Initial program 58.4%

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

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

        \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right) - 1\right) \]
    3. Simplified63.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, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right)} \]
    4. Step-by-step derivation
      1. fma-def63.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{8}} \cdot \sqrt[3]{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right) \]
    6. Taylor expanded in a around 0 58.8%

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

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

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

        \[\leadsto \left(\left(-12 \cdot \left(a \cdot {b}^{2}\right) + 4 \cdot {b}^{2}\right) + {b}^{4}\right) + \color{blue}{-1} \]
      4. associate-+l+58.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-12 \cdot \left(a \cdot {b}^{2}\right)} \]
    10. Step-by-step derivation
      1. *-commutative34.0%

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

        \[\leadsto \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot -12 \]
      3. *-commutative34.0%

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

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(a \cdot -12\right)} \]
      5. associate-*l*28.4%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(a \cdot -12\right)\right)} \]
    11. Simplified28.4%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(a \cdot -12\right)\right)} \]
    12. Taylor expanded in b around 0 34.0%

      \[\leadsto \color{blue}{-12 \cdot \left(a \cdot {b}^{2}\right)} \]
    13. Step-by-step derivation
      1. *-commutative34.0%

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

        \[\leadsto \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot -12 \]
      3. associate-*l*34.0%

        \[\leadsto \color{blue}{a \cdot \left(\left(b \cdot b\right) \cdot -12\right)} \]
    14. Simplified34.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.004:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot -12\right)\\ \end{array} \]

Alternative 9: 24.7% accurate, 130.0× speedup?

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

\\
-1
\end{array}
Derivation
  1. Initial program 72.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+72.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
    2. fma-def72.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(1 - 3 \cdot 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, a + 1, \left(b \cdot b\right) \cdot \left(1 + -3 \cdot a\right)\right) - 1\right)} \]
  4. Taylor expanded in b around 0 54.1%

    \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1} \]
  5. Step-by-step derivation
    1. associate--l+54.1%

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification26.2%

    \[\leadsto -1 \]

Reproduce

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