Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
interface
uses
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Memo1: TMemo;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Button2: TButton;
Memo2: TMemo;
Memo3: TMemo;
Memo4: TMemo;
U: TLabel;
Y: TLabel;
X: TLabel;
L: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
const
n=3;
var
A:array[1..n,1..n] of double;
X:array[1..n] of double;
B:array[1..n] of double;
D:array[1..n] of double;
L:array[1..n,1..n] of double;
U:array[1..n,1..n] of double;
Y:array[1..n] of double;
som:double;
Form1: TForm1;
implementation
{$R *.dfm}
var
i,j,k:integer;
pivot,val: double;
begin
A[1][1]:= Strtofloat(Edit1.Text);
A[1][2]:= Strtofloat(Edit2.Text);
A[1][3]:= Strtofloat(Edit3.Text);
A[2][1]:= Strtofloat(Edit4.Text);
A[2][2]:= Strtofloat(Edit5.Text);
A[2][3]:= Strtofloat(Edit6.Text);
A[3][1]:= Strtofloat(Edit7.Text);
A[3][2]:= Strtofloat(Edit8.Text);
A[3][3]:= Strtofloat(Edit9.Text);
B[1]:= Strtofloat(Edit10.Text);
B[2]:= Strtofloat(Edit11.Text);
B[3]:= Strtofloat(Edit12.Text);
D[1]:= Strtofloat(Edit10.Text);
D[2]:= Strtofloat(Edit11.Text);
D[3]:= Strtofloat(Edit12.Text);
Memo1.Clear;
Memo2.Clear;
Memo3.Clear;
Memo4.Clear;
// Calcul de la matrice U
for j := 1 to n do
begin
for i := 1 to n do
begin
U[j][j]:=A[i][j] ;
for k := 1 to i-1 do
begin
end;
end;
// Calcul de la matrice L
for i := j+1 to n do
begin
L[i][j]:=A[i][j] ;
for k := 1 to j-1 do
begin
end;
L[i][j]:=L[i][j]/U[j][j] ;
for k := 1 to n do
begin
L[k][k]:= 1;
end;
end;
end;
for i := 1 to n do
begin
for j := 1 to n do
begin
Memo1.Lines.Add('L['+IntToStr(i)+']['+IntToStr(j)+']='+FloatToStr(L[i][j]));
end;
end;
for i := 1 to n do
begin
for j := 1 to n do
begin
Memo2.Lines.Add('U['+IntToStr(i)+']['+IntToStr(j)+']='+FloatToStr(U[i][j]));
end;
end;
if (L[1][1]<>0)then
begin
Y[1]:=B[1]/L[1][1];
Memo3.Lines.Add('Y[1]='+FloatToStr(Y[1]));
for i:=2 to n do
begin
som:=0;
begin
som:=som+L[i][j]*Y[j];
end;
Y[i]:=(1/L[i][i])*(B[i]-som);
Memo3.Lines.Add('Y['+intToStr(i)+']='+FloatToStr(Y[i]));
end;
end;
// Resolution de l'equation U*x=y
if (U[n][n]<>0)then
begin
X[n]:=Y[n]/U[n][n];
Memo4.Lines.Add('X['+intToStr(n)+']='+FloatToStr(X[n]));
begin
som:=0;
for j:=i+1 to n do
begin
end;
X[i]:=(Y[i]-som)/U[i][i];
Memo4.Lines.Add('X['+IntToStr(i)+']='+FloatToStr(X[i]));
end;
end;
end;
begin
Close;
end;
end.