Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.5% → 99.9%
Time: 7.6s
Alternatives: 10
Speedup: 8.6×

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 10 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.5% 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.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + \color{blue}{a \cdot \left({a}^{2} \cdot 4\right)} \]
      6. unpow243.5%

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

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

        \[\leadsto \color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + a \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right) \]
      9. metadata-eval43.5%

        \[\leadsto {a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(2 \cdot 2\right)}} + a \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right) \]
      10. pow-sqr43.5%

        \[\leadsto {a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2} \cdot {a}^{2}} + a \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right) \]
      11. *-commutative43.5%

        \[\leadsto {a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{2} \cdot {a}^{2} + \color{blue}{\left(\left(a \cdot a\right) \cdot 4\right) \cdot a}\right) \]
      12. unpow243.5%

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

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

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

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

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

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

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

Alternative 2: 99.2% accurate, 0.4× speedup?

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

\\
\left(\left(2 \cdot {\left(b \cdot a\right)}^{2} + {b}^{4}\right) + {a}^{4}\right) + \left(4 \cdot \left(b \cdot b\right) + -1\right)
\end{array}
Derivation
  1. Initial program 72.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+72.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. fma-def72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+22} \lor \neg \left(a \leq 4.5 \cdot 10^{+17}\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -1.4e+22) (not (<= a 4.5e+17)))
   (* (* a a) (+ (fma 2.0 (* b b) 4.0) (* a (+ a 4.0))))
   (+ (+ (pow b 4.0) (* 4.0 (* b b))) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -1.4e+22) || !(a <= 4.5e+17)) {
		tmp = (a * a) * (fma(2.0, (b * b), 4.0) + (a * (a + 4.0)));
	} else {
		tmp = (pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if ((a <= -1.4e+22) || !(a <= 4.5e+17))
		tmp = Float64(Float64(a * a) * Float64(fma(2.0, Float64(b * b), 4.0) + Float64(a * Float64(a + 4.0))));
	else
		tmp = Float64(Float64((b ^ 4.0) + Float64(4.0 * Float64(b * b))) + -1.0);
	end
	return tmp
end
code[a_, b_] := If[Or[LessEqual[a, -1.4e+22], N[Not[LessEqual[a, 4.5e+17]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * N[(N[(2.0 * N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision] + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4 \cdot 10^{+22} \lor \neg \left(a \leq 4.5 \cdot 10^{+17}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + 4\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.4e22 or 4.5e17 < a

    1. Initial program 41.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + \color{blue}{a \cdot \left({a}^{2} \cdot 4\right)} \]
      6. unpow265.0%

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

        \[\leadsto \color{blue}{\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + a \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right)} \]
      8. *-commutative65.0%

        \[\leadsto \color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + a \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right) \]
      9. metadata-eval65.0%

        \[\leadsto {a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(2 \cdot 2\right)}} + a \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right) \]
      10. pow-sqr64.9%

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

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

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

        \[\leadsto {a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{2} \cdot {a}^{2} + \color{blue}{{a}^{2} \cdot \left(4 \cdot a\right)}\right) \]
      14. distribute-lft-out97.9%

        \[\leadsto {a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{2} \cdot \left({a}^{2} + 4 \cdot a\right)} \]
      15. distribute-lft-out97.9%

        \[\leadsto \color{blue}{{a}^{2} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + \left({a}^{2} + 4 \cdot a\right)\right)} \]
      16. unpow297.9%

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

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

    if -1.4e22 < a < 4.5e17

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+22} \lor \neg \left(a \leq 4.5 \cdot 10^{+17}\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]

Alternative 4: 93.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{+30}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq 6.4 \cdot 10^{+69}:\\
\;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4.2e30 or 6.3999999999999997e69 < a

    1. Initial program 39.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+39.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. fma-def39.9%

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

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

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

    if -4.2e30 < a < 6.3999999999999997e69

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 93.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -2 \cdot 10^{+30} \lor \neg \left(a \leq 2.45 \cdot 10^{+70}\right):\\ \;\;\;\;{a}^{4}\\ \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 (or (<= a -2e+30) (not (<= a 2.45e+70)))
   (pow a 4.0)
   (+ -1.0 (* b (* b (fma b b 4.0))))))
double code(double a, double b) {
	double tmp;
	if ((a <= -2e+30) || !(a <= 2.45e+70)) {
		tmp = pow(a, 4.0);
	} else {
		tmp = -1.0 + (b * (b * fma(b, b, 4.0)));
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if ((a <= -2e+30) || !(a <= 2.45e+70))
		tmp = a ^ 4.0;
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * fma(b, b, 4.0))));
	end
	return tmp
end
code[a_, b_] := If[Or[LessEqual[a, -2e+30], N[Not[LessEqual[a, 2.45e+70]], $MachinePrecision]], N[Power[a, 4.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}\;a \leq -2 \cdot 10^{+30} \lor \neg \left(a \leq 2.45 \cdot 10^{+70}\right):\\
\;\;\;\;{a}^{4}\\

\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 a < -2e30 or 2.45000000000000014e70 < a

    1. Initial program 39.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+39.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. fma-def39.9%

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

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

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

    if -2e30 < a < 2.45000000000000014e70

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {b}^{4} + \color{blue}{\left(b \cdot \left(b \cdot 4\right) + -1\right)} \]
      8. associate-+l+95.4%

        \[\leadsto \color{blue}{\left({b}^{4} + b \cdot \left(b \cdot 4\right)\right) + -1} \]
      9. metadata-eval95.4%

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

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

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

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} + b \cdot \left(b \cdot 4\right)\right) + -1 \]
      13. associate-*r*95.3%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot 4}\right) + -1 \]
      14. distribute-lft-in95.3%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} + -1 \]
      15. associate-*l*95.3%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(b \cdot b + 4\right)\right)} + -1 \]
      16. fma-def95.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2 \cdot 10^{+30} \lor \neg \left(a \leq 2.45 \cdot 10^{+70}\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\ \end{array} \]

