Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 6.0s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ {\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: 94.3% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+44}:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right) + -1\\

\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+84}:\\
\;\;\;\;{a}^{4}\\

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


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

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

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

    if 2e16 < (*.f64 b b) < 2.0000000000000002e44

    1. Initial program 98.7%

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

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

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

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

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

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

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

    if 2.0000000000000002e44 < (*.f64 b b) < 5.0000000000000001e84

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

        \[\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 inf 73.5%

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

    if 5.0000000000000001e84 < (*.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*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 inf 95.7%

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

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

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

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

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

\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+44}:\\
\;\;\;\;{b}^{4}\\

\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+84}:\\
\;\;\;\;{a}^{4}\\

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


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

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

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

    if 2e16 < (*.f64 b b) < 2.0000000000000002e44 or 5.0000000000000001e84 < (*.f64 b b)

    1. Initial program 99.8%

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

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

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

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

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.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 inf 95.9%

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

    if 2.0000000000000002e44 < (*.f64 b b) < 5.0000000000000001e84

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

        \[\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 inf 73.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+16}:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+44}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+84}:\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]

Alternative 5: 81.8% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;a \leq 6.8 \cdot 10^{+46}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq 1.45 \cdot 10^{+76}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < 35

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

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

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

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

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

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

    if 35 < a < 6.7999999999999996e46 or 1.4500000000000001e76 < a

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if 6.7999999999999996e46 < a < 1.4500000000000001e76

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 81.8% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;a \leq 3.05 \cdot 10^{+47}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq 1.45 \cdot 10^{+76}:\\
\;\;\;\;{b}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < 35

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

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

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

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

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

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

    if 35 < a < 3.05000000000000009e47 or 1.4500000000000001e76 < a

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if 3.05000000000000009e47 < a < 1.4500000000000001e76

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

        \[\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 inf 80.4%

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

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

Alternative 7: 70.5% accurate, 7.7× speedup?

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

\\
\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \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 67.6%

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

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

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

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

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

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

Alternative 8: 70.5% 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 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 51.6% accurate, 16.6× speedup?

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

\\
4 \cdot \left(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 67.6%

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

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

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

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

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

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

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

Alternative 10: 24.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 67.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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