Bouland and Aaronson, Equation (26)

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

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

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

\\
\mathsf{fma}\left(b \cdot 4, b, -1 + {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\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. Step-by-step derivation
    1. sqr-pow99.9%

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(\frac{4}{2}\right)}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
    7. add-sqr-sqrt99.9%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(a \cdot a + b \cdot b, \sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
    12. add-sqr-sqrt99.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 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 3: 69.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1700:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -4.3 \cdot 10^{-20}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq -1.7 \cdot 10^{-75}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq -1.15 \cdot 10^{-211}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{-214}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq 8.5 \cdot 10^{-165}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 4.4 \cdot 10^{-10}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq 6 \cdot 10^{+21}:\\ \;\;\;\;{b}^{4}\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -1700.0)
   (pow a 4.0)
   (if (<= a -4.3e-20)
     (pow b 4.0)
     (if (<= a -1.7e-75)
       -1.0
       (if (<= a -1.15e-211)
         (pow b 4.0)
         (if (<= a 2.3e-214)
           -1.0
           (if (<= a 8.5e-165)
             (pow b 4.0)
             (if (<= a 4.4e-10)
               -1.0
               (if (<= a 6e+21) (pow b 4.0) (pow a 4.0))))))))))
double code(double a, double b) {
	double tmp;
	if (a <= -1700.0) {
		tmp = pow(a, 4.0);
	} else if (a <= -4.3e-20) {
		tmp = pow(b, 4.0);
	} else if (a <= -1.7e-75) {
		tmp = -1.0;
	} else if (a <= -1.15e-211) {
		tmp = pow(b, 4.0);
	} else if (a <= 2.3e-214) {
		tmp = -1.0;
	} else if (a <= 8.5e-165) {
		tmp = pow(b, 4.0);
	} else if (a <= 4.4e-10) {
		tmp = -1.0;
	} else if (a <= 6e+21) {
		tmp = pow(b, 4.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 <= (-1700.0d0)) then
        tmp = a ** 4.0d0
    else if (a <= (-4.3d-20)) then
        tmp = b ** 4.0d0
    else if (a <= (-1.7d-75)) then
        tmp = -1.0d0
    else if (a <= (-1.15d-211)) then
        tmp = b ** 4.0d0
    else if (a <= 2.3d-214) then
        tmp = -1.0d0
    else if (a <= 8.5d-165) then
        tmp = b ** 4.0d0
    else if (a <= 4.4d-10) then
        tmp = -1.0d0
    else if (a <= 6d+21) then
        tmp = b ** 4.0d0
    else
        tmp = a ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (a <= -1700.0) {
		tmp = Math.pow(a, 4.0);
	} else if (a <= -4.3e-20) {
		tmp = Math.pow(b, 4.0);
	} else if (a <= -1.7e-75) {
		tmp = -1.0;
	} else if (a <= -1.15e-211) {
		tmp = Math.pow(b, 4.0);
	} else if (a <= 2.3e-214) {
		tmp = -1.0;
	} else if (a <= 8.5e-165) {
		tmp = Math.pow(b, 4.0);
	} else if (a <= 4.4e-10) {
		tmp = -1.0;
	} else if (a <= 6e+21) {
		tmp = Math.pow(b, 4.0);
	} else {
		tmp = Math.pow(a, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -1700.0:
		tmp = math.pow(a, 4.0)
	elif a <= -4.3e-20:
		tmp = math.pow(b, 4.0)
	elif a <= -1.7e-75:
		tmp = -1.0
	elif a <= -1.15e-211:
		tmp = math.pow(b, 4.0)
	elif a <= 2.3e-214:
		tmp = -1.0
	elif a <= 8.5e-165:
		tmp = math.pow(b, 4.0)
	elif a <= 4.4e-10:
		tmp = -1.0
	elif a <= 6e+21:
		tmp = math.pow(b, 4.0)
	else:
		tmp = math.pow(a, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -1700.0)
		tmp = a ^ 4.0;
	elseif (a <= -4.3e-20)
		tmp = b ^ 4.0;
	elseif (a <= -1.7e-75)
		tmp = -1.0;
	elseif (a <= -1.15e-211)
		tmp = b ^ 4.0;
	elseif (a <= 2.3e-214)
		tmp = -1.0;
	elseif (a <= 8.5e-165)
		tmp = b ^ 4.0;
	elseif (a <= 4.4e-10)
		tmp = -1.0;
	elseif (a <= 6e+21)
		tmp = b ^ 4.0;
	else
		tmp = a ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -1700.0)
		tmp = a ^ 4.0;
	elseif (a <= -4.3e-20)
		tmp = b ^ 4.0;
	elseif (a <= -1.7e-75)
		tmp = -1.0;
	elseif (a <= -1.15e-211)
		tmp = b ^ 4.0;
	elseif (a <= 2.3e-214)
		tmp = -1.0;
	elseif (a <= 8.5e-165)
		tmp = b ^ 4.0;
	elseif (a <= 4.4e-10)
		tmp = -1.0;
	elseif (a <= 6e+21)
		tmp = b ^ 4.0;
	else
		tmp = a ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -1700.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -4.3e-20], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, -1.7e-75], -1.0, If[LessEqual[a, -1.15e-211], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 2.3e-214], -1.0, If[LessEqual[a, 8.5e-165], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 4.4e-10], -1.0, If[LessEqual[a, 6e+21], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1700:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq -4.3 \cdot 10^{-20}:\\
\;\;\;\;{b}^{4}\\

\mathbf{elif}\;a \leq -1.7 \cdot 10^{-75}:\\
\;\;\;\;-1\\

\mathbf{elif}\;a \leq -1.15 \cdot 10^{-211}:\\
\;\;\;\;{b}^{4}\\

\mathbf{elif}\;a \leq 2.3 \cdot 10^{-214}:\\
\;\;\;\;-1\\

\mathbf{elif}\;a \leq 8.5 \cdot 10^{-165}:\\
\;\;\;\;{b}^{4}\\

\mathbf{elif}\;a \leq 4.4 \cdot 10^{-10}:\\
\;\;\;\;-1\\

\mathbf{elif}\;a \leq 6 \cdot 10^{+21}:\\
\;\;\;\;{b}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1700 or 6e21 < 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*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 95.0%

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

    if -1700 < a < -4.30000000000000011e-20 or -1.70000000000000008e-75 < a < -1.14999999999999994e-211 or 2.30000000000000011e-214 < a < 8.5e-165 or 4.3999999999999998e-10 < a < 6e21

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

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

    if -4.30000000000000011e-20 < a < -1.70000000000000008e-75 or -1.14999999999999994e-211 < a < 2.30000000000000011e-214 or 8.5e-165 < a < 4.3999999999999998e-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. Step-by-step derivation
      1. sqr-pow99.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(\frac{4}{2}\right)}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      7. add-sqr-sqrt99.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a + b \cdot b, \sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      12. add-sqr-sqrt99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1700:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -4.3 \cdot 10^{-20}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq -1.7 \cdot 10^{-75}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq -1.15 \cdot 10^{-211}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{-214}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq 8.5 \cdot 10^{-165}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 4.4 \cdot 10^{-10}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq 6 \cdot 10^{+21}:\\ \;\;\;\;{b}^{4}\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 4: 97.8% accurate, 1.0× speedup?

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

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

\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.99999999999999977e-7

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

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

    if 4.99999999999999977e-7 < (*.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. unpow296.7%

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

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    6. Simplified96.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.0%

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

Alternative 5: 99.9% accurate, 1.0× speedup?

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

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

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

Alternative 6: 94.5% accurate, 1.0× speedup?

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

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

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


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

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

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

    if 1.9999999999999999e-7 < (*.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. Step-by-step derivation
      1. sqr-pow99.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(\frac{4}{2}\right)}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      7. add-sqr-sqrt99.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a + b \cdot b, \sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      12. add-sqr-sqrt99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 67.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.1 \cdot 10^{-20}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq 1.25 \cdot 10^{-213}:\\
\;\;\;\;-1\\

\mathbf{elif}\;a \leq 1.05 \cdot 10^{-165}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\

\mathbf{elif}\;a \leq 3 \cdot 10^{-9}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -5.10000000000000019e-20 or 2.99999999999999998e-9 < 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*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 86.2%

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

    if -5.10000000000000019e-20 < a < 1.24999999999999994e-213 or 1.04999999999999997e-165 < a < 2.99999999999999998e-9

    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. Step-by-step derivation
      1. sqr-pow99.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(\frac{4}{2}\right)}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      7. add-sqr-sqrt99.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a + b \cdot b, \sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      12. add-sqr-sqrt99.9%

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

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

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

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

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

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

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

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

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

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

    if 1.24999999999999994e-213 < a < 1.04999999999999997e-165

    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. Simplified99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.1 \cdot 10^{-20}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 1.25 \cdot 10^{-213}:\\ \;\;\;\;-1\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-165}:\\ \;\;\;\;4 \cdot \left(b \cdot b\right)\\ \mathbf{elif}\;a \leq 3 \cdot 10^{-9}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 8: 94.4% accurate, 1.1× speedup?

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

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

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


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

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

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

    if 4e20 < (*.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 94.7%

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

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

Alternative 9: 51.2% accurate, 12.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.235:\\
\;\;\;\;-1\\

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


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

    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. Step-by-step derivation
      1. sqr-pow99.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(\frac{4}{2}\right)}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      7. add-sqr-sqrt99.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a \cdot a + b \cdot b, \sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
      12. add-sqr-sqrt99.9%

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

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

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

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

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

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

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

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

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

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

    if 0.23499999999999999 < (*.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. unpow296.7%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 24.6% accurate, 116.0× speedup?

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

\\
-1
\end{array}
Derivation
  1. Initial program 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. Step-by-step derivation
    1. sqr-pow99.9%

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(\frac{4}{2}\right)}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
    7. add-sqr-sqrt99.9%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(a \cdot a + b \cdot b, \sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}, \mathsf{fma}\left(b, b \cdot 4, -1\right)\right) \]
    12. add-sqr-sqrt99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification24.6%

    \[\leadsto -1 \]

Reproduce

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