FISH.

Click Here for Free Traffic!




Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/virtwww/w_beloshenko-org-ua_e2c5fc46/http/topp.php on line 8

Warning: include(http://www.beloshenko.org.ua/panel.html) [function.include]: failed to open stream: no suitable wrapper could be found in /home/virtwww/w_beloshenko-org-ua_e2c5fc46/http/topp.php on line 8

Warning: include() [function.include]: Failed opening 'http://www.beloshenko.org.ua/panel.html' for inclusion (include_path='.:') in /home/virtwww/w_beloshenko-org-ua_e2c5fc46/http/topp.php on line 8







Lagrange interpolation.

void main()
{
 // real x(100),y(100),x1(100)

 float x[100];
 float y[100];
 float x1[100];

 // real p,x_,L_

 float p;
 float x_;
 float L_;

 // integer i,j,k,N,M

 int i;
 int j;
 int k;
 int N;
 int M;

 // open(unit=1,file='lagr.dat',status='old')
 // open(unit=2,file='lagr.res',status='new')
 // read(1,*)N
 // if(N.GE.100) goto 1
 // read(1,*)(x(i),i=1,N)
 // read(1,*)(y(i),i=1,N)
 // read(1,*)M
 // if(M.GE.100) goto 1
 // read(1,*)(x1(i),i=1,M)
 // write(2,*)M
 // write(2,*)

 // Вхідні дані
 N=4;
 x[1]=1;
 x[2]=3;
 x[3]=5;
 x[4]=7;
 y[1]=1;
 y[2]=9;
 y[3]=25;
 y[4]=49;
 M=6;
 x1[1]=0;
 x1[2]=1;
 x1[3]=2;
 x1[4]=3;
 x1[5]=4;
 x1[6]=5;

 // do 2 i=1,M
    //   x_=x1(i)
    //     L_=0
    //     do 3 j=1,N
    //          p=1
    //          do 4 k=1,j-1
    //              p=p*(x_-x(k))/(x(j)-x(k))
    // 4        continue
    //          do 5 k=j+1,N
    //              p=p*(x_-x(k))/(x(j)-x(k))
    // 5        continue
    //          L_=L_+y(j)*p
    // 3   continue
    //     write(2,*)L_
    // 2 continue
   
 // 1   close(2)
    //     close(1)
    //  stop
    //  end

 // Обробка
 for(i=1; i<=M; i++)
 {
  x_=x1[i];
  L_=0;
  for(j=1; j<=N; j++)
  {
   p=1;
   for(k=1; k<=j-1; k++)
   {
    p=p*(x_-x[k])/(x[j]-x[k]);
   };
   for(k=j+1; k<=N; k++)
   {
    p=p*(x_-x[k])/(x[j]-x[k]);
   };
   L_+=y[j]*p;
  };
  L_=L_;
 };
}








Click Here for Free Traffic!

FISH.