Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 7.0s
Alternatives: 7
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 7 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.5× speedup?

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

\\
{\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + \left(4 \cdot \left(b \cdot b\right) + -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. fma-define99.9%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(\left(b \cdot b\right) \cdot 4 - 1\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-define99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {b}^{2} + \color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \left(a \cdot a\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
    12. add-sqr-sqrt84.6%

      \[\leadsto \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {b}^{2} + \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)} \cdot \left(a \cdot a\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
    13. pow284.6%

      \[\leadsto \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {b}^{2} + \color{blue}{{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{2}} \cdot \left(a \cdot a\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
    14. fma-define84.6%

      \[\leadsto \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {b}^{2} + {\left(\sqrt{\color{blue}{a \cdot a + b \cdot b}}\right)}^{2} \cdot \left(a \cdot a\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
    15. hypot-define84.6%

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

      \[\leadsto \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {b}^{2} + {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \color{blue}{{a}^{2}}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
  6. Applied egg-rr84.6%

    \[\leadsto \color{blue}{\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {b}^{2} + {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot {a}^{2}\right)} + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
  7. Step-by-step derivation
    1. distribute-lft-out99.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}} + \left(\left(b \cdot b\right) \cdot 4 - 1\right) \]
    12. pow-sqr100.0%

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

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

    \[\leadsto {\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + \left(4 \cdot \left(b \cdot b\right) + -1\right) \]
  10. Add Preprocessing

Alternative 2: 99.9% accurate, 1.0× speedup?

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

\\
\left({\left(b \cdot b + a \cdot a\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. Add Preprocessing
  3. Final simplification99.9%

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

Alternative 3: 81.2% accurate, 1.0× speedup?

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

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

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


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

    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.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.1199999999999999e59 < 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. fma-define99.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.1% accurate, 1.1× speedup?

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

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

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


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

    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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.04999999999999992e59 < 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. fma-define99.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 69.2% accurate, 7.7× speedup?

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

\\
\left(4 \cdot \left(b \cdot b\right) + -1\right) + b \cdot \left(b \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. 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. fma-define99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(4 \cdot \left(b \cdot b\right) + -1\right) + b \cdot \left(b \cdot \left(b \cdot b\right)\right) \]
  13. Add Preprocessing

Alternative 6: 51.6% accurate, 16.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 4 \cdot \left(b \cdot b\right) + -1 \]
  10. Add Preprocessing

Alternative 7: 25.0% 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. fma-define99.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  7. Add Preprocessing

Reproduce

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