Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.8% → 99.0%
Time: 8.2s
Alternatives: 11
Speedup: 9.9×

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 11 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.8% 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.0% accurate, 1.1× speedup?

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

\\
{\left(b \cdot b + a \cdot a\right)}^{2} + \left(\left(b \cdot b\right) \cdot 4 + -1\right)
\end{array}
Derivation
  1. Initial program 75.3%

    \[\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+75.3%

      \[\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-def75.3%

      \[\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. Simplified76.4%

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

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

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

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

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

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

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

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

Alternative 2: 96.8% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 1.00000000000000006e-9

    1. Initial program 83.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+83.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-def83.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. Simplified83.4%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000006e-9 < (*.f64 b b)

    1. Initial program 68.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+68.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-def68.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. Simplified70.2%

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

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

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

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

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

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

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

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

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

Alternative 3: 96.8% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.5e18 or 1.95e11 < a

    1. Initial program 48.3%

      \[\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+48.3%

        \[\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-def48.3%

        \[\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. Simplified50.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 99.8%

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

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

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

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

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

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

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

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

    if -2.5e18 < a < 1.95e11

    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 98.7%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      3. distribute-rgt-out97.8%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} - 1 \]
    11. Applied egg-rr97.8%

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

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

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

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

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

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

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

        \[\leadsto b \cdot \left(\color{blue}{\left(b \cdot b\right) \cdot b} + 4 \cdot b\right) - 1 \]
      7. distribute-rgt-out97.8%

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

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

      \[\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 simplification97.5%

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

Alternative 4: 96.8% accurate, 6.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.5e18 or 1.05e10 < a

    1. Initial program 48.3%

      \[\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+48.3%

        \[\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-def48.3%

        \[\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. Simplified50.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 99.8%

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

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

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

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

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

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

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

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

    if -2.5e18 < a < 1.05e10

    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 98.7%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      3. distribute-rgt-out97.8%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} - 1 \]
    11. Applied egg-rr97.8%

      \[\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 simplification97.5%

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

Alternative 5: 87.5% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -4.8e21

    1. Initial program 32.2%

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

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

        \[\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. Simplified37.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 inf 59.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. associate-*r*59.2%

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

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

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right)} \cdot \left(b \cdot b\right) \]
    9. Simplified59.2%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right) \cdot \left(b \cdot b\right)} \]
    10. Taylor expanded in a around 0 59.2%

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

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

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. *-commutative59.2%

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

        \[\leadsto 2 \cdot \color{blue}{\left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]
    12. Simplified73.7%

      \[\leadsto \color{blue}{2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]

    if -4.8e21 < a < 3.6000000000000002e102

    1. Initial program 97.1%

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

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

        \[\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. Simplified97.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 98.7%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      3. distribute-rgt-out94.7%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} - 1 \]
    11. Applied egg-rr94.7%

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
    14. Simplified94.2%

      \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]

    if 3.6000000000000002e102 < a

    1. Initial program 63.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+63.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-def63.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. Simplified63.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 100.0%

      \[\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+100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.8 \cdot 10^{+21}:\\ \;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{elif}\;a \leq 3.6 \cdot 10^{+102}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1\\ \end{array} \]

Alternative 6: 88.1% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -4.8e21

    1. Initial program 32.2%

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

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

        \[\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. Simplified37.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 inf 59.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. associate-*r*59.2%

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

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

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right)} \cdot \left(b \cdot b\right) \]
    9. Simplified59.2%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right) \cdot \left(b \cdot b\right)} \]
    10. Taylor expanded in a around 0 59.2%

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

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

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. *-commutative59.2%

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

        \[\leadsto 2 \cdot \color{blue}{\left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]
    12. Simplified73.7%

      \[\leadsto \color{blue}{2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]

    if -4.8e21 < a < 3.50000000000000011e102

    1. Initial program 97.1%

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

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

        \[\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. Simplified97.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 98.7%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      3. distribute-rgt-out94.7%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} - 1 \]
    11. Applied egg-rr94.7%

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

    if 3.50000000000000011e102 < a

    1. Initial program 63.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+63.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-def63.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. Simplified63.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 100.0%

      \[\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+100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.8 \cdot 10^{+21}:\\ \;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{+102}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1\\ \end{array} \]

Alternative 7: 73.7% accurate, 9.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 0.44\right):\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\

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


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

    1. Initial program 52.2%

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

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

        \[\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. Simplified54.4%

      \[\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 inf 68.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. associate-*r*63.5%

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

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

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right)} \cdot \left(b \cdot b\right) \]
    9. Simplified63.5%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right) \cdot \left(b \cdot b\right)} \]
    10. Taylor expanded in a around 0 63.5%

      \[\leadsto \color{blue}{2 \cdot \left({a}^{2} \cdot {b}^{2}\right)} \]
    11. Step-by-step derivation
      1. unpow263.5%

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]
    12. Simplified74.1%

      \[\leadsto \color{blue}{2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]

    if -2.39999999999999991 < a < 0.440000000000000002

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 85.3% accurate, 9.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+21} \lor \neg \left(a \leq 7.8 \cdot 10^{+39}\right):\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4.8e21 or 7.8000000000000002e39 < a

    1. Initial program 47.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+47.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-def47.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. Simplified49.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 inf 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}\right) \]
      2. unpow268.1%

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. associate-*r*68.1%

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

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

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right)} \cdot \left(b \cdot b\right) \]
    9. Simplified68.1%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot 2\right)\right) \cdot \left(b \cdot b\right)} \]
    10. Taylor expanded in a around 0 68.1%

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

        \[\leadsto 2 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}\right) \]
      2. unpow268.1%

        \[\leadsto 2 \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
      3. *-commutative68.1%

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

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

      \[\leadsto \color{blue}{2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)} \]

    if -4.8e21 < a < 7.8000000000000002e39

    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 98.6%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} - 1 \]
    11. Applied egg-rr96.5%

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

      \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{{b}^{2}} - 1 \]
    13. Step-by-step derivation
      1. unpow295.9%

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
    14. Simplified95.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.8 \cdot 10^{+21} \lor \neg \left(a \leq 7.8 \cdot 10^{+39}\right):\\ \;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1\\ \end{array} \]

Alternative 9: 70.3% accurate, 11.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2e292

    1. Initial program 80.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+80.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-def80.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. Simplified80.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 b around 0 63.4%

      \[\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+63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e292 < (*.f64 b b)

    1. Initial program 59.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} \]
    12. Simplified97.4%

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

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

Alternative 10: 51.6% accurate, 14.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 3.2000000000000001e-7

    1. Initial program 83.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+83.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-def83.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. Simplified83.4%

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

      \[\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+83.1%

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 3.2000000000000001e-7 < (*.f64 b b)

    1. Initial program 68.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+68.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-def68.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. Simplified70.2%

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} \]
    12. Simplified51.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 3.2 \cdot 10^{-7}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot 4\\ \end{array} \]

Alternative 11: 26.1% accurate, 130.0× speedup?

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

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

    \[\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+75.3%

      \[\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-def75.3%

      \[\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. Simplified76.4%

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

    \[\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+51.4%

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification23.5%

    \[\leadsto -1 \]

Reproduce

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