Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 5.2s
Alternatives: 8
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 8 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) \]
    6. unpow199.9%

      \[\leadsto \left(\color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} \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) \]
    7. sqr-pow99.9%

      \[\leadsto \left(\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)} \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) \]
    8. unpow399.9%

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

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

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

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

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(\color{blue}{b \cdot \left(4 \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: 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 3: 97.0% accurate, 1.0× speedup?

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

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

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


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

    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. Taylor expanded in a around 0 99.1%

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

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

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

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

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

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

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

    if 9.99999999999999958e27 < (*.f64 a a)

    1. Initial program 100.0%

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

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

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

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

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

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

Alternative 4: 97.0% accurate, 6.1× speedup?

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

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

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


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

    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. Taylor expanded in a around 0 99.1%

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

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

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

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

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

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

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

    if 6.5000000000000005e27 < (*.f64 a a)

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 5: 69.2% accurate, 10.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 4.8e-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*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) \]
      6. unpow1100.0%

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

        \[\leadsto \left(\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)} \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) \]
      8. unpow3100.0%

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(\color{blue}{b \cdot \left(4 \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 0 48.8%

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

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

    if 4.8e-10 < (*.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) \]
      6. unpow199.9%

        \[\leadsto \left(\color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} \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) \]
      7. sqr-pow99.9%

        \[\leadsto \left(\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)} \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) \]
      8. unpow399.9%

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(\color{blue}{b \cdot \left(4 \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 0 87.9%

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

      \[\leadsto \color{blue}{{b}^{4}} \]
    6. Step-by-step derivation
      1. metadata-eval86.9%

        \[\leadsto {b}^{\color{blue}{\left(2 \cdot 2\right)}} \]
      2. pow-pow86.8%

        \[\leadsto \color{blue}{{\left({b}^{2}\right)}^{2}} \]
      3. pow286.8%

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

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
    7. Applied egg-rr86.8%

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

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

Alternative 6: 69.2% accurate, 10.5× speedup?

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

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

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


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

    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. Taylor expanded in a around 0 48.8%

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

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

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

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

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

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

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

    if 1.99999999999999988e-11 < (*.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) \]
      6. unpow199.9%

        \[\leadsto \left(\color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} \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) \]
      7. sqr-pow99.9%

        \[\leadsto \left(\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)} \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) \]
      8. unpow399.9%

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(\color{blue}{b \cdot \left(4 \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 0 87.9%

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

      \[\leadsto \color{blue}{{b}^{4}} \]
    6. Step-by-step derivation
      1. metadata-eval86.9%

        \[\leadsto {b}^{\color{blue}{\left(2 \cdot 2\right)}} \]
      2. pow-pow86.8%

        \[\leadsto \color{blue}{{\left({b}^{2}\right)}^{2}} \]
      3. pow286.8%

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

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} \]
    7. Applied egg-rr86.8%

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

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

Alternative 7: 69.9% accurate, 10.5× speedup?

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

\\
\left(b \cdot b\right) \cdot \left(4 + b \cdot b\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. Taylor expanded in a around 0 68.0%

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

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

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

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

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

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

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

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

Alternative 8: 25.5% 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) \]
    6. unpow199.9%

      \[\leadsto \left(\color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} \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) \]
    7. sqr-pow99.9%

      \[\leadsto \left(\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)} \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) \]
    8. unpow399.9%

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

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

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

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

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(\color{blue}{b \cdot \left(4 \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 0 68.1%

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

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification25.0%

    \[\leadsto -1 \]

Reproduce

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