Bill Allombert on Wed, 20 Mar 2019 18:56:21 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Evaluating Multiple Sums in PARI/GP


On Fri, Feb 15, 2019 at 08:28:37PM +0300, kevin lucas wrote:
> I recently ran into problems attempting to formulate a PARI program that
> evaluated the expression
> 
> sum(((-1)^(a+b+c))/(a^2 + b^2 + c^2)^s)
> 
> for various complex values of s, with a,b,c running over Z^3/{(0,0,0)}. How
> should I attempt this? More generally, how should one set up iterated
> alternating sums like these? If, for instance I also wanted the
> eight-dimensional version of the above sum, how would I compute it?

I have created a git branch bill-lfunqf which adds support for quadratic
forms with an odd number of variables to lfunqf.

So in this branch, you can compute
sum(1/(a^2 + b^2 + c^2)^4)
with 

? L=lfunqf(matid(3));
? lfun(L,4)
%30 = 6.9458079272263696241707780231117151644

The additive character can be added using the standard linear algebra
trick.

L1=lfunqf(matdiagonal([1,1,1]));
L2=lfunqf(matdiagonal([4,1,1]));
L3=lfunqf(matdiagonal([4,4,1]));
F(s)=6*lfun(L2,s)-12*lfun(L3,s)-lfun(L1,s)*(1-8/4^s)
Where 
F is equal to sum(((-1)^(a+b+c))/(a^2 + b^2 + c^2)^s)

(which you can checck using this brute force approximation:
h(s,B=10)=sum(a=-B,B,sum(b=-B,B,sum(c=-B,B,my(u=a^2+b^2+c^2);if(u,((-1)^(a+b+c))/u^s,0.))))
which is accurate as long as B^s is small enough).

For the 8-variables version, you do not need this branch.
You can do the same, thought it becomes a bit cumbersome to write down.

trick(n)=
{
  my(gen(L,S)=s->sum(i=1,n,S[i]*lfun(L[i],s))+S[n+1]*lfun(L[1],s)/4^s);
  my(L,M,V,C,S);
  L=vector(n,i,lfunqf(matdiagonal(vector(n,j,if(j<i,4,1)))));
  M=matrix(2^n,2^n,i,j,vecsum(binary(bitand(i-1,j-1)))==0);
  V=vector(2^n,i,(-1)^hammingweight(i-1));
  C=matsolve(M,V~);
  S=sum(i=1,2^n,my(c=hammingweight(i-1));vector(n+1,i,i-1==c)*C[i]);
  gen(L,S);
}
F=trick(8);
F(5)
%3 = -13.645422314366283523895801862859342064
? ##
  ***   last result computed in 5,917 ms.

F should be what you want.

Cheers,
Bill.