Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.3% → 99.9%
Time: 9.7s
Alternatives: 9
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 74.3% 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.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(a + 1\right), b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -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
 (if (<=
      (+
       (pow (+ (* a a) (* b b)) 2.0)
       (* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
      INFINITY)
   (+
    (fma
     4.0
     (fma a (* a (+ a 1.0)) (* b (* b (+ 1.0 (* a -3.0)))))
     (pow (fma a a (* b b)) 2.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 tmp;
	if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= ((double) INFINITY)) {
		tmp = fma(4.0, fma(a, (a * (a + 1.0)), (b * (b * (1.0 + (a * -3.0))))), pow(fma(a, a, (b * b)), 2.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;
}
function code(a, b)
	tmp = 0.0
	if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= Inf)
		tmp = Float64(fma(4.0, fma(a, Float64(a * Float64(a + 1.0)), Float64(b * Float64(b * Float64(1.0 + Float64(a * -3.0))))), (fma(a, a, Float64(b * b)) ^ 2.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
code[a_, b_] := If[LessEqual[N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(4.0 * N[(a * N[(a * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(b * N[(b * N[(1.0 + N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -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}
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(a + 1\right), b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -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. Step-by-step derivation
      1. associate--l+99.9%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(a + 1\right), b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) + -1} \]
    4. 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-define6.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. +-commutative6.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*6.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-inv6.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-eval6.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-define6.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-eval6.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. Simplified6.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:\\ \;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(a + 1\right), b \cdot \left(b \cdot \left(1 + a \cdot -3\right)\right)\right), {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\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: 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-define6.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. +-commutative6.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*6.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-inv6.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-eval6.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-define6.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-eval6.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. Simplified6.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 3: 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}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot \left(4 + a \cdot \left(a + 4\right)\right), a, -1\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)
     (fma (* a (+ 4.0 (* a (+ a 4.0)))) a -1.0))))
double code(double a, double b) {
	double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0 + -1.0;
	} else {
		tmp = fma((a * (4.0 + (a * (a + 4.0)))), a, -1.0);
	}
	return tmp;
}
function code(a, b)
	t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(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 = fma(Float64(a * Float64(4.0 + Float64(a * Float64(a + 4.0)))), a, -1.0);
	end
	return tmp
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[(a * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + -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:\\
\;\;\;\;t\_0 + -1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \left(4 + a \cdot \left(a + 4\right)\right), a, -1\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-define6.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. +-commutative6.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*6.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-inv6.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-eval6.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-define6.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-eval6.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. Simplified6.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 0 29.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.4% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 79.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-neg79.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)} \]
      2. +-commutative79.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(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define80.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. +-commutative80.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*80.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-inv80.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-eval80.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-define80.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-eval80.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. Simplified80.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 0 64.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.60000000000000039e53 < b

    1. Initial program 60.4%

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

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

        \[\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-define62.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. +-commutative62.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*62.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-inv62.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-eval62.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-define62.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-eval62.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. Simplified62.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 100.0%

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

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

Alternative 5: 80.8% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 79.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-neg79.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)} \]
      2. +-commutative79.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(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define80.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. +-commutative80.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*80.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-inv80.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-eval80.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-define80.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-eval80.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. Simplified80.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 a around inf 79.4%

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

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

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

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

    if 1.25000000000000001e54 < b

    1. Initial program 60.4%

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

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

        \[\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-define62.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. +-commutative62.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*62.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-inv62.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-eval62.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-define62.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-eval62.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. Simplified62.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 100.0%

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

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

Alternative 6: 80.8% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 79.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-neg79.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)} \]
      2. +-commutative79.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(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define80.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. +-commutative80.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*80.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-inv80.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-eval80.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-define80.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-eval80.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. Simplified80.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 a around inf 79.4%

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

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

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

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

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

    if 4.2000000000000004e53 < b

    1. Initial program 60.4%

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

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

        \[\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-define62.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. +-commutative62.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*62.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-inv62.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-eval62.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-define62.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-eval62.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. Simplified62.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 100.0%

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

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

Alternative 7: 80.5% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 79.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-neg79.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)} \]
      2. +-commutative79.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(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(-1\right) \]
      3. fma-define80.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. +-commutative80.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*80.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-inv80.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-eval80.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-define80.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-eval80.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. Simplified80.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 a around inf 79.2%

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

    if 5.40000000000000022e54 < b

    1. Initial program 60.4%

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

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

        \[\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-define62.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. +-commutative62.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*62.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-inv62.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-eval62.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-define62.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-eval62.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. Simplified62.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 100.0%

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

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

Alternative 8: 68.8% accurate, 1.3× speedup?

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

\\
-1 + {a}^{4}
\end{array}
Derivation
  1. Initial program 75.7%

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

      \[\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. +-commutative77.2%

      \[\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*77.2%

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

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

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

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

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

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

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

Alternative 9: 24.7% accurate, 130.0× speedup?

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

\\
-1
\end{array}
Derivation
  1. Initial program 75.7%

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

      \[\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. +-commutative77.2%

      \[\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*77.2%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  7. Final simplification30.0%

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

Reproduce

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