Alternative 6: 93.5% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -8 \cdot 10^{+31} \lor \neg \left(a \leq 4.2 \cdot 10^{+69}\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.9999999999999997e31 or 4.2000000000000003e69 < a

    1. Initial program 39.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+39.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. fma-def39.9%

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

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

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

    if -7.9999999999999997e31 < a < 4.2000000000000003e69

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({b}^{4} + \left(b \cdot b\right) \cdot \color{blue}{4}\right) + -1 \]
    11. Step-by-step derivation
      1. metadata-eval95.4%

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

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

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

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} + \left(b \cdot b\right) \cdot 4\right) + -1 \]
      5. distribute-lft-out95.3%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} + -1 \]
    12. Applied egg-rr95.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -8 \cdot 10^{+31} \lor \neg \left(a \leq 4.2 \cdot 10^{+69}\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]

Alternative 7: 85.2% accurate, 8.6× speedup?

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

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

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


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

    1. Initial program 30.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(4 \cdot {a}^{2} + 4 \cdot {a}^{3}\right) - 1} \]
    8. Step-by-step derivation
      1. distribute-lft-out54.2%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{{a}^{2}} + a \cdot {a}^{2}, -1\right) \]
      10. distribute-rgt1-in54.2%

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

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

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

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1} \]
      14. associate-*l*54.2%

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

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

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

        \[\leadsto \left(a \cdot 4\right) \cdot \color{blue}{\left(\left(a + 1\right) \cdot a\right)} + -1 \]
      18. distribute-lft1-in54.2%

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

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

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

      \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
    11. Step-by-step derivation
      1. unpow2100.0%

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

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

    if -6.49999999999999972e153 < a < 6.49999999999999972e153

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({b}^{4} + \left(b \cdot b\right) \cdot \color{blue}{4}\right) + -1 \]
    11. Step-by-step derivation
      1. metadata-eval83.0%

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

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

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

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} + \left(b \cdot b\right) \cdot 4\right) + -1 \]
      5. distribute-lft-out82.9%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} + -1 \]
    12. Applied egg-rr82.9%

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

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

Alternative 8: 60.7% accurate, 9.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -6.9999999999999998e153 or -1.7600000000000001e-289 < a

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(4 \cdot {a}^{2} + 4 \cdot {a}^{3}\right) - 1} \]
    8. Step-by-step derivation
      1. distribute-lft-out50.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{{a}^{2}} + a \cdot {a}^{2}, -1\right) \]
      10. distribute-rgt1-in50.9%

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

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

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

        \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1} \]
      14. associate-*l*50.9%

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

        \[\leadsto \color{blue}{\left(4 \cdot a\right) \cdot \left(a \cdot \left(a + 1\right)\right)} + -1 \]
      16. *-commutative50.9%

        \[\leadsto \color{blue}{\left(a \cdot 4\right)} \cdot \left(a \cdot \left(a + 1\right)\right) + -1 \]
      17. *-commutative50.9%

        \[\leadsto \left(a \cdot 4\right) \cdot \color{blue}{\left(\left(a + 1\right) \cdot a\right)} + -1 \]
      18. distribute-lft1-in50.9%

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

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

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

      \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
    11. Step-by-step derivation
      1. unpow261.0%

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

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

    if -6.9999999999999998e153 < a < -1.7600000000000001e-289

    1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{a \cdot \left(\left(b \cdot b\right) \cdot -12\right)} + -1 \]
      4. *-commutative59.6%

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

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

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

Alternative 9: 51.6% accurate, 18.6× speedup?

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

\\
-1 + 4 \cdot \left(a \cdot a\right)
\end{array}
Derivation
  1. Initial program 72.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+72.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. fma-def72.9%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(4 \cdot {a}^{2} + 4 \cdot {a}^{3}\right) - 1} \]
  8. Step-by-step derivation
    1. distribute-lft-out44.5%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(4, \color{blue}{{a}^{2}} + a \cdot {a}^{2}, -1\right) \]
    10. distribute-rgt1-in44.5%

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

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

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

      \[\leadsto \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1} \]
    14. associate-*l*44.5%

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

      \[\leadsto \color{blue}{\left(4 \cdot a\right) \cdot \left(a \cdot \left(a + 1\right)\right)} + -1 \]
    16. *-commutative44.5%

      \[\leadsto \color{blue}{\left(a \cdot 4\right)} \cdot \left(a \cdot \left(a + 1\right)\right) + -1 \]
    17. *-commutative44.5%

      \[\leadsto \left(a \cdot 4\right) \cdot \color{blue}{\left(\left(a + 1\right) \cdot a\right)} + -1 \]
    18. distribute-lft1-in44.5%

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

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

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

    \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
  11. Step-by-step derivation
    1. unpow251.4%

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

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

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

Alternative 10: 25.7% accurate, 130.0× speedup?

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

\\
-1
\end{array}
Derivation
  1. Initial program 72.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+72.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. fma-def72.9%

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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