Question: Problem: Sum with greater "lower" number is not zero

Hi there!

Essentially, sum(sqrt(-2),x=2..1) is, as it should be, 0. My issue is, that e.g. sum(sqrt(-2),x=2..0) or sum(sqrt(-2),x=2..-1)  are declared by Maple as -I*sqrt(2) and -(2*I)*sqrt(2), which, to my knowledge, is not true, and should be 0 as well. I need those results for a rather complicated algorithm to be 0, otherwise it doesn't work.

NEUZMinus:= proc(Unten, Oben, f,G,Liste,n)::real;
  #Unten:= Untere Intervallgrenze; Oben:= Obere Intervallgrenze; g:= zu integrierende Funktion;
  #G:= Gewicht; n:= Hinzuzufügende Knoten;
 
  Basenwechsel:=proc(Dividend, m);
 
  print(Anfang,Dividend,p[m]);
  Koeffizient:=quo(Dividend, p[m],x);

  Rest:=rem(Dividend, p[m],x);
 
  if m=0 then
    Basenwechsel:=[Koeffizient];
  else

    Basenwechsel:=[Koeffizient,op(Basenwechsel(Rest,m-1))];
   
  end if;
 
  end proc;
p[-1]:=0;
p[0]:=1;
for i from 1 to max(n,numelems(Liste)) do
  p[i]:=x^i-add(int(x^i*p[j]*diff(G,x),x=Unten..Oben)*p[j]/int(p[j]^2*diff(G,x),x=Unten..Oben),j=0..i-1);
  print(p[i]);
c[i-1]:=lcoeff(p[i],x)/lcoeff(p[i-1],x);
d[i-1]:=coeff(p[i],x,(i-1))/coeff(p[i-1],x,(i-1));
if i <> 1 then
  e[i-1]:=coeff(p[i]-(c[i-1]*x+d[i-1])*p[i-1],x,i-2)/coeff(p[i-2],x,i-2);
else
  e[i-1]:=1;
end if;
end do;
print(Liste[1],numelems(Liste));
Hn:=mul(x-Liste[i],i=1..numelems(Liste));
print(Hn);
 Koeffizienten:=Basenwechsel(Hn,numelems(Liste));
print(Koeffizienten);
for j from 0 to numelems(Liste)-1 do
  a[s][j][j]:=1;
end do;
for s from 1 to numelems(Liste)-1 do
  a[s][0]:=[1];
  a[s][1]:=[-e[s]*c[0]/c[s],d[0]-d[s]*c[0]/c[s],c[0]/c[s]];
  for j from 2 to numelems(Liste)-1 do
    print(1);
    a[s][j][abs(s-j)]:=sum(-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1],i=abs(s-j)..min(abs(s-j),s+j-2));
    print(2);
    a[s][j][abs(s-j)+1]:=sum(d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i],i=abs(s-j)+1..min(abs(s-j)+1,s+j-1)+sum(-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1],         i=abs(s-j)+1..min(abs(s-j)+1,s+j-2));
    print(3);
    for i from abs(s-j)+2 to s+j-2 do
      a[s][j][i]:=c[j-1]*a[s][j-1][i-1]/c[i-1]+(d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i]-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1]+e[j-1]*a[s][j-2][i];

      print(4);
    end do;
    a[s][j][s+j-1]:=sum(c[j-1]*a[s][j-1][i-1]/c[i-1],i=max(s-j+2,s+j-1)..s+j-1)+sum((d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i],i=max(s-j+1,s+j-1));
    print(5);
    a[s][j][s+j]:=sum(c[j-1]*a[s][j-1][i-1]/c[i-1],i=max(s-j+2,s+j)..s+j);
    print(6);
  end do;
end do
 

end proc

 

In the case of

a[s][j][abs(s-j)+1]:=sum(d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i],i=abs(s-j)+1..min(abs(s-j)+1,s+j-1)+sum(-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1],         i=abs(s-j)+1..min(abs(s-j)+1,s+j-2));

 
 
for example, the
i=abs(s-j)+1..min(abs(s-j)+1,s+j-2) clause in the end checks, wether the term should be added or not. I basically just need a way to tell Maple wether to add a term or not, depending on wether abs(s-j)+1 is not greater than s+j-2 in this case, without using if-clauses if possible. The problem here is, that min(abs(s-j)+1,s+j-2) can become 0, Maple then tries to calculate something instead of returning 0, and then complains when something inside the term is not properly defined (c[j-1] can become c[-1] for example when j=0) and aborts the entire procedure. How can I tell it to just assign 0?
 
 
 
 
 
Please Wait...