Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 5.1s
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) \]
  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: 97.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if 5e15 < (*.f64 b b)

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.9% accurate, 1.0× speedup?

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

\\
-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right)
\end{array}
Derivation
  1. Initial program 99.9%

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

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

Alternative 4: 79.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{if}\;a \leq -2.8 \cdot 10^{+41}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -9.4 \cdot 10^{-122}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq -9 \cdot 10^{-182}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{elif}\;a \leq 4.7 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (+ -1.0 (* b (* b 4.0)))))
   (if (<= a -2.8e+41)
     (pow a 4.0)
     (if (<= a -9.4e-122)
       t_0
       (if (<= a -9e-182)
         (* (* b b) (+ 4.0 (* b b)))
         (if (<= a 4.7e+39) t_0 (pow a 4.0)))))))
double code(double a, double b) {
	double t_0 = -1.0 + (b * (b * 4.0));
	double tmp;
	if (a <= -2.8e+41) {
		tmp = pow(a, 4.0);
	} else if (a <= -9.4e-122) {
		tmp = t_0;
	} else if (a <= -9e-182) {
		tmp = (b * b) * (4.0 + (b * b));
	} else if (a <= 4.7e+39) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (-1.0d0) + (b * (b * 4.0d0))
    if (a <= (-2.8d+41)) then
        tmp = a ** 4.0d0
    else if (a <= (-9.4d-122)) then
        tmp = t_0
    else if (a <= (-9d-182)) then
        tmp = (b * b) * (4.0d0 + (b * b))
    else if (a <= 4.7d+39) then
        tmp = t_0
    else
        tmp = a ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double t_0 = -1.0 + (b * (b * 4.0));
	double tmp;
	if (a <= -2.8e+41) {
		tmp = Math.pow(a, 4.0);
	} else if (a <= -9.4e-122) {
		tmp = t_0;
	} else if (a <= -9e-182) {
		tmp = (b * b) * (4.0 + (b * b));
	} else if (a <= 4.7e+39) {
		tmp = t_0;
	} else {
		tmp = Math.pow(a, 4.0);
	}
	return tmp;
}
def code(a, b):
	t_0 = -1.0 + (b * (b * 4.0))
	tmp = 0
	if a <= -2.8e+41:
		tmp = math.pow(a, 4.0)
	elif a <= -9.4e-122:
		tmp = t_0
	elif a <= -9e-182:
		tmp = (b * b) * (4.0 + (b * b))
	elif a <= 4.7e+39:
		tmp = t_0
	else:
		tmp = math.pow(a, 4.0)
	return tmp
function code(a, b)
	t_0 = Float64(-1.0 + Float64(b * Float64(b * 4.0)))
	tmp = 0.0
	if (a <= -2.8e+41)
		tmp = a ^ 4.0;
	elseif (a <= -9.4e-122)
		tmp = t_0;
	elseif (a <= -9e-182)
		tmp = Float64(Float64(b * b) * Float64(4.0 + Float64(b * b)));
	elseif (a <= 4.7e+39)
		tmp = t_0;
	else
		tmp = a ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = -1.0 + (b * (b * 4.0));
	tmp = 0.0;
	if (a <= -2.8e+41)
		tmp = a ^ 4.0;
	elseif (a <= -9.4e-122)
		tmp = t_0;
	elseif (a <= -9e-182)
		tmp = (b * b) * (4.0 + (b * b));
	elseif (a <= 4.7e+39)
		tmp = t_0;
	else
		tmp = a ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.8e+41], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -9.4e-122], t$95$0, If[LessEqual[a, -9e-182], N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4.7e+39], t$95$0, N[Power[a, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;a \leq -9.4 \cdot 10^{-122}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;a \leq 4.7 \cdot 10^{+39}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -2.7999999999999999e41 or 4.6999999999999999e39 < a

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -2.7999999999999999e41 < a < -9.3999999999999999e-122 or -8.9999999999999998e-182 < a < 4.6999999999999999e39

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

        \[\leadsto \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(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*l*99.9%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, b \cdot b, -1\right)} \]
    8. Step-by-step derivation
      1. fma-udef71.3%

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

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

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

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

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

    if -9.3999999999999999e-122 < a < -8.9999999999999998e-182

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2.8 \cdot 10^{+41}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -9.4 \cdot 10^{-122}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{elif}\;a \leq -9 \cdot 10^{-182}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{elif}\;a \leq 4.7 \cdot 10^{+39}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 5: 79.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{if}\;a \leq -2.8 \cdot 10^{+41}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -1.46 \cdot 10^{-120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq -2.1 \cdot 10^{-181}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 4.2 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (+ -1.0 (* b (* b 4.0)))))
   (if (<= a -2.8e+41)
     (pow a 4.0)
     (if (<= a -1.46e-120)
       t_0
       (if (<= a -2.1e-181)
         (pow b 4.0)
         (if (<= a 4.2e+39) t_0 (pow a 4.0)))))))
