?

Average Error: 0.2 → 0.0
Time: 8.0s
Precision: binary64
Cost: 20480

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.2

    \[\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 0.0

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

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

    [Start]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    unpow2 [=>]0.0

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

    unpow2 [=>]0.0

    \[ \left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  4. Applied egg-rr0.0

    \[\leadsto \left(\color{blue}{\left({b}^{4} + \left({a}^{4} + {\left(a \cdot b\right)}^{2} \cdot 2\right)\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  5. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost13504
\[\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + b \cdot \left(b \cdot 4\right)\right) + -1 \]
Alternative 2
Error0.1
Cost7936
\[\left(4 \cdot \left(b \cdot b\right) + \left({b}^{4} + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\right)\right) + -1 \]
Alternative 3
Error2.2
Cost7432
\[\begin{array}{l} \mathbf{if}\;b \leq -56:\\ \;\;\;\;{b}^{4} + \left(b \cdot b\right) \cdot \left(4 + 2 \cdot \left(a \cdot a\right)\right)\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{+16}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + 2 \cdot \left(\left(b \cdot b\right) \cdot \left(a \cdot a\right)\right)\\ \end{array} \]
Alternative 4
Error0.2
Cost7424
\[\left(4 \cdot \left(b \cdot b\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + -1 \]
Alternative 5
Error1.8
Cost7305
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;a \leq -30 \lor \neg \left(a \leq 0.0011\right):\\ \;\;\;\;\left({a}^{4} + t_0\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 6
Error1.7
Cost7305
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;a \leq -30 \lor \neg \left(a \leq 0.00098\right):\\ \;\;\;\;\left({a}^{4} + t_0\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + t_0\right) + -1\\ \end{array} \]
Alternative 7
Error1.8
Cost6921
\[\begin{array}{l} \mathbf{if}\;a \leq -30 \lor \neg \left(a \leq 0.0075\right):\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 8
Error1.9
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \leq -30 \lor \neg \left(a \leq 0.00022\right):\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\ \end{array} \]
Alternative 9
Error1.9
Cost1225
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;a \leq -30 \lor \neg \left(a \leq 0.0019\right):\\ \;\;\;\;\left(t_0 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 10
Error11.8
Cost704
\[\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1 \]
Alternative 11
Error12.7
Cost576
\[\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1 \]
Alternative 12
Error22.8
Cost448
\[b \cdot \left(b \cdot 4\right) + -1 \]

Error

Reproduce?

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