Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.1% → 98.6%
Time: 8.9s
Alternatives: 6
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.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(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: 98.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+102}:\\
\;\;\;\;{a}^{4} + -1\\

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


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

    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)} \]
    3. Simplified16.2%

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

    if -5e102 < a

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.2% 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:\\ \;\;\;\;-1 + t_0\\ \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) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
   (if (<= t_0 INFINITY) (+ -1.0 t_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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = -1.0 + t_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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = -1.0 + t_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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = -1.0 + t_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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0))))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = Float64(-1.0 + t_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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = -1.0 + t_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[(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[(-1.0 + t$95$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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;-1 + t_0\\

\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 1 (*.f64 3 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)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.f64 3 a))))))

    1. Initial program 0.0%

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

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

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

    \[\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:\\ \;\;\;\;-1 + \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)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.9% accurate, 1.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\


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

    1. Initial program 78.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-neg78.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)} \]
    3. Simplified79.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 80.7%

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

    if 17 < b

    1. Initial program 61.1%

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

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

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

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

        \[\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(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+61.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\color{blue}{\left(\left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) \cdot \left(4 \cdot 4\right)} - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      8. pow215.4%

        \[\leadsto \frac{-\left(\color{blue}{{\left(b \cdot b\right)}^{2}} \cdot \left(4 \cdot 4\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      9. pow-prod-down15.4%

        \[\leadsto \frac{-\left(\color{blue}{\left({b}^{2} \cdot {b}^{2}\right)} \cdot \left(4 \cdot 4\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      10. pow-prod-up15.4%

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

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

        \[\leadsto \frac{-\left({b}^{4} \cdot \color{blue}{16} - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      13. pow-prod-up15.3%

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

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

      \[\leadsto \color{blue}{\frac{-\left({b}^{4} \cdot 16 - {b}^{8}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)}} - 1 \]
    8. Step-by-step derivation
      1. neg-sub015.3%

        \[\leadsto \frac{\color{blue}{0 - \left({b}^{4} \cdot 16 - {b}^{8}\right)}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      2. associate--r-15.3%

        \[\leadsto \frac{\color{blue}{\left(0 - {b}^{4} \cdot 16\right) + {b}^{8}}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      3. neg-sub015.3%

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

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

        \[\leadsto \frac{\color{blue}{{b}^{8} - {b}^{4} \cdot 16}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      6. neg-sub015.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{0 - \left(4 \cdot {b}^{2} - {b}^{4}\right)}} - 1 \]
      7. associate--r-15.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{\left(0 - 4 \cdot {b}^{2}\right) + {b}^{4}}} - 1 \]
      8. neg-sub015.3%

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

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{{b}^{4} + \left(-4 \cdot {b}^{2}\right)}} - 1 \]
      10. sub-neg15.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{{b}^{4} - 4 \cdot {b}^{2}}} - 1 \]
      11. *-commutative15.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{{b}^{2} \cdot 4}} - 1 \]
      12. unpow215.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{\left(b \cdot b\right)} \cdot 4} - 1 \]
      13. metadata-eval15.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \left(b \cdot b\right) \cdot \color{blue}{\left(2 \cdot 2\right)}} - 1 \]
      14. swap-sqr15.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{\left(b \cdot 2\right) \cdot \left(b \cdot 2\right)}} - 1 \]
      15. unpow215.3%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{{\left(b \cdot 2\right)}^{2}}} - 1 \]
    9. Simplified15.3%

      \[\leadsto \color{blue}{\frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}}} - 1 \]
    10. Step-by-step derivation
      1. metadata-eval15.3%

        \[\leadsto \frac{{b}^{8} - {b}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      2. pow-sqr15.3%

        \[\leadsto \frac{{b}^{8} - \color{blue}{\left({b}^{2} \cdot {b}^{2}\right)} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      3. metadata-eval15.3%

        \[\leadsto \frac{{b}^{8} - \left({b}^{2} \cdot {b}^{2}\right) \cdot \color{blue}{\left(4 \cdot 4\right)}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      4. swap-sqr15.3%

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

        \[\leadsto \frac{{b}^{8} - \left({b}^{2} \cdot \color{blue}{{2}^{2}}\right) \cdot \left({b}^{2} \cdot 4\right)}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      6. unpow-prod-down15.3%

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

        \[\leadsto \frac{{b}^{8} - {\left(b \cdot 2\right)}^{2} \cdot \left({b}^{2} \cdot \color{blue}{{2}^{2}}\right)}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      8. unpow-prod-down15.3%

        \[\leadsto \frac{{b}^{8} - {\left(b \cdot 2\right)}^{2} \cdot \color{blue}{{\left(b \cdot 2\right)}^{2}}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      9. metadata-eval15.3%

        \[\leadsto \frac{{b}^{\color{blue}{\left(2 \cdot 4\right)}} - {\left(b \cdot 2\right)}^{2} \cdot {\left(b \cdot 2\right)}^{2}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      10. pow-sqr15.4%

        \[\leadsto \frac{\color{blue}{{b}^{4} \cdot {b}^{4}} - {\left(b \cdot 2\right)}^{2} \cdot {\left(b \cdot 2\right)}^{2}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      11. flip-+88.7%

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

        \[\leadsto \left({b}^{\color{blue}{\left(2 \cdot 2\right)}} + {\left(b \cdot 2\right)}^{2}\right) - 1 \]
      13. pow-sqr88.6%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot {b}^{2}} + {\left(b \cdot 2\right)}^{2}\right) - 1 \]
      14. unpow-prod-down88.6%

        \[\leadsto \left({b}^{2} \cdot {b}^{2} + \color{blue}{{b}^{2} \cdot {2}^{2}}\right) - 1 \]
      15. metadata-eval88.6%

        \[\leadsto \left({b}^{2} \cdot {b}^{2} + {b}^{2} \cdot \color{blue}{4}\right) - 1 \]
      16. distribute-lft-in88.6%

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

        \[\leadsto \color{blue}{\left({b}^{2} + 4\right) \cdot {b}^{2}} - 1 \]
      18. unpow288.6%

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

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(b, b, 4\right) \cdot b\right) \cdot b} - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.8%

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

Alternative 4: 76.2% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 76.2%

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

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

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

    if 1.35999999999999993e144 < b

    1. Initial program 62.2%

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

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

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

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

        \[\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(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
      5. associate-+l+62.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\left(4 \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot \left(4 \cdot {b}^{2}\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      4. *-commutative0.0%

        \[\leadsto \frac{-\left(\color{blue}{\left(\left(b \cdot b\right) \cdot 4\right)} \cdot \left(4 \cdot {b}^{2}\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      5. pow20.0%

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

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

        \[\leadsto \frac{-\left(\color{blue}{\left(\left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) \cdot \left(4 \cdot 4\right)} - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      8. pow20.0%

        \[\leadsto \frac{-\left(\color{blue}{{\left(b \cdot b\right)}^{2}} \cdot \left(4 \cdot 4\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      9. pow-prod-down0.0%

        \[\leadsto \frac{-\left(\color{blue}{\left({b}^{2} \cdot {b}^{2}\right)} \cdot \left(4 \cdot 4\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      10. pow-prod-up0.0%

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

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

        \[\leadsto \frac{-\left({b}^{4} \cdot \color{blue}{16} - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      13. pow-prod-up0.0%

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

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

      \[\leadsto \color{blue}{\frac{-\left({b}^{4} \cdot 16 - {b}^{8}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)}} - 1 \]
    8. Step-by-step derivation
      1. neg-sub00.0%

        \[\leadsto \frac{\color{blue}{0 - \left({b}^{4} \cdot 16 - {b}^{8}\right)}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      2. associate--r-0.0%

        \[\leadsto \frac{\color{blue}{\left(0 - {b}^{4} \cdot 16\right) + {b}^{8}}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      3. neg-sub00.0%

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

        \[\leadsto \frac{\color{blue}{{b}^{8} + \left(-{b}^{4} \cdot 16\right)}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      5. sub-neg0.0%

        \[\leadsto \frac{\color{blue}{{b}^{8} - {b}^{4} \cdot 16}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
      6. neg-sub00.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{0 - \left(4 \cdot {b}^{2} - {b}^{4}\right)}} - 1 \]
      7. associate--r-0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{\left(0 - 4 \cdot {b}^{2}\right) + {b}^{4}}} - 1 \]
      8. neg-sub00.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{\left(-4 \cdot {b}^{2}\right)} + {b}^{4}} - 1 \]
      9. +-commutative0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{{b}^{4} + \left(-4 \cdot {b}^{2}\right)}} - 1 \]
      10. sub-neg0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{{b}^{4} - 4 \cdot {b}^{2}}} - 1 \]
      11. *-commutative0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{{b}^{2} \cdot 4}} - 1 \]
      12. unpow20.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{\left(b \cdot b\right)} \cdot 4} - 1 \]
      13. metadata-eval0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \left(b \cdot b\right) \cdot \color{blue}{\left(2 \cdot 2\right)}} - 1 \]
      14. swap-sqr0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{\left(b \cdot 2\right) \cdot \left(b \cdot 2\right)}} - 1 \]
      15. unpow20.0%

        \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{{\left(b \cdot 2\right)}^{2}}} - 1 \]
    9. Simplified0.0%

      \[\leadsto \color{blue}{\frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}}} - 1 \]
    10. Step-by-step derivation
      1. metadata-eval0.0%

        \[\leadsto \frac{{b}^{8} - {b}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      2. pow-sqr0.0%

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

        \[\leadsto \frac{{b}^{8} - \left({b}^{2} \cdot {b}^{2}\right) \cdot \color{blue}{\left(4 \cdot 4\right)}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      4. swap-sqr0.0%

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

        \[\leadsto \frac{{b}^{8} - \left({b}^{2} \cdot \color{blue}{{2}^{2}}\right) \cdot \left({b}^{2} \cdot 4\right)}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      6. unpow-prod-down0.0%

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

        \[\leadsto \frac{{b}^{8} - {\left(b \cdot 2\right)}^{2} \cdot \left({b}^{2} \cdot \color{blue}{{2}^{2}}\right)}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      8. unpow-prod-down0.0%

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

        \[\leadsto \frac{{b}^{\color{blue}{\left(2 \cdot 4\right)}} - {\left(b \cdot 2\right)}^{2} \cdot {\left(b \cdot 2\right)}^{2}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      10. pow-sqr0.0%

        \[\leadsto \frac{\color{blue}{{b}^{4} \cdot {b}^{4}} - {\left(b \cdot 2\right)}^{2} \cdot {\left(b \cdot 2\right)}^{2}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
      11. flip-+100.0%

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

        \[\leadsto \left({b}^{\color{blue}{\left(2 \cdot 2\right)}} + {\left(b \cdot 2\right)}^{2}\right) - 1 \]
      13. pow-sqr100.0%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot {b}^{2}} + {\left(b \cdot 2\right)}^{2}\right) - 1 \]
      14. unpow-prod-down100.0%

        \[\leadsto \left({b}^{2} \cdot {b}^{2} + \color{blue}{{b}^{2} \cdot {2}^{2}}\right) - 1 \]
      15. metadata-eval100.0%

        \[\leadsto \left({b}^{2} \cdot {b}^{2} + {b}^{2} \cdot \color{blue}{4}\right) - 1 \]
      16. distribute-lft-in100.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(b, b, 4\right) \cdot b\right) \cdot b} - 1 \]
    12. Taylor expanded in b around 0 97.6%

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

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

Alternative 5: 80.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3100:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b 3100.0) (+ (pow a 4.0) -1.0) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
	double tmp;
	if (b <= 3100.0) {
		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 (b <= 3100.0d0) 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 (b <= 3100.0) {
		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 b <= 3100.0:
		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 (b <= 3100.0)
		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 (b <= 3100.0)
		tmp = (a ^ 4.0) + -1.0;
	else
		tmp = -1.0 + (b ^ 4.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[b, 3100.0], 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}\;b \leq 3100:\\
\;\;\;\;{a}^{4} + -1\\

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


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

    1. Initial program 78.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-neg78.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)} \]
    3. Simplified79.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 80.7%

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

    if 3100 < b

    1. Initial program 61.1%

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

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

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

Alternative 6: 51.5% accurate, 18.6× speedup?

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

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

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

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

      \[\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(-1\right)\right)} + {\left(b \cdot b + a \cdot a\right)}^{2} \]
    5. associate-+l+74.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-\left(\color{blue}{\left(\left(b \cdot b\right) \cdot 4\right)} \cdot \left(4 \cdot {b}^{2}\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    5. pow222.6%

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

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

      \[\leadsto \frac{-\left(\color{blue}{\left(\left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) \cdot \left(4 \cdot 4\right)} - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    8. pow222.6%

      \[\leadsto \frac{-\left(\color{blue}{{\left(b \cdot b\right)}^{2}} \cdot \left(4 \cdot 4\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    9. pow-prod-down22.6%

      \[\leadsto \frac{-\left(\color{blue}{\left({b}^{2} \cdot {b}^{2}\right)} \cdot \left(4 \cdot 4\right) - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    10. pow-prod-up22.6%

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

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

      \[\leadsto \frac{-\left({b}^{4} \cdot \color{blue}{16} - {b}^{4} \cdot {b}^{4}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    13. pow-prod-up22.6%

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

      \[\leadsto \frac{-\left({b}^{4} \cdot 16 - {b}^{\color{blue}{8}}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
  7. Applied egg-rr22.6%

    \[\leadsto \color{blue}{\frac{-\left({b}^{4} \cdot 16 - {b}^{8}\right)}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)}} - 1 \]
  8. Step-by-step derivation
    1. neg-sub022.6%

      \[\leadsto \frac{\color{blue}{0 - \left({b}^{4} \cdot 16 - {b}^{8}\right)}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    2. associate--r-22.6%

      \[\leadsto \frac{\color{blue}{\left(0 - {b}^{4} \cdot 16\right) + {b}^{8}}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    3. neg-sub022.6%

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

      \[\leadsto \frac{\color{blue}{{b}^{8} + \left(-{b}^{4} \cdot 16\right)}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    5. sub-neg22.6%

      \[\leadsto \frac{\color{blue}{{b}^{8} - {b}^{4} \cdot 16}}{-\left(4 \cdot {b}^{2} - {b}^{4}\right)} - 1 \]
    6. neg-sub022.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{0 - \left(4 \cdot {b}^{2} - {b}^{4}\right)}} - 1 \]
    7. associate--r-22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{\left(0 - 4 \cdot {b}^{2}\right) + {b}^{4}}} - 1 \]
    8. neg-sub022.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{\left(-4 \cdot {b}^{2}\right)} + {b}^{4}} - 1 \]
    9. +-commutative22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{{b}^{4} + \left(-4 \cdot {b}^{2}\right)}} - 1 \]
    10. sub-neg22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{\color{blue}{{b}^{4} - 4 \cdot {b}^{2}}} - 1 \]
    11. *-commutative22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{{b}^{2} \cdot 4}} - 1 \]
    12. unpow222.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{\left(b \cdot b\right)} \cdot 4} - 1 \]
    13. metadata-eval22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \left(b \cdot b\right) \cdot \color{blue}{\left(2 \cdot 2\right)}} - 1 \]
    14. swap-sqr22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{\left(b \cdot 2\right) \cdot \left(b \cdot 2\right)}} - 1 \]
    15. unpow222.6%

      \[\leadsto \frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - \color{blue}{{\left(b \cdot 2\right)}^{2}}} - 1 \]
  9. Simplified22.6%

    \[\leadsto \color{blue}{\frac{{b}^{8} - {b}^{4} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}}} - 1 \]
  10. Step-by-step derivation
    1. metadata-eval22.6%

      \[\leadsto \frac{{b}^{8} - {b}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot 16}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    2. pow-sqr22.6%

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

      \[\leadsto \frac{{b}^{8} - \left({b}^{2} \cdot {b}^{2}\right) \cdot \color{blue}{\left(4 \cdot 4\right)}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    4. swap-sqr22.6%

      \[\leadsto \frac{{b}^{8} - \color{blue}{\left({b}^{2} \cdot 4\right) \cdot \left({b}^{2} \cdot 4\right)}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    5. metadata-eval22.6%

      \[\leadsto \frac{{b}^{8} - \left({b}^{2} \cdot \color{blue}{{2}^{2}}\right) \cdot \left({b}^{2} \cdot 4\right)}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    6. unpow-prod-down22.6%

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

      \[\leadsto \frac{{b}^{8} - {\left(b \cdot 2\right)}^{2} \cdot \left({b}^{2} \cdot \color{blue}{{2}^{2}}\right)}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    8. unpow-prod-down22.6%

      \[\leadsto \frac{{b}^{8} - {\left(b \cdot 2\right)}^{2} \cdot \color{blue}{{\left(b \cdot 2\right)}^{2}}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    9. metadata-eval22.6%

      \[\leadsto \frac{{b}^{\color{blue}{\left(2 \cdot 4\right)}} - {\left(b \cdot 2\right)}^{2} \cdot {\left(b \cdot 2\right)}^{2}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    10. pow-sqr22.6%

      \[\leadsto \frac{\color{blue}{{b}^{4} \cdot {b}^{4}} - {\left(b \cdot 2\right)}^{2} \cdot {\left(b \cdot 2\right)}^{2}}{{b}^{4} - {\left(b \cdot 2\right)}^{2}} - 1 \]
    11. flip-+72.3%

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

      \[\leadsto \left({b}^{\color{blue}{\left(2 \cdot 2\right)}} + {\left(b \cdot 2\right)}^{2}\right) - 1 \]
    13. pow-sqr72.3%

      \[\leadsto \left(\color{blue}{{b}^{2} \cdot {b}^{2}} + {\left(b \cdot 2\right)}^{2}\right) - 1 \]
    14. unpow-prod-down72.3%

      \[\leadsto \left({b}^{2} \cdot {b}^{2} + \color{blue}{{b}^{2} \cdot {2}^{2}}\right) - 1 \]
    15. metadata-eval72.3%

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

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

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

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

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

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(b, b, 4\right) \cdot b\right) \cdot b} - 1 \]
  12. Taylor expanded in b around 0 55.2%

    \[\leadsto \color{blue}{\left(4 \cdot b\right)} \cdot b - 1 \]
  13. Final simplification55.2%

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

Reproduce

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