double code(double a, double b) {
	double t_0 = -1.0 + (b * (b * 4.0));
	double tmp;
	if (a <= -2.8e+41) {
		tmp = pow(a, 4.0);
	} else if (a <= -1.46e-120) {
		tmp = t_0;
	} else if (a <= -2.1e-181) {
		tmp = pow(b, 4.0);
	} else if (a <= 4.2e+39) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (-1.0d0) + (b * (b * 4.0d0))
    if (a <= (-2.8d+41)) then
        tmp = a ** 4.0d0
    else if (a <= (-1.46d-120)) then
        tmp = t_0
    else if (a <= (-2.1d-181)) then
        tmp = b ** 4.0d0
    else if (a <= 4.2d+39) then
        tmp = t_0
    else
        tmp = a ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double t_0 = -1.0 + (b * (b * 4.0));
	double tmp;
	if (a <= -2.8e+41) {
		tmp = Math.pow(a, 4.0);
	} else if (a <= -1.46e-120) {
		tmp = t_0;
	} else if (a <= -2.1e-181) {
		tmp = Math.pow(b, 4.0);
	} else if (a <= 4.2e+39) {
		tmp = t_0;
	} else {
		tmp = Math.pow(a, 4.0);
	}
	return tmp;
}
def code(a, b):
	t_0 = -1.0 + (b * (b * 4.0))
	tmp = 0
	if a <= -2.8e+41:
		tmp = math.pow(a, 4.0)
	elif a <= -1.46e-120:
		tmp = t_0
	elif a <= -2.1e-181:
		tmp = math.pow(b, 4.0)
	elif a <= 4.2e+39:
		tmp = t_0
	else:
		tmp = math.pow(a, 4.0)
	return tmp
function code(a, b)
	t_0 = Float64(-1.0 + Float64(b * Float64(b * 4.0)))
	tmp = 0.0
	if (a <= -2.8e+41)
		tmp = a ^ 4.0;
	elseif (a <= -1.46e-120)
		tmp = t_0;
	elseif (a <= -2.1e-181)
		tmp = b ^ 4.0;
	elseif (a <= 4.2e+39)
		tmp = t_0;
	else
		tmp = a ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = -1.0 + (b * (b * 4.0));
	tmp = 0.0;
	if (a <= -2.8e+41)
		tmp = a ^ 4.0;
	elseif (a <= -1.46e-120)
		tmp = t_0;
	elseif (a <= -2.1e-181)
		tmp = b ^ 4.0;
	elseif (a <= 4.2e+39)
		tmp = t_0;
	else
		tmp = a ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.8e+41], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -1.46e-120], t$95$0, If[LessEqual[a, -2.1e-181], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 4.2e+39], t$95$0, N[Power[a, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;a \leq -1.46 \cdot 10^{-120}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;a \leq -2.1 \cdot 10^{-181}:\\
\;\;\;\;{b}^{4}\\

\mathbf{elif}\;a \leq 4.2 \cdot 10^{+39}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -2.7999999999999999e41 or 4.1999999999999997e39 < a

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -2.7999999999999999e41 < a < -1.4599999999999999e-120 or -2.10000000000000003e-181 < a < 4.1999999999999997e39

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

        \[\leadsto \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(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*l*99.9%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, b \cdot b, -1\right)} \]
    8. Step-by-step derivation
      1. fma-udef71.3%

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

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

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

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

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

    if -1.4599999999999999e-120 < a < -2.10000000000000003e-181

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2.8 \cdot 10^{+41}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq -1.46 \cdot 10^{-120}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{elif}\;a \leq -2.1 \cdot 10^{-181}:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;a \leq 4.2 \cdot 10^{+39}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 6: 94.4% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if 5e15 < (*.f64 b b)

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

Alternative 7: 69.0% accurate, 8.9× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \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(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*l*100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, -1\right)} \]
      2. unpow260.7%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, -1\right) \]
      3. metadata-eval60.7%

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

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

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

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

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

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

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

    if 1.00000000000000004e-10 < (*.f64 b b)

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 50.7% accurate, 12.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.48 \lor \neg \left(b \leq 3.2 \cdot 10^{-15}\right):\\
\;\;\;\;b \cdot \left(b \cdot 4\right)\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.47999999999999998 or 3.1999999999999999e-15 < b

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.47999999999999998 < b < 3.1999999999999999e-15

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

        \[\leadsto \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(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*l*100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.48 \lor \neg \left(b \leq 3.2 \cdot 10^{-15}\right):\\ \;\;\;\;b \cdot \left(b \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 9: 51.2% accurate, 16.6× speedup?

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

\\
-1 + b \cdot \left(b \cdot 4\right)
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

      \[\leadsto \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(4 \cdot \left(b \cdot b\right) - 1\right) \]
    5. associate-*l*99.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, {b}^{2}, -1\right)} \]
    2. unpow254.5%

      \[\leadsto \mathsf{fma}\left(4, \color{blue}{b \cdot b}, -1\right) \]
    3. metadata-eval54.5%

      \[\leadsto \mathsf{fma}\left(4, b \cdot b, \color{blue}{-1}\right) \]
  7. Simplified54.5%

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

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

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

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

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

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

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

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

      \[\leadsto \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(4 \cdot \left(b \cdot b\right) - 1\right) \]
    5. associate-*l*99.9%

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification29.2%

    \[\leadsto -1 \]

Reproduce

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