Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 5.4s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\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: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \end{array} \]
(FPCore (a b)
 :precision binary64
 (+ (pow (hypot a b) 4.0) (fma b (* b 4.0) -1.0)))
double code(double a, double b) {
	return pow(hypot(a, b), 4.0) + fma(b, (b * 4.0), -1.0);
}
function code(a, b)
	return Float64((hypot(a, b) ^ 4.0) + fma(b, Float64(b * 4.0), -1.0))
end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

    \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \]

Alternative 2: 98.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 1000000:\\ \;\;\;\;{a}^{4} + -1\\ \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) 1000000.0)
   (+ (pow a 4.0) -1.0)
   (+ (pow b 4.0) (* (* b b) (+ 4.0 (* (* a a) 2.0))))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1000000.0) {
		tmp = pow(a, 4.0) + -1.0;
	} 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) <= 1000000.0d0) then
        tmp = (a ** 4.0d0) + (-1.0d0)
    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) <= 1000000.0) {
		tmp = Math.pow(a, 4.0) + -1.0;
	} 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) <= 1000000.0:
		tmp = math.pow(a, 4.0) + -1.0
	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) <= 1000000.0)
		tmp = Float64((a ^ 4.0) + -1.0);
	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) <= 1000000.0)
		tmp = (a ^ 4.0) + -1.0;
	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], 1000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $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 1000000:\\
\;\;\;\;{a}^{4} + -1\\

\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) < 1e6

    1. Initial program 99.8%

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

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

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

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

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

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

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

    if 1e6 < (*.f64 b b)

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

    if 1e6 < (*.f64 b b)

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) -1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -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 * (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) + -1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) + -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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}

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

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

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

Alternative 5: 94.0% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a a) < 9.9999999999999996e81

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

    if 9.9999999999999996e81 < (*.f64 a a)

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

Alternative 6: 79.5% accurate, 7.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a a) < 2.0000000000000001e47

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e47 < (*.f64 a a)

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
      6. distribute-rgt-out57.6%

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(2 \cdot \color{blue}{\left(a \cdot a\right)}\right) \]
    11. Simplified57.6%

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

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

Alternative 7: 59.1% accurate, 8.8× speedup?

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

\\
\begin{array}{l}
t_0 := b \cdot \left(b \cdot 4\right) + -1\\
\mathbf{if}\;b \leq 9.5 \cdot 10^{-45}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq 2 \cdot 10^{-9}:\\
\;\;\;\;2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right)\\

\mathbf{elif}\;b \leq 1.9:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 9.5000000000000002e-45 or 2.00000000000000012e-9 < b < 1.8999999999999999

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if 9.5000000000000002e-45 < b < 2.00000000000000012e-9

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
      6. distribute-rgt-out36.6%

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\left(\left(b \cdot a\right) \cdot \left(b \cdot a\right)\right)} \]
    11. Simplified36.6%

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

    if 1.8999999999999999 < b

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    11. Simplified89.9%

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

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

Alternative 8: 58.9% accurate, 8.8× speedup?

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

\\
\begin{array}{l}
t_0 := b \cdot \left(b \cdot 4\right) + -1\\
\mathbf{if}\;b \leq 2.1 \cdot 10^{-68}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq 6.2 \cdot 10^{-10}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot 2\right)\\

\mathbf{elif}\;b \leq 1.9:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 2.10000000000000008e-68 or 6.2000000000000003e-10 < b < 1.8999999999999999

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if 2.10000000000000008e-68 < b < 6.2000000000000003e-10

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
      6. distribute-rgt-out47.3%

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

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

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

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

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

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

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

    if 1.8999999999999999 < b

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    11. Simplified89.9%

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

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

Alternative 9: 68.9% accurate, 10.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if 2e-14 < (*.f64 b b)

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    11. Simplified88.6%

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

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

Alternative 10: 45.4% accurate, 16.6× speedup?

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

\\
\left(b \cdot b\right) \cdot \left(b \cdot b\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
    6. distribute-rgt-out55.0%

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

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

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

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

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

      \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
  11. Simplified43.5%

    \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
  12. Final simplification43.5%

    \[\leadsto \left(b \cdot b\right) \cdot \left(b \cdot b\right) \]

Alternative 11: 27.3% accurate, 23.2× speedup?

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

\\
4 \cdot \left(b \cdot b\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
    6. distribute-rgt-out55.0%

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

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

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

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

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

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

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

      \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\mathsf{fma}\left(b, b, 4\right)} \]
  11. Simplified43.7%

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

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

      \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} \]
  14. Simplified24.7%

    \[\leadsto \color{blue}{4 \cdot \left(b \cdot b\right)} \]
  15. Final simplification24.7%

    \[\leadsto 4 \cdot \left(b \cdot b\right) \]

Reproduce

?
herbie shell --seed 2023222 
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (26)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))