Поможем написать учебную работу
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Мета: Засвоїти властивості поведінки різних інтерполяційних поліномів, реалізованих власноруч.
Завдання:
e(x) = | f(x) - PN(x) |
із кроком щонайменше уп'ятеро меншим, ніж крок інтерполяції, та побудувати на папері графіки цих помилок, як функцій від х.
Результати роботи програми:
Файл OUTPUT.txt
Chebuw: 0.14+0.03*T1+-0.01*T2+0.00*T3+-0.00*T4+0.00*T5
Ermit: 0.13+0.07*H1+-0.01*H2+0.01*H3+-0.00*H4+0.00*H5
Legandr: 0.15+0.02*P1+-0.01*P2+0.01*P3+-0.00*P4+0.00*P5
Lager: 0.11+-0.04*L1+0.01*L2+-0.00*L3+-0.00*L4+-0.00*L5
x= 3.800
Lagrang y=0.14179 f(x)=0.14179 0.000001048
Nuton forwardy=0.14179 f(x)=0.14179 0.000001048
Nuton back y=0.14179 f(x)=0.14179 0.000001048
Spline y=0.14179 f(x)=0.14182 0.000030587
Chebuw y=0.14179 f(x)=0.14179 0.000001048
Ermit y=0.14179 f(x)=0.14179 0.000001048
Legandr y=0.14179 f(x)=0.14179 0.000001048
Lager y=0.14179 f(x)=0.14179 0.000001048
Magor 0.00002
x= 3.900
Lagrang y=0.14234 f(x)=0.14234 0.000000348
Nuton forwardy=0.14234 f(x)=0.14234 0.000000348
Nuton back y=0.14234 f(x)=0.14234 0.000000348
Spline y=0.14234 f(x)=0.14235 0.000011753
Chebuw y=0.14234 f(x)=0.14234 0.000000348
Ermit y=0.14234 f(x)=0.14234 0.000000348
Legandr y=0.14234 f(x)=0.14234 0.000000348
Lager y=0.14234 f(x)=0.14234 0.000000348
Magor 0.00001
x= 4.000
Lagrang y=0.14286 f(x)=0.14286 0.000000000
Nuton forwardy=0.14286 f(x)=0.14286 0.000000000
Nuton back y=0.14286 f(x)=0.14286 0.000000000
Spline y=0.14286 f(x)=0.14286 0.000000000
Chebuw y=0.14286 f(x)=0.14286 0.000000000
Ermit y=0.14286 f(x)=0.14286 0.000000000
Legandr y=0.14286 f(x)=0.14286 0.000000000
Lager y=0.14286 f(x)=0.14286 0.000000000
Magor 0.00000
x= 4.100
Lagrang y=0.14336 f(x)=0.14336 0.000000133
Nuton forwardy=0.14336 f(x)=0.14336 0.000000133
Nuton back y=0.14336 f(x)=0.14336 0.000000133
Spline y=0.14336 f(x)=0.14335 0.000006142
Chebuw y=0.14336 f(x)=0.14336 0.000000133
Ermit y=0.14336 f(x)=0.14336 0.000000133
Legandr y=0.14336 f(x)=0.14336 0.000000133
Lager y=0.14336 f(x)=0.14336 0.000000133
Magor 0.00000
x= 4.200
Lagrang y=0.14384 f(x)=0.14384 0.000000147
Nuton forwardy=0.14384 f(x)=0.14384 0.000000147
Nuton back y=0.14384 f(x)=0.14384 0.000000147
Spline y=0.14384 f(x)=0.14383 0.000008021
Chebuw y=0.14384 f(x)=0.14384 0.000000147
Ermit y=0.14384 f(x)=0.14384 0.000000147
Legandr y=0.14384 f(x)=0.14384 0.000000147
Lager y=0.14384 f(x)=0.14384 0.000000147
Magor 0.00000
x= 4.300
Lagrang y=0.14430 f(x)=0.14430 0.000000105
Nuton forwardy=0.14430 f(x)=0.14430 0.000000105
Nuton back y=0.14430 f(x)=0.14430 0.000000105
Spline y=0.14430 f(x)=0.14429 0.000006877
Chebuw y=0.14430 f(x)=0.14430 0.000000105
Ermit y=0.14430 f(x)=0.14430 0.000000105
Legandr y=0.14430 f(x)=0.14430 0.000000105
Lager y=0.14430 f(x)=0.14430 0.000000105
Magor 0.00000
x= 4.400
Lagrang y=0.14474 f(x)=0.14474 0.000000048
Nuton forwardy=0.14474 f(x)=0.14474 0.000000048
Nuton back y=0.14474 f(x)=0.14474 0.000000048
Spline y=0.14474 f(x)=0.14473 0.000003852
Chebuw y=0.14474 f(x)=0.14474 0.000000048
Ermit y=0.14474 f(x)=0.14474 0.000000048
Legandr y=0.14474 f(x)=0.14474 0.000000048
Lager y=0.14474 f(x)=0.14474 0.000000048
Magor 0.00000
x= 4.500
Lagrang y=0.14516 f(x)=0.14516 0.000000000
Nuton forwardy=0.14516 f(x)=0.14516 0.000000000
Nuton back y=0.14516 f(x)=0.14516 0.000000000
Spline y=0.14516 f(x)=0.14516 0.000000000
Chebuw y=0.14516 f(x)=0.14516 0.000000000
Ermit y=0.14516 f(x)=0.14516 0.000000000
Legandr y=0.14516 f(x)=0.14516 0.000000000
Lager y=0.14516 f(x)=0.14516 0.000000000
Magor 0.00000
x= 4.600
Lagrang y=0.14557 f(x)=0.14557 0.000000030
Nuton forwardy=0.14557 f(x)=0.14557 0.000000030
Nuton back y=0.14557 f(x)=0.14557 0.000000030
Spline y=0.14557 f(x)=0.14557 0.000002123
Chebuw y=0.14557 f(x)=0.14557 0.000000030
Ermit y=0.14557 f(x)=0.14557 0.000000030
Legandr y=0.14557 f(x)=0.14557 0.000000030
Lager y=0.14557 f(x)=0.14557 0.000000030
Magor 0.00000
x= 4.700
Lagrang y=0.14596 f(x)=0.14596 0.000000040
Nuton forwardy=0.14596 f(x)=0.14596 0.000000040
Nuton back y=0.14596 f(x)=0.14596 0.000000040
Spline y=0.14596 f(x)=0.14596 0.000001617
Chebuw y=0.14596 f(x)=0.14596 0.000000040
Ermit y=0.14596 f(x)=0.14596 0.000000040
Legandr y=0.14596 f(x)=0.14596 0.000000040
Lager y=0.14596 f(x)=0.14596 0.000000040
Magor 0.00000
x= 4.800
Lagrang y=0.14634 f(x)=0.14634 0.000000035
Nuton forwardy=0.14634 f(x)=0.14634 0.000000035
Nuton back y=0.14634 f(x)=0.14634 0.000000035
Spline y=0.14634 f(x)=0.14634 0.000000019
Chebuw y=0.14634 f(x)=0.14634 0.000000035
Ermit y=0.14634 f(x)=0.14634 0.000000035
Legandr y=0.14634 f(x)=0.14634 0.000000035
Lager y=0.14634 f(x)=0.14634 0.000000035
Magor 0.00000
x= 4.900
Lagrang y=0.14671 f(x)=0.14671 0.000000019
Nuton forwardy=0.14671 f(x)=0.14671 0.000000019
Nuton back y=0.14671 f(x)=0.14671 0.000000019
Spline y=0.14671 f(x)=0.14671 0.000001071
Chebuw y=0.14671 f(x)=0.14671 0.000000019
Ermit y=0.14671 f(x)=0.14671 0.000000019
Legandr y=0.14671 f(x)=0.14671 0.000000019
Lager y=0.14671 f(x)=0.14671 0.000000019
Magor 0.00000
x= 5.000
Lagrang y=0.14706 f(x)=0.14706 0.000000000
Nuton forwardy=0.14706 f(x)=0.14706 0.000000000
Nuton back y=0.14706 f(x)=0.14706 0.000000000
Spline y=0.14706 f(x)=0.14706 0.000000000
Chebuw y=0.14706 f(x)=0.14706 0.000000000
Ermit y=0.14706 f(x)=0.14706 0.000000000
Legandr y=0.14706 f(x)=0.14706 0.000000000
Lager y=0.14706 f(x)=0.14706 0.000000000
Magor 0.00000
x= 5.100
Lagrang y=0.14740 f(x)=0.14740 0.000000016
Nuton forwardy=0.14740 f(x)=0.14740 0.000000016
Nuton back y=0.14740 f(x)=0.14740 0.000000016
Spline y=0.14740 f(x)=0.14740 0.000001454
Chebuw y=0.14740 f(x)=0.14740 0.000000016
Ermit y=0.14740 f(x)=0.14740 0.000000016
Legandr y=0.14740 f(x)=0.14740 0.000000016
Lager y=0.14740 f(x)=0.14740 0.000000016
Magor 0.00000
x= 5.200
Lagrang y=0.14773 f(x)=0.14773 0.000000025
Nuton forwardy=0.14773 f(x)=0.14773 0.000000025
Nuton back y=0.14773 f(x)=0.14773 0.000000025
Spline y=0.14773 f(x)=0.14773 0.000001083
Chebuw y=0.14773 f(x)=0.14773 0.000000025
Ermit y=0.14773 f(x)=0.14773 0.000000025
Legandr y=0.14773 f(x)=0.14773 0.000000025
Lager y=0.14773 f(x)=0.14773 0.000000025
Magor 0.00000
x= 5.300
Lagrang y=0.14804 f(x)=0.14804 0.000000024
Nuton forwardy=0.14804 f(x)=0.14804 0.000000024
Nuton back y=0.14804 f(x)=0.14804 0.000000024
Spline y=0.14804 f(x)=0.14804 0.000000034
Chebuw y=0.14804 f(x)=0.14804 0.000000024
Ermit y=0.14804 f(x)=0.14804 0.000000024
Legandr y=0.14804 f(x)=0.14804 0.000000024
Lager y=0.14804 f(x)=0.14804 0.000000024
Magor 0.00000
x= 5.400
Lagrang y=0.14835 f(x)=0.14835 0.000000015
Nuton forwardy=0.14835 f(x)=0.14835 0.000000015
Nuton back y=0.14835 f(x)=0.14835 0.000000015
Spline y=0.14835 f(x)=0.14835 0.000000779
Chebuw y=0.14835 f(x)=0.14835 0.000000015
Ermit y=0.14835 f(x)=0.14835 0.000000015
Legandr y=0.14835 f(x)=0.14835 0.000000015
Lager y=0.14835 f(x)=0.14835 0.000000015
Magor 0.00000
x= 5.500
Lagrang y=0.14865 f(x)=0.14865 0.000000000
Nuton forwardy=0.14865 f(x)=0.14865 0.000000000
Nuton back y=0.14865 f(x)=0.14865 0.000000000
Spline y=0.14865 f(x)=0.14865 0.000000000
Chebuw y=0.14865 f(x)=0.14865 0.000000000
Ermit y=0.14865 f(x)=0.14865 0.000000000
Legandr y=0.14865 f(x)=0.14865 0.000000000
Lager y=0.14865 f(x)=0.14865 0.000000000
Magor 0.00000
x= 5.600
Lagrang y=0.14894 f(x)=0.14894 0.000000017
Nuton forwardy=0.14894 f(x)=0.14894 0.000000017
Nuton back y=0.14894 f(x)=0.14894 0.000000017
Spline y=0.14894 f(x)=0.14894 0.000001028
Chebuw y=0.14894 f(x)=0.14894 0.000000017
Ermit y=0.14894 f(x)=0.14894 0.000000017
Legandr y=0.14894 f(x)=0.14894 0.000000017
Lager y=0.14894 f(x)=0.14894 0.000000017
Magor 0.00000
x= 5.700
Lagrang y=0.14921 f(x)=0.14921 0.000000030
Nuton forwardy=0.14921 f(x)=0.14921 0.000000030
Nuton back y=0.14921 f(x)=0.14921 0.000000030
Spline y=0.14921 f(x)=0.14922 0.000000751
Chebuw y=0.14921 f(x)=0.14921 0.000000030
Ermit y=0.14921 f(x)=0.14921 0.000000030
Legandr y=0.14921 f(x)=0.14921 0.000000030
Lager y=0.14921 f(x)=0.14921 0.000000030
Magor 0.00000
x= 5.800
Lagrang y=0.14948 f(x)=0.14948 0.000000034
Nuton forwardy=0.14948 f(x)=0.14948 0.000000034
Nuton back y=0.14948 f(x)=0.14948 0.000000034
Spline y=0.14948 f(x)=0.14948 0.000000054
Chebuw y=0.14948 f(x)=0.14948 0.000000034
Ermit y=0.14948 f(x)=0.14948 0.000000034
Legandr y=0.14948 f(x)=0.14948 0.000000034
Lager y=0.14948 f(x)=0.14948 0.000000034
Magor 0.00000
x= 5.900
Lagrang y=0.14975 f(x)=0.14975 0.000000024
Nuton forwardy=0.14975 f(x)=0.14975 0.000000024
Nuton back y=0.14975 f(x)=0.14975 0.000000024
Spline y=0.14975 f(x)=0.14975 0.000000580
Chebuw y=0.14975 f(x)=0.14975 0.000000024
Ermit y=0.14975 f(x)=0.14975 0.000000024
Legandr y=0.14975 f(x)=0.14975 0.000000024
Lager y=0.14975 f(x)=0.14975 0.000000024
Magor 0.00000
x= 6.000
Lagrang y=0.15000 f(x)=0.15000 0.000000000
Nuton forwardy=0.15000 f(x)=0.15000 0.000000000
Nuton back y=0.15000 f(x)=0.15000 0.000000000
Spline y=0.15000 f(x)=0.15000 0.000000000
Chebuw y=0.15000 f(x)=0.15000 0.000000000
Ermit y=0.15000 f(x)=0.15000 0.000000000
Legandr y=0.15000 f(x)=0.15000 0.000000000
Lager y=0.15000 f(x)=0.15000 0.000000000
Magor 0.00000
x= 6.100
Lagrang y=0.15025 f(x)=0.15025 0.000000036
Nuton forwardy=0.15025 f(x)=0.15025 0.000000036
Nuton back y=0.15025 f(x)=0.15025 0.000000036
Spline y=0.15025 f(x)=0.15025 0.000001338
Chebuw y=0.15025 f(x)=0.15025 0.000000036
Ermit y=0.15025 f(x)=0.15025 0.000000036
Legandr y=0.15025 f(x)=0.15025 0.000000036
Lager y=0.15025 f(x)=0.15025 0.000000036
Magor 0.00000
x= 6.200
Lagrang y=0.15049 f(x)=0.15049 0.000000076
Nuton forwardy=0.15049 f(x)=0.15049 0.000000076
Nuton back y=0.15049 f(x)=0.15049 0.000000076
Spline y=0.15049 f(x)=0.15049 0.000002307
Chebuw y=0.15049 f(x)=0.15049 0.000000076
Ermit y=0.15049 f(x)=0.15049 0.000000076
Legandr y=0.15049 f(x)=0.15049 0.000000076
Lager y=0.15049 f(x)=0.15049 0.000000076
Magor 0.00000
x= 6.300
Lagrang y=0.15072 f(x)=0.15072 0.000000102
Nuton forwardy=0.15072 f(x)=0.15072 0.000000102
Nuton back y=0.15072 f(x)=0.15072 0.000000102
Spline y=0.15072 f(x)=0.15072 0.000002598
Chebuw y=0.15072 f(x)=0.15072 0.000000102
Ermit y=0.15072 f(x)=0.15072 0.000000102
Legandr y=0.15072 f(x)=0.15072 0.000000102
Lager y=0.15072 f(x)=0.15072 0.000000102
Magor 0.00000
x= 6.400
Lagrang y=0.15094 f(x)=0.15094 0.000000090
Nuton forwardy=0.15094 f(x)=0.15094 0.000000090
Nuton back y=0.15094 f(x)=0.15094 0.000000090
Spline y=0.15094 f(x)=0.15095 0.000001921
Chebuw y=0.15094 f(x)=0.15094 0.000000090
Ermit y=0.15094 f(x)=0.15094 0.000000090
Legandr y=0.15094 f(x)=0.15094 0.000000090
Lager y=0.15094 f(x)=0.15094 0.000000090
Magor 0.00000
x= 6.500
Lagrang y=0.15116 f(x)=0.15116 0.000000000
Nuton forwardy=0.15116 f(x)=0.15116 0.000000000
Nuton back y=0.15116 f(x)=0.15116 0.000000000
Spline y=0.15116 f(x)=0.15116 0.000000000
Chebuw y=0.15116 f(x)=0.15116 0.000000000
Ermit y=0.15116 f(x)=0.15116 0.000000000
Legandr y=0.15116 f(x)=0.15116 0.000000000
Lager y=0.15116 f(x)=0.15116 0.000000000
Magor 0.00000
x= 6.600
Lagrang y=0.15138 f(x)=0.15138 0.000000219
Nuton forwardy=0.15138 f(x)=0.15138 0.000000219
Nuton back y=0.15138 f(x)=0.15138 0.000000219
Spline y=0.15138 f(x)=36.91128 36.759905814
Chebuw y=0.15138 f(x)=0.15138 0.000000219
Ermit y=0.15138 f(x)=0.15138 0.000000219
Legandr y=0.15138 f(x)=0.15138 0.000000219
Lager y=0.15138 f(x)=0.15138 0.000000219
Magor 0.00001
x= 6.700
Lagrang y=0.15158 f(x)=0.15158 0.000000636
Nuton forwardy=0.15158 f(x)=0.15158 0.000000636
Nuton back y=0.15158 f(x)=0.15158 0.000000636
Spline y=0.15158 f(x)=48.93377 48.782184234
Chebuw y=0.15158 f(x)=0.15158 0.000000636
Ermit y=0.15158 f(x)=0.15158 0.000000636
Legandr y=0.15158 f(x)=0.15158 0.000000636
Lager y=0.15158 f(x)=0.15158 0.000000636
Magor 0.00002
Висновок:
За даними отриманими при виконанні роботи можна стверджувати, що були отримані однакові поліноми для всіх методів крім сплайна, записані у різних формах.
Інтерполяційний поліном для розглянутої функції дає точніші значення, ніж інтерполяція сплайнами.
Текст програми:
{$N+\}
uses crt;
const n=5;
start : real = 4;
step : real = 0.5;
type arr = array[0..10] of double;
ar=array[0..25,0..25] of double;
var ff : text;
xo,yo,z,xoo : double;
x,y,x1,y1,t,h,p,l,m : arr;
nach,magor,max : real ;
a : ar;
coef : ar;
i,splin : integer;
function f(x : double) : double;
begin
f :=x/(2*(3*x+2));
end;
function d6(x:real):real;
begin
d6:=(-5598720*(6*x+4)+33592320*x)/(exp(7*ln(6*x+4)));
end;
procedure init(var x,y : arr);
var i : integer;
begin
for i := 0 to n do
begin
x[i] := start + step*i;
y[i] := f(x[i]);
end;
end;
procedure init1(var x1,y1 : arr);
var i : integer;
begin
for i := 0 to n do
begin
x1[i] :=0.2*(x[i]-1)-1;
y1[i] := y[i];
end;
end;
procedure Lagrange( x,y:arr; xo:double; var res:double);
var i,j :integer;
b : double;
begin
res:=0;
for i:=0 to n do
begin
b:=1;
for j:=0 to n do
if i<>j then
b:=b*(xo-x[j])/(x[i]-x[j]);
res:=res+y[i]*b;
end;
end;
Procedure Newton(x, y: arr; xo:double; var res: double);
var
i, j:byte ;
p, s: double;
f: array [ 0..5, 0..5] of double;
begin
for i:=0 to n do f[i,0]:=y[i];
for i:=1 to n do
for j:=0 to n-i do
f[j,i]:=(f[j,i-1]-f[j+1,i-1])/(x[j]-x[i+j]);
s:=y[0];
p:=1;
for i:=1 to n do
begin
p:=p*(xo-x[i-1]);
s:=s+p*f[0,i];
end;
yo:=s;
end;
Procedure Newtonback(x, y: arr; xo:double; var yo: double);
var
i: byte;
perX, perY: arr;
begin
for i:=0 to n do
begin
perX[i]:=x[n-i];
perY[i]:=y[n-i];
end;
Newton(perX,perY,xo,yo);
end;
procedure MetodGausa(a:ar; n:integer; var x:arr);
var l,k,z,i,j:integer;
c,sum:double;
begin
for k:=0 to n-1 do
begin
l:=k;
for i:=k+1 to n do
if (abs(a[i,k])>abs(a[l,k])) then l:=k;
for z:=0 to n+1 do
begin
c:=a[l,z];
a[l,z]:=a[k,z];
a[k,z]:=c;
end;
for i:=k+1 to n do
begin
c:=a[i,k];
for j:=0 to n+1 do
a[i,j]:=-(c/a[k,k])*a[k,j]+a[i,j];
end;
end;
for i:=n-1 downto 0 do
for j:=n to n do
begin
sum:=0;
for k:=i+1 to n-1 do
sum:=sum+a[i,k]*a[k,j];
a[i,j]:=(a[i,j]-sum)/a [i,i];
end;
for i:=0 to n-1 do
x[i]:=a[i,n];
end;
procedure Chebuw(x1,y1:arr; var t:arr);
var m:ar;
i,j,k:integer;
begin
for i:=0 to n do
begin
m[i,0]:=1;
m[i,1]:=x1[i];
m[i,2]:=2*x1[i]*x1[i]-1;
m[i,3]:=4*x1[i]*x1[i]*x1[i]-3*x1[i];
m[i,4]:=8*x1[i]*x1[i]*x1[i]*x1[i]-8*x1[i]*x1[i]-1;
m[i,5]:=16*x1[i]*x1[i]*x1[i]*x1[i]*x1[i]-20*x1[i]*x1[i]*x1[i]+x1[i];
m[i,6]:=y1[i];
end;
MetodGausa(m,6,t);
writeln(ff,'Chebuw: ',t[0]:0:2,'+',t[1]:0:2,'*T1+',t[2]:0:2,'*T2+',t[3]:0:2,'*T3+',t[4]:0:2,'*T4+',t[5]:0:2,'*T5');
end;
procedure Ermit(x1,y1:arr; var h:arr);
var m:ar;
i,j,k:integer;
begin
for i:=0 to n do
begin
m[i,0]:=1;
m[i,1]:=x1[i];
m[i,2]:=2*x1[i]*x1[i]-2;
m[i,3]:=4*x1[i]*x1[i]*x1[i]-8*x1[i];
m[i,4]:=8*x1[i]*x1[i]*x1[i]*x1[i]-28*x1[i]*x1[i]+12;
m[i,5]:=16*x1[i]*x1[i]*x1[i]*x1[i]*x1[i]-80*x1[i]*x1[i]*x1[i]+88*x1[i];
m[i,6]:=y1[i];
end;
MetodGausa(m,6,h);
writeln(ff,'Ermit: ',h[0]:0:2,'+',h[1]:0:2,'*H1+',h[2]:0:2,'*H2+',h[3]:0:2,'*H3+',h[4]:0:2,'*H4+',h[5]:0:2,'*H5');
end;
procedure Legandr(x1,y1:arr; var p:arr);
var m:ar;
i,j,k:integer;
begin
for i:=0 to n do
begin
m[i,0]:=1;
m[i,1]:=x1[i];
m[i,2]:=1.5*x1[i]*x1[i]-0.5;
m[i,3]:=2.5*x1[i]*x1[i]*x1[i]-1.5*x1[i];
m[i,4]:=35*x1[i]*x1[i]*x1[i]*x1[i]/8-15*x1[i]*x1[i]/4+3/8;
m[i,5]:=63*x1[i]*x1[i]*x1[i]*x1[i]*x1[i]/8-35*x1[i]*x1[i]*x1[i]/4+75*x1[i]/40;
m[i,6]:=y1[i];
end;
MetodGausa(m,6,p);
writeln(ff,'Legandr: ',p[0]:0:2,'+',p[1]:0:2,'*P1+',p[2]:0:2,'*P2+',p[3]:0:2,'*P3+',p[4]:0:2,'*P4+',p[5]:0:2,'*P5');
end;
procedure Lager(x1,y1:arr; var l:arr);
var m:ar;
i,j,k:integer;
begin
for i:=0 to n do
begin
m[i,0]:=1;
m[i,1]:=1-x1[i];
m[i,2]:=-0.5*x1[i]*x1[i]-2*x1[i]+1;
m[i,3]:=-x1[i]*x1[i]*x1[i]/6+1.5*x1[i]*x1[i]-3*x1[i]+1;
m[i,4]:=x1[i]*x1[i]*x1[i]*x1[i]/24-2*x1[i]*x1[i]*x1[i]/3+3*x1[i]*x1[i]-4*x1[i]+1;
m[i,5]:=-x1[i]*x1[i]*x1[i]*x1[i]*x1[i]/120+25*x1[i]*x1[i]*x1[i]*x1[i]/120-5*x1[i]*x1[i]*x1[i]/3
+5*x1[i]*x1[i]-5*x1[i]+1;
m[i,6]:=y1[i];
end;
MetodGausa(m,6,l);
writeln(ff,'Lager: ',l[0]:0:2,'+',l[1]:0:2,'*L1+',l[2]:0:2,'*L2+',l[3]:0:2,'*L3+',l[4]:0:2,'*L4+',l[5]:0:2,'*L5');
end;
BEGIN
init(x,y);
init1(x1,y1);
assign(ff,'output.txt');
rewrite(ff);
clrscr;
m[0]:=(4*y[1]-y[2]-3*y[0])/(2*step);
m[n]:=(3*y[n]+y[n-2]-4*y[n-1])/(2*step);
for i:=1 to n-1 do m[i]:=(y[i+1]-y[i-1])/(2*step);
Chebuw(x1,y1,t);
Ermit(x1,y1,h);
Legandr(x1,y1,p);
Lager(x,y1,l);
splin:=0;
xo:=x[0]-0.2;
repeat
magor:=1/120; max:=0;
for i:=0 to n do magor:=magor*(xo-x[i]);
for i:=400 to 650 do
if abs(d6(i/100))>max then max:=abs(d6(i/100));
magor:=magor*max;
writeln(ff,'x=',xo:7:3);
Lagrange(x,y,xo,yo);
writeln(ff, 'Lagrang ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
Newton(x,y,xo,yo);
writeln(ff, 'Nuton forward','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
Newtonback(x,y,xo,yo);
writeln(ff, 'Nuton back ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
yo:=( sqr(x[splin+1]-xo) * (2*(xo-x[splin])+step) * y[splin] )/(step*step*step);
yo:=yo+( sqr(xo-x[splin]) * (2*(x[splin+1]-xo)+step) * y[splin+1] )/(step*step*step);
yo:=yo+(sqr(x[splin+1]-xo) * (xo-x[splin]) * m[splin])/(sqr(step));
yo:=yo+(sqr(x[splin]-xo) * (xo-x[splin+1]) * m[splin+1])/(sqr(step));
writeln(ff, 'Spline ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
xoo:=0.2*(xo-1)-1;
yo:=t[0]+t[1]*xoo+t[2]*(2*xoo*xoo-1)+t[3]*(4*xoo*xoo*xoo-3*xoo)+t[4]*(8*xoo*xoo*xoo*xoo-8*xoo*xoo-1)
+t[5]*(16*xoo*xoo*xoo*xoo*xoo-20*xoo*xoo*xoo+xoo);
writeln(ff, 'Chebuw ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
yo:=h[0]+h[1]*xoo+h[2]*(2*xoo*xoo-2)+h[3]*(4*xoo*xoo*xoo-8*xoo)+h[4]*(8*xoo*xoo*xoo*xoo-28*xoo*xoo+12)
+h[5]*(16*xoo*xoo*xoo*xoo*xoo-80*xoo*xoo*xoo+88*xoo);
writeln(ff, 'Ermit ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
yo:=p[0]+p[1]*xoo+p[2]*(1.5*xoo*xoo-0.5)+p[3]*(2.5*xoo*xoo*xoo-1.5*xoo)+p[4]*(35*xoo*xoo*xoo*xoo/8-15*xoo*xoo/4+3/8)
+p[5]*(63*xoo*xoo*xoo*xoo*xoo/8-35*xoo*xoo*xoo/4+75*xoo/40);
writeln(ff, 'Legandr ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
yo:=l[0]+l[1]*(1-xo)+l[2]*(-0.5*xo*xo-2*xo+1)+l[3]*(-xo*xo*xo/6+1.5*xo*xo-3*xo+1)+l[4]*(xo*xo*xo*xo/24
-2*xo*xo*xo/3+3*xo*xo-4*xo+1)+l[5]*(-xo*xo*xo*xo*xo/120+25*xo*xo*xo*xo/120-5*xo*xo*xo/3+5*xo*xo-5*xo+1);
writeln(ff, 'Lager ','y=',f(xo):3:5,' ','f(x)=',yo:3:5,' ', abs(f(xo)-yo):10:9);
writeln(ff,'Magor ',abs(magor):3:5);
writeln(ff,'');
xo:=xo+0.1;
if (x[splin]+step<=xo) then splin:=splin+1;
until xo>=x[n]+0.201;
close(ff);
readln;
END.