Galyorkin usulining ishchi algoritmi uchun blok-sxema
algoritmning dastur matni:
Program Galerkin;
Const
q=2;
Type
Masqarray[1..q,1..q] of real;
Mas1qarray[1..q] of real;
Var
fx,lu0,lu1,lu2,a,b,z,x,h:Real;
m:Mas;
C,M1:Mas1;
i:Integer;
Function F(X:Real; K:Integer):Real;
var
u0,u1,u2,u3:real;
begin
lu0:=Sqr(x)-2;
u1:=Sqr(x)-x;
lu1:=sqr(x)*sqr(x)*x-x*x*x*x-4*x+4;
lu2:=Sqr(x)*Sqr(x)*Sqr(x)-sqr(x)*sqr(x)*x-6*x*x+10*x-2;
fx:=12*x*x-8*x*x*x+sqr(x)*sqr(x)*sqr(x)*x;
case K of
1:F:=lu1*u1;
2:F:=lu2*u1;
3:F:=lu1*u1*x;
4:F:=lu2*u1*x;
5:F:=(fx-lu0)*u1;
6:F:=(fx-lu0)*u1*x;
end;
end;
function Integ(a,b:Real; k:Integer):Real;
var
y,h1:Real;
i:Integer;
begin
h1:=(b-a)/20;
y:=(f(a,k)+f(b,k))/2;
write(y:12:3);
for i:=1 to 19 do y:=y+f(a+i*h1,k);
y:=y*h1;
Integ:=y;
writeln(y:12:3);
end;
Procedure Gauss(A:Mas; B:Mas1; Var x:Mas1; N:Integer);
var
k,m,l:Integer;
s:Real;
begin
for k:=1 to n-1 do
for m:=k+1 to n do
begin
for l:=k+1 to n do
A[m,l]:=A[m,l]-A[m,k]*A[k,l]/A[k,k];
B[m]:=B[m]-A[m,k]*B[k]/A[k,k];
end;
x[n]:=B[n]/A[n,n];
for k:=n-1 downto 1 do
begin
s:=0;
for i:=k+1 to n do s:=s+A[k,i]*X[i];
X[k]:=(B[k]-s)/A[k,k];
end;
end;
begin
Write('a,bq');Readln(a,b);
M[1,1]:=Integ(a,b,1);
M[1,2]:=Integ(a,b,2);
M[2,1]:=Integ(a,b,3);
M[2,2]:=Integ(a,b,4);
M1[1]:=Integ(a,b,5);
M1[2]:=Integ(a,b,6);
Gauss(M,M1,C,q);
For i:=1 to q do writeln(c[i]:12:4);
For I:=0 to 10 do
begin
h:=(b-a)/10;
x:=a+i*h;
z:=x+c[1]*(x*x-x)+c[2]*(x*x*x-x*x);
Writeln('x=',x:2:2,' z=',z:2:8,' a=', sqr(x)*sqr(x):2:8,' ', abs(z-sqr(x)*sqr(x)):2:8);
end;
end.
Dostları ilə paylaş: |