?

Average Accuracy: 38.9% → 37.9%
Time: 8.3s
Precision: binary64
Cost: 7300

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 b b) < 4e15

    1. Initial program 66.1%

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

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

    if 4e15 < (*.f64 b b)

    1. Initial program 11.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 12.5%

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

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

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

Alternatives

Alternative 1
Accuracy39.0%
Cost19776
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \]
Alternative 2
Accuracy38.9%
Cost7424
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1 \]
Alternative 3
Accuracy32.2%
Cost6976
\[b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right) + -1 \]
Alternative 4
Accuracy32.2%
Cost704
\[\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1 \]
Alternative 5
Accuracy26.0%
Cost448
\[4 \cdot \left(b \cdot b\right) + -1 \]

Error

Reproduce?

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