Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 3.9s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 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.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. Final simplification100.0%

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

Alternative 2: 96.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-25}:\\ \;\;\;\;{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) 5e-25)
   (+ (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) <= 5e-25) {
		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) <= 5d-25) 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) <= 5e-25) {
		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) <= 5e-25:
		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) <= 5e-25)
		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) <= 5e-25)
		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], 5e-25], 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 5 \cdot 10^{-25}:\\
\;\;\;\;{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) < 4.99999999999999962e-25

    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 0 100.0%

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

    if 4.99999999999999962e-25 < (*.f64 b b)

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-25}:\\ \;\;\;\;{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: 96.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-25}:\\ \;\;\;\;{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) 5e-25)
   (+ (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) <= 5e-25) {
		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) <= 5e-25)
		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], 5e-25], 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 5 \cdot 10^{-25}:\\
\;\;\;\;{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) < 4.99999999999999962e-25

    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 0 100.0%

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

    if 4.99999999999999962e-25 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(4 + 2 \cdot \left(a \cdot a\right)\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
      6. distribute-lft-out96.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. +-commutative96.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-def96.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-rr96.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-25}:\\ \;\;\;\;{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.9%

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

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

Alternative 5: 94.1% accurate, 1.0× speedup?

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

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

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


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

    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 0 100.0%

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

    if 5e6 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.0% accurate, 1.1× speedup?

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

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

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


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

    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 0 100.0%

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

    if 5e6 < (*.f64 b b)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 43.4% accurate, 8.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e-38 < (*.f64 a a)

    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.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 64.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(4 + 2 \cdot \left(a \cdot a\right)\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
      6. distribute-lft-out64.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. +-commutative64.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-def64.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-rr64.5%

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

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

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

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

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

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

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

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

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

Alternative 8: 56.1% accurate, 8.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5999999999999999e83 < (*.f64 a a)

    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*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 72.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b \cdot b\right) \cdot \left(4 + 2 \cdot \left(a \cdot a\right)\right) + \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
      6. distribute-lft-out72.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. +-commutative72.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-def72.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-rr72.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 72.3%

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

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

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

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

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

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

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

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

Alternative 9: 28.1% 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.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 59.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{4 \cdot \left(b \cdot b\right)} \]
  13. Final simplification28.6%

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

Reproduce

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