Interpolyatsion ko`phadni MS Excel dasturida qurish va hisoblash
Quyidagi jadval bilan berilgan ko`phad uchun uchinchi darajali Lagranj interpolyasion ko’phadi tuzish va x=1 nuqtada uning qiymatini hisoblash ketma-ketligini MS Excel dasturida hal etishga harakat qilamiz:
i
|
0
|
1
|
2
|
3
|
|
0
|
2
|
3
|
5
|
|
1
|
3
|
2
|
5
|
Interpolyatsiya tugunlarini mos ravishda quyidagi ko`rinishda Excel ish varag’iga kiritamiz:
Diagramma ustasidan foydalanib, quyidagi diagramma turini tanlaymiz:
Hosil bo`lgan grafik chizmasi ustida sichqoncha o`ng tugmasini bosib, hosil bo`lgan kontekst menyudan Добавит линию тренда… buyrug’ini ishga tushiramiz:
Hosil bo`lgan oynadan Полиномиальная bo`limiga 3 darajali deb tanlaymiz:
Oynaning Параметры bo`limiga o`tib, показывать уравнение на диаграмме qismini faollashtiramiz:
Natijada quyidagi grafik va funksiyani ifodalovchi oynaga ega bo`lamiz:
Diagrammada ko`rinib turganidek, 3-darajali y=0.3x3-2.1667x2+4.1333x+1 ko`phadga ega bo`lamiz. MS Excel dasturi yordamida hisoblash ishlarini olib borib,
=0,3*C2^3-2,1667*C2^2+4,1333*C2+1
formula asosida
natijaga erishamiz.
2.2. Interpolyatsion ko`phadni Paskal dasturida qurish va hisoblash
Yuqoridagi masalani hal etish, interpolyatsion ko`phadni qurish va masalaning natijasini olish uchun Paskal dasturidan foydalanish qulay.
program FormLagr;
const
Nmax = 50;
type
massiv = array[0..Nmax] of real;
var
X,Y,D: massiv;
P,x0: Real;
i,j,n: Integer;
function Lagr(x0:real):Real;
var
s:real;
begin
s:=0;
for i:=0 to n do
s:=s+Y[i]/((x0-X[i])*D[i]+0);
lagr:=P*s;
end;
begin
Write('n= ');
ReadLn(n);
for i:=0 to n do begin
Write('x',i,'= ');
ReadLn(X[i]);
Write('y',i,'= ');
ReadLn(Y[i]);
end;
{D}
for i:=0 to n do begin
D[i]:=1;
for j:=0 to n do
if j<>i then
D[i]:=D[i]*(X[i]-X[j]);
end; {D}
repeat
Write('x= ');
ReadLn(x0);
{P}
P:=1;
for i:=0 to n do
P:=P*(x0-X[i]); {P}
WriteLn('y= ',lagr(x0):3:3);
until false;
end.
Dastur natijasi:
1.3. Interpolyatsion ko`phadni MathCad dasturida qurish va hisoblash
MathCadda yuqoridagi masalani hal etish, interpolyatsion ko`phadni qurish va masalaning natijasini olish uchun MathCad ishchi varag’iga quyidagi massivlarni kiritamiz:
Quyidagi funksiyani yozib,
f(1) ifoda uchun quyidagi natijani olamiz:
funksiyasi yordamida ko`phadning qiymatlar sohasini qurib, uning grafigini yasaymiz:
MathCad oynasida bizga tanish funksiya grafigi namoyon bo`ladi.
1.4. Interpolyatsion ko`phadni Maple dasturida qurish va baholash
Bizga ma’lumki, Maple dasturi boshqa matematik paketlarga qaraganda birmuncha imkoniyatlari kengroq sanaladi.
Maple dasturida quyidagi algoritm asosida yuqorida qo`yilgan masala uchun yechim olamiz:
> t:=[0,2,3,5];
> z:=[1,3,2,5];
> x:=[1,2,3];
> interp(t,z,y);
> Z:=y->interp(t,z,y);
> for i from 1 to 3 do X[i]:=Z(x[i]);end do;
>
> 49/15.0;
> t:=[0,2,3,5];
> z:=[1,3,2,5];
> x:=[1,2,3];
> l:=[[t[n],z[n]]$n=1..4]; plot([l,Z(y)],y=1..5,style=[point,line],symbol=circle);
Warning, unable to evaluate 1 of the 2 functions to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct
Maple dasturining grafik imkoniyatidan foydalanib, biz istagan natija va funksiya grafigiga ega bo`lamiz:
Do'stlaringiz bilan baham: |