Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 5.2s
Alternatives: 12
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 12 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: 98.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

    if 0.20000000000000001 < (*.f64 a 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. Taylor expanded in b around 0 85.6%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(2 \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      5. count-285.4%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(\left(b \cdot b\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      7. associate-*l*85.4%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \left(\color{blue}{b \cdot \left(b \cdot \left(a \cdot a\right)\right)} + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)\right) - 1 \]
      8. associate-*l*97.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot a \leq 0.2:\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + \left(b \cdot \left(a \cdot a\right)\right) \cdot \left(b + b\right)\right) + -1\\ \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: 98.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

    if 0.20000000000000001 < (*.f64 a 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. Taylor expanded in b around 0 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(2 \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      5. count-285.4%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(\left(b \cdot b\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      7. associate-*l*85.4%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \left(\color{blue}{b \cdot \left(b \cdot \left(a \cdot a\right)\right)} + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)\right) - 1 \]
      8. associate-*l*97.0%

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

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

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

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

Alternative 5: 98.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.20000000000000001 < (*.f64 a 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. Taylor expanded in b around 0 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(2 \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      5. count-285.4%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(\left(b \cdot b\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      7. associate-*l*85.4%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \left(\color{blue}{b \cdot \left(b \cdot \left(a \cdot a\right)\right)} + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)\right) - 1 \]
      8. associate-*l*97.0%

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

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

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

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

Alternative 6: 98.1% accurate, 5.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

      \[\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 0.20000000000000001 < (*.f64 a 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. Taylor expanded in b around 0 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(b \cdot b\right) \cdot \left(2 \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      5. count-285.4%

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

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \color{blue}{\left(\left(b \cdot b\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)}\right) - 1 \]
      7. associate-*l*85.4%

        \[\leadsto \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + \left(\color{blue}{b \cdot \left(b \cdot \left(a \cdot a\right)\right)} + \left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)\right) - 1 \]
      8. associate-*l*97.0%

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

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

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

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

Alternative 7: 97.4% accurate, 6.1× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if 0.170000000000000012 < (*.f64 a 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. Taylor expanded in b around 0 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 97.4% accurate, 6.1× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

      \[\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 0.12 < (*.f64 a 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. Taylor expanded in b around 0 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 70.2% accurate, 10.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 52.3% accurate, 16.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 27.1% accurate, 23.2× speedup?

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

\\
-1 + \left(b + b\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. Taylor expanded in a around 0 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{b \cdot \left(4 \cdot b\right)} - 1 \]
  10. Step-by-step derivation
    1. sub-neg50.8%

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

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

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

      \[\leadsto \color{blue}{\left(\sqrt{4} \cdot \sqrt{4}\right)} \cdot \left(b \cdot b\right) + \left(-1\right) \]
    5. swap-sqr50.8%

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

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

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

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

      \[\leadsto \left(b + b\right) \cdot \color{blue}{\left(b + b\right)} + \left(-1\right) \]
    10. flip-+0.0%

      \[\leadsto \left(b + b\right) \cdot \color{blue}{\frac{b \cdot b - b \cdot b}{b - b}} + \left(-1\right) \]
    11. +-inverses0.0%

      \[\leadsto \left(b + b\right) \cdot \frac{\color{blue}{0}}{b - b} + \left(-1\right) \]
    12. metadata-eval0.0%

      \[\leadsto \left(b + b\right) \cdot \frac{\color{blue}{\log 1}}{b - b} + \left(-1\right) \]
    13. +-inverses0.0%

      \[\leadsto \left(b + b\right) \cdot \frac{\log 1}{\color{blue}{0}} + \left(-1\right) \]
    14. metadata-eval0.0%

      \[\leadsto \left(b + b\right) \cdot \frac{\log 1}{\color{blue}{\log 1}} + \left(-1\right) \]
    15. associate-*r/0.0%

      \[\leadsto \color{blue}{\frac{\left(b + b\right) \cdot \log 1}{\log 1}} + \left(-1\right) \]
    16. metadata-eval0.0%

      \[\leadsto \frac{\left(b + b\right) \cdot \color{blue}{0}}{\log 1} + \left(-1\right) \]
    17. +-inverses0.0%

      \[\leadsto \frac{\left(b + b\right) \cdot \color{blue}{\left(b - b\right)}}{\log 1} + \left(-1\right) \]
    18. difference-of-squares0.0%

      \[\leadsto \frac{\color{blue}{b \cdot b - b \cdot b}}{\log 1} + \left(-1\right) \]
    19. metadata-eval0.0%

      \[\leadsto \frac{b \cdot b - b \cdot b}{\color{blue}{0}} + \left(-1\right) \]
    20. +-inverses0.0%

      \[\leadsto \frac{b \cdot b - b \cdot b}{\color{blue}{b - b}} + \left(-1\right) \]
    21. flip-+27.7%

      \[\leadsto \color{blue}{\left(b + b\right)} + \left(-1\right) \]
    22. metadata-eval27.7%

      \[\leadsto \left(b + b\right) + \color{blue}{-1} \]
  11. Applied egg-rr27.7%

    \[\leadsto \color{blue}{\left(b + b\right) + -1} \]
  12. Final simplification27.7%

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

Alternative 12: 26.2% 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. Taylor expanded in a around 0 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  11. Final simplification26.4%

    \[\leadsto -1 \]

Reproduce

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