Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 3.7s
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, 0.5× speedup?

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

\\
\left({\left(\mathsf{fma}\left(b, b, a \cdot a\right)\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. Taylor expanded in a around 0 99.9%

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

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

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

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

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

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

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

Alternative 3: 99.9% accurate, 1.0× speedup?

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

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

Alternative 4: 94.1% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000008e99 < (*.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. Step-by-step derivation
      1. associate--l+100.0%

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

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

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

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

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

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

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

Alternative 5: 94.1% accurate, 1.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000008e99 < (*.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. Step-by-step derivation
      1. associate--l+100.0%

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

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

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

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

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

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

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

Alternative 6: 94.1% accurate, 7.7× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.70000000000000024e99 < (*.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. Step-by-step derivation
      1. associate--l+100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} - 1} \]
    5. Step-by-step derivation
      1. metadata-eval97.4%

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

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

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

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

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

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

Alternative 7: 77.3% accurate, 10.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.94999999999999992e153

    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 b around 0 73.0%

      \[\leadsto \color{blue}{{a}^{4} - 1} \]
    5. Step-by-step derivation
      1. metadata-eval73.0%

        \[\leadsto {a}^{\color{blue}{\left(2 \cdot 2\right)}} - 1 \]
      2. pow-pow73.0%

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

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

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(a \cdot a\right)} - 1 \]
    6. Applied egg-rr73.0%

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

    if 1.94999999999999992e153 < b

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 51.2% accurate, 16.6× speedup?

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

\\
b \cdot \left(b \cdot 4\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. 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 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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