Question: Recursive Polynomial Division

Hi there!

I am trying to express a given polynomial not in terms of the monomes, but in terms of some orthogonal polynomials p_i, i=1..n.

If I have let's say x^5+x^4+2x^2 then I first divide that term by p_5, then the remainder by p_4 and so on, until I have the wanted coefficients. My problem is, that Maple complains about my code:

Error, (in Basenwechsel) invalid input: op expects 1 or 2 arguments, but received 0.

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);
  print(Koeffizient);
  Rest:=rem(Dividend, p[m],x);
  print(Rest);
  if m=0 then
    Basenwechsel:=[Koeffizient];
  else
    
    Basenwechsel:=[Koeffizient,op(Basenwechsel(Rest,m-1))];
   print(Basenwechsel);
  end if;
  print(Durchlauf)
  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]);
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)
end proc
 

Funnily enough, when I add a print command before the op-function, it does 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);
  print(Koeffizient);
  Rest:=rem(Dividend, p[m],x);
  print(Rest);
  if m=0 then
    Basenwechsel:=[Koeffizient];
  else
    print(Basenwechsel(Rest,m-1));
    Basenwechsel:=[Koeffizient,op(Basenwechsel(Rest,m-1))];
   print(Basenwechsel);
  end if;
  print(Durchlauf)
  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]);
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)
end proc

Does anyone know how I can get rid of the print command without getting no result? And how does a simple print command change the outcome of an algorithm in the first place?

 

Thank you in advance,

Daniel Reksten

 

Please Wait...