%Zum Initialisieren f\"ur Remez.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%MATLAB-Programm, Gerhard Opfer, Approximation, SS 1995, s. remez.info 
%leicht modifiziert Juni 1998, f\"ur "Numerische Mathematik f\"ur Anf\"anger"
%Wieder hervorgeholt für Approximation SS 1999 und SS 2000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
n=7; %n ist Dimension! Polynomgrad also n-1
%Testfunktion=1;  %exp(-x^2)  in [0,1]
%Testfunktion=2;  %Bessel J_1 in [0,7]
%Testfunktion=3;  %xsin(1/x)  in [0.05,1]; %schwierig!
%Testfunktion=4;  %sin pi/4x  in [0,1]; %geht sehr gut, erzeugt kleinen Fehler
%Testfunktion=5;  %tan pi/4x  in [0,1];
 Testfunktion=6;  %gamma x  in [1,2];

k=linspace(0,pi,n+1);
[y,a,b]=remeztestf(Testfunktion,1);
        %Wird nur gebraucht, um a, b zu bestimmen
Knoten=0.5*((b+a)-(b-a)*cos(k)); %T-Knoten
%Nur f\"ur xsin(1/x):  %Die T_Knoten werden \"uberschrieben, zum Testen weglassen!
if Testfunktion==3 & n==6
   Knoten=[0.0917  0.1325 0.2163  0.3987 0.6709 0.9078 1.0000]; %Jan M. 16.6.95
end; %if
if Testfunktion==3 & n==9
  Knoten=[
   0.05000000000000   0.09237875288684   0.13163972286374   0.20323325635104 ...
   0.33256351039261   0.51270207852194   0.69745958429561   0.85450346420323 ...
   0.96073903002309   1.00000000000000];
end; 
[unten,oben,Knoten]=remez(Knoten,Testfunktion);
disp('Untere, obere Schranken und Knoten nach dem ersten Aufruf');
Schranken=[unten,oben], Knoten
return;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Gute Knotenwahlen f\"ur n=6 (Polynomgrad=5):
%Fall 1: Glockenkurve exp(-x^2) in [0,1]:
%        0      0.1132 0.3210 0.5704 0.7852 0.9469 1.0000, Fehler 1.6e-5
%Fall 2: Besselfunktion J_1     in [0,7]:
%        0.1132 1.1316 2.5866 4.0901 5.5612 6.6120 7.0000, Fehler 4.8e-3
%Fall 3: xsin(1/x) s.o.
%Fall 4: sin x in [0,pi/4]
%        0      0.0553 0.2046 0.4037 0.5954 0.7328 0.7854, Fehler 6.1e-8
%Fall 5: tan x in [0,pi/4]
%        0      0.0596 0.2124 0.4174 0.6087 0.7404 0.7854, Fehler 4.6e-5
%Fall 6: gamma x in [1,2]
%        1      1.0622 1.2281 1.4724 1.7327 1.9286 2.0000, Fehler 3.7e-5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
