GVA SUPPORT

³äïîâ³äü íà çàïèòàííÿ ¹ 1319558776
Text:
	ԲΠ= Skliarov to Gorbachenko

 Çàïèòàííÿ:
#include <iostream>
#include <Math.h>
#include <conio.h>
#include <stdio.h>
using namespace std; 
double lagrange(double *xmas, double *ymas, int n, double x, double &dx) 
  { 
    double rez = 0, f; 
    for(int i = 0; i < n; i++) 
      { 
        f = 1.0; 
        for(int j = 0; j < n; j++) 
          { 
            if (i != j) f *= (x - *(xmas + j))/(*(xmas + i) - *(xmas + j)); 
          } 
        rez += *(ymas + i)*f; 
      } 
    dx = fabs(pow(x,0.5) - rez); 
    return rez; 
  }
int main()
{
    double a;
    double * xmas;
    double * ymas; 
    double * reslt; 
    double dx, err = 0;
    xmas=(double*)malloc(8*sizeof(double));
    ymas=(double*)malloc(8*sizeof(double)); 
    reslt=(double*)malloc(11*sizeof(double)); 
    for(int i=0;i<8;i++)
    {
            *(xmas+i)= cos((2*i+1)*M_PI/16)+1;
    }
    for(int i=0;i<8;i++)
    {
            *(ymas+i)=pow(*(xmas+i),0.5);
    }
    double F=0;
    for(int i = 0; i < 11; i++) 
      { 
        *(reslt + i) = lagrange(xmas, ymas, 8, i*0.2, dx); 
        if (dx > err) err = dx;  
      } 
      cout<<"Znachenia x     "<<"Table(function)"<<"       "<<"Interpolation"<<endl;
    for(int i = 0; i < 11; i++) 
      { 
        cout <<i*0.2<<"              "<< pow(i*0.2,0.5) <<"                     "<< *(reslt + i) << endl; 
      } 
    cout << err<<endl;
    a = lagrange(xmas, ymas, 8, 3, dx); 
    cout << a <<endl;
 system("Pause");
 return 0;   
}

====================================	
Âàøà â³äïîâ³äü