Bouland and Aaronson, Equation (24)

Percentage Accurate: 74.1% → 98.4%
Time: 8.4s
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(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 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: 74.1% 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: 98.4% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\


\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 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(3 + 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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg0.0%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.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({b}^{4} + \mathsf{fma}\left(2, b \cdot \left(a \cdot \left(a \cdot b\right)\right), {a}^{4}\right)\right) + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \]

Alternative 2: 98.4% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\


\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 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(3 + 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(3 + a\right)\right) - 1\right)} \]
      2. sqr-pow99.8%

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

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

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg0.0%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.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(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), \left(b \cdot b\right) \cdot \left(a + 3\right)\right), -1\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \]

Alternative 3: 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(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} + -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))))
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;
	}
	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;
	}
	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
	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 ^ 4.0) + -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;
	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, 4.0], $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} + -1\\


\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 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(3 + 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 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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg0.0%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.8%

    \[\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} + -1\\ \end{array} \]

Alternative 4: 80.9% accurate, 1.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.5e18

    1. Initial program 78.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. sub-neg78.1%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg78.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5e18 < b

    1. Initial program 55.4%

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

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg55.4%

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

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

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

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

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

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

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

Alternative 5: 69.3% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.92 \lor \neg \left(a \leq 0.09\right):\\
\;\;\;\;{a}^{4}\\

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


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

    1. Initial program 49.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg49.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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg49.8%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Taylor expanded in a around inf 86.9%

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

    if -1.9199999999999999 < a < 0.089999999999999997

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot {a}^{2}} - 1 \]
    6. Step-by-step derivation
      1. add-sqr-sqrt51.2%

        \[\leadsto \color{blue}{\sqrt{4 \cdot {a}^{2}} \cdot \sqrt{4 \cdot {a}^{2}}} - 1 \]
      2. difference-of-sqr-151.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot a + 1\right) \cdot \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} - 1\right) \]
      12. add-sqr-sqrt51.2%

        \[\leadsto \left(2 \cdot a + 1\right) \cdot \left(2 \cdot \color{blue}{a} - 1\right) \]
    7. Applied egg-rr51.2%

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

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

Alternative 6: 80.5% accurate, 1.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 7.6e13

    1. Initial program 78.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. sub-neg78.1%

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg78.1%

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

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

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

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

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

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

    if 7.6e13 < b

    1. Initial program 55.4%

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

        \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. sqr-neg55.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 76000000000000:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \]

Alternative 7: 69.2% accurate, 1.2× speedup?

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

\\
{a}^{4} + -1
\end{array}
Derivation
  1. Initial program 74.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. sub-neg74.1%

      \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
    2. sqr-neg74.1%

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

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

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

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

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

    \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  5. Final simplification69.4%

    \[\leadsto {a}^{4} + -1 \]

Alternative 8: 50.9% accurate, 11.6× speedup?

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

\\
\left(1 + a \cdot 2\right) \cdot \left(-1 + a \cdot 2\right)
\end{array}
Derivation
  1. Initial program 74.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+74.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. sqr-pow74.1%

      \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{\left(\frac{2}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{2}{2}\right)}} + \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. Simplified75.0%

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

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

    \[\leadsto \color{blue}{4 \cdot {a}^{2}} - 1 \]
  6. Step-by-step derivation
    1. add-sqr-sqrt50.0%

      \[\leadsto \color{blue}{\sqrt{4 \cdot {a}^{2}} \cdot \sqrt{4 \cdot {a}^{2}}} - 1 \]
    2. difference-of-sqr-150.0%

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

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

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

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

      \[\leadsto \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} + 1\right) \cdot \left(\sqrt{4 \cdot {a}^{2}} - 1\right) \]
    7. add-sqr-sqrt37.9%

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

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

      \[\leadsto \left(2 \cdot a + 1\right) \cdot \left(\color{blue}{2} \cdot \sqrt{{a}^{2}} - 1\right) \]
    10. pow237.9%

      \[\leadsto \left(2 \cdot a + 1\right) \cdot \left(2 \cdot \sqrt{\color{blue}{a \cdot a}} - 1\right) \]
    11. sqrt-prod24.3%

      \[\leadsto \left(2 \cdot a + 1\right) \cdot \left(2 \cdot \color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} - 1\right) \]
    12. add-sqr-sqrt50.0%

      \[\leadsto \left(2 \cdot a + 1\right) \cdot \left(2 \cdot \color{blue}{a} - 1\right) \]
  7. Applied egg-rr50.0%

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

    \[\leadsto \left(1 + a \cdot 2\right) \cdot \left(-1 + a \cdot 2\right) \]

Alternative 9: 24.9% 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 74.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. sub-neg74.1%

      \[\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(3 + a\right)\right)\right) + \left(-1\right)} \]
    2. sqr-neg74.1%

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

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

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

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

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

    \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  5. Taylor expanded in a around 0 25.0%

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification25.0%

    \[\leadsto -1 \]

Reproduce

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