Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Linear interpolation

Читайте также:
  1. Full Title Nonlinear Optical Analogous Correction for Distortions in Wide Spectral Band Imaging Telescopes Tech Area / Field
  2. Home assignment 2. Multiple Linear Regression Model. Transformations of variables.
  3. Linearization
  4. Relating the linear and angular characteristics
  5. Закладка NONLINEAR SOLVER

Linear interpolation is quick and easy, but it is not very precise. Another disadvantage is that the interpolant is not differentiable at the point xk. The following error estimate shows that linear interpolation is not very precise. The error is proportional to the square of the distance between the data points. The error in some other methods, including polynomial interpolation and spline interpolation, is proportional to higher powers of the distance between the data points. These methods also produce smoother interpolants.

Polynomial interpolation

Polynomial interpolation is a generalization of linear interpolation. Note that the linear interpolant is a linear function. We now replace this interpolant by a polynomial of higher degree.

Spline interpolation

Linear interpolation uses a linear function for each of intervals. Spline interpolation uses low-degree polynomials in each of the intervals, and chooses the polynomial pieces such that they fit smoothly together. The resulting function is called a spline.

Interpolation via Gaussian processes

Gaussian process is a powerful non-linear interpolation tool. Many popular interpolation tools are actually equivalent to particular Gaussian processes. Gaussian processes can be used not only for fitting an interpolant that passes exactly through the given data points but also for regression, i.e., for fitting a curve through noisy data. In the geostatistics community Gaussian process regression is also known as Kriging.

Piecewise constant interpolation

The simplest interpolation method is to locate the nearest data value, and assign the same value. In simple problems, this method is unlikely to be used, as linear interpolation is almost as easy, but in higher dimensional multivariate interpolation, this could be a favourable choice for its speed and simplicity.

5)What is a polynomial approximation?

Polynomial interpolation is the interpolation of a given data set by a polynomial: given some points, find a polynomial which goes exactly through these points.

6) What is interpolation of Lagrange polynomial?

Lagrange polynomials are used for polynomial interpolation. For a given set of distinct points and numbers , the Lagrange polynomial is the polynomial of the least degree that at each point assumes the corresponding value (i.e. the functions coincide at each point). The interpolating polynomial of the least degree is unique, however, and it is therefore more appropriate to speak of "the Lagrange form" of that unique polynomial rather than "the Lagrange interpolation polynomial," since the same polynomial can be arrived at through multiple methods.

7) What functions and operators did you use in MathCad?

 

 

Calculations

In Mathcad

Lagrange polynomial

 

2)In C++ Builder

Code in C++ Builder

#include <Math.hpp>

#include <math.h>

// subprogramme of Lagrange polynomial

double lagrang (double *x, double *y, int n,double xp)

{ int i,j; double p,yr;

yr=0;

for (i=0;i<n;i++)

{ p=1;

for (j=0;j<n;j++)

if (i!=j) p*=(xp-x[j])/(x[i]-x[j]);

yr+=y[i]*p;

} return yr;

}

void __fastcall TForm1:: Button1Click( TObject *Sender)

{ double x[20],y[20]; int i,n,n1;

n=Memo1->Lines->Count-1;

for (i=0;i<n;i++)

x[i]=StrToFloat(Memo1->Lines->Strings[i+1]); //

n1=Memo2->Lines->Count-1;

if (n!=n1)

{ ShowMessage ("Check up the quantity of numbers! "); exit; }

for (i=0;i<n;i++)

{ y[i]=StrToFloat(Memo2->Lines->Strings[i+1]);

Series1->AddXY(x[i],y[i],"",clRed);

}

double xbeg,xend,h,xt,yt,yp;int kt;

if (Edit1->Text=="") { ShowMessage("Input the number of test points! "); exit;}

kt=StrToInt(Edit1->Text);

xbeg=x[0];

xend=x[n-1];

h=(double)(xend-xbeg)/(kt-1);

if (xbeg>xend ||h<=0)

{ ShowMessage("Bad data"); exit;}

xt=xbeg;

Memo3->Clear();

do { yp=lagrang(x,y,n,xt);

Memo3->Lines->Add("x="+FloatToStrF(xt,ffFixed,5,1)+" yp="+FloatToStrF(yp,ffFixed,6,3));

Series2->AddXY(xt,yp,"",clGreen);

xt+=h;

} while (xt<=xend);}

 

Results

In Mathcad:

Interpolation by algebraic polynomial:

Lagrange polynomial:

In C++ Builder:

x=2,7 y=10,185

x=3,0 y=11,000

x=3,3 y=12,259

x=3,7 y=14,185

x=4,0 y=17,000

 

Conclusion

I have successfully studied the Mathcad(Congratulatians?)

Допиливаем вывод сами

 

 

Literature

1. «Программирование в среде MathCad

(Валерий Очхов)


Дата добавления: 2015-11-14; просмотров: 32 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Theoretical Part| Task: Read out and learn the following expressions with the verb to be.

mybiblioteka.su - 2015-2024 год. (0.008 сек.)