Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.7% → 99.9%
Time: 12.0s
Alternatives: 6
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(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 6 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.7% 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.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(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}:\\ \;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + 2 \cdot {b}^{2}}{a}}{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)
     (+
      -1.0
      (*
       (pow a 4.0)
       (+ 1.0 (/ (+ 4.0 (/ (+ 4.0 (* 2.0 (pow b 2.0))) 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 = -1.0 + (pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + (2.0 * pow(b, 2.0))) / 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 = -1.0 + (Math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + (2.0 * Math.pow(b, 2.0))) / 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 = -1.0 + (math.pow(a, 4.0) * (1.0 + ((4.0 + ((4.0 + (2.0 * math.pow(b, 2.0))) / 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(-1.0 + Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(4.0 + Float64(Float64(4.0 + Float64(2.0 * (b ^ 2.0))) / 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 = -1.0 + ((a ^ 4.0) * (1.0 + ((4.0 + ((4.0 + (2.0 * (b ^ 2.0))) / 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[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(4.0 + N[(N[(4.0 + N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + 2 \cdot {b}^{2}}{a}}{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)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) < +inf.0

    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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Add Preprocessing

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(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}:\\ \;\;\;\;-1 + {a}^{4} \cdot \left(1 + \frac{4 + \frac{4 + 2 \cdot {b}^{2}}{a}}{a}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 98.4% 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}:\\ \;\;\;\;-1 + {a}^{2} \cdot \left(4 + a \cdot \left(a + 4\right)\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)
     (+ -1.0 (* (pow a 2.0) (+ 4.0 (* a (+ a 4.0))))))))
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 = -1.0 + (pow(a, 2.0) * (4.0 + (a * (a + 4.0))));
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (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 = -1.0 + (Math.pow(a, 2.0) * (4.0 + (a * (a + 4.0))));
	}
	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 = -1.0 + (math.pow(a, 2.0) * (4.0 + (a * (a + 4.0))))
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(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(-1.0 + Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(a + 4.0)))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0 + -1.0;
	else
		tmp = -1.0 + ((a ^ 2.0) * (4.0 + (a * (a + 4.0))));
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(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[(-1.0 + N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;-1 + {a}^{2} \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\


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

    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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Add Preprocessing

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{2} \cdot \left(4 + a \cdot \left(4 + a\right)\right) - 1} \]
  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}:\\ \;\;\;\;-1 + {a}^{2} \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.8% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 74.5%

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

        \[\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)} \]
      2. +-commutative74.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {a}^{4} \cdot \left(1 + -1 \cdot \frac{-1 \cdot \left(4 + \frac{\color{blue}{4}}{a}\right)}{a}\right) + -1 \]
      4. distribute-lft-in65.5%

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

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

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

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

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

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

    if 4.4e10 < b

    1. Initial program 70.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-neg70.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)} \]
      2. +-commutative70.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{+38} \lor \neg \left(a \leq 1.75 \cdot 10^{+18}\right):\\
\;\;\;\;{a}^{4} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4.6000000000000002e38 or 1.75e18 < a

    1. Initial program 47.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg47.9%

        \[\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)} \]
      2. +-commutative47.9%

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

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

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

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

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

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

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

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

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

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

    if -4.6000000000000002e38 < a < 1.75e18

    1. Initial program 97.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. sub-neg97.6%

        \[\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)} \]
      2. +-commutative97.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 69.1% accurate, 1.3× 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 73.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. sub-neg73.7%

      \[\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)} \]
    2. +-commutative73.7%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {a}^{4} + -1 \]
  7. Add Preprocessing

Alternative 6: 25.4% 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 73.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. sub-neg73.7%

      \[\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)} \]
    2. +-commutative73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  9. Final simplification21.9%

    \[\leadsto -1 \]
  10. Add Preprocessing

Reproduce

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