Методы решения дифференциальных уравнений

контрольная работа

2. Расчетная часть

program s;

var x: real;

procedure Rung (x: real);

Var

m,t,d,h,y,k1,k2,k3,k4: real;

i: integer;

Function f (x,y: real): real;

begin

f: =2*x*x+2*y;

end;

Begin

Writeln (METOD RUNGE-KUTTA!! );

Writeln (Poluchenoe znachenie );

Writeln ( dy/dx=2* (x^2+y) );

m: =0; d: =1; t: =1; h: =0.1;

Writeln (--------------------);

Writeln (| i | x | y |);

Writeln (--------------------);

x: =m; y: =d; i: =1;

Writeln (|, i: 2, |, x: 5: 2, |, y: 7: 2, |);

repeat

x: =x+h;

i: =i+1;

k1: =f (x,y);

k2: =f (x+h/2,y+h*k1/2);

k3: =f (x+h/2,y+h*k2/2);

k4: =f (x+h,y+h*k3);

y: =y+h* (k1+2*k2+2*k3+k4);

Writeln (|, i: 2, |, x: 5: 2, |, y: 7: 2, |);

until x>t;

Writeln (--------------------);

Readln;

End;

procedure Gold (x: real);

var

y: real;

Function f (x: real): real;

Begin

f: = (2*sqr (x)) +2*y

End;

Var

e, a, b, c, i,x1,x2: real;

n: Integer;

begin

Writeln (METOD ZOLOTOGO SECHENIA!! );

i: =1.618;

e: =0.0001;

a: =0;

b: =1;

Repeat

x1: =b- (b-a) /i;

x2: =a+ (b-a) /i;

If f (x1) >= f (x2) Then a: =x1

Else b: = x2;

Until abs (b - a) < e;

x: = (a + b) / 2;

writeLn (kopen min =,x: 10: 8);

Repeat

x1: =b- (b-a) /i;

x2: =a+ (b-a) /i;

If f (x1) <= f (x2) Then b: =x1

Else a: = x2;

Until abs (b - a) < e;

x: = (a + b) / 2;

writeLn (kopen max =,x: 10: 8);

readln;

end;

procedure kvad (int: real);

function f (x,x1: real): real;

begin

f: = ( (x+x1) /2) * (x1-x);

end;

var

a,b,x,x1,l,n: real;

i,h: integer;

begin

Writeln (METOD PRYMOUGOLNIKOV!! );

write (nachalo a= ); readln (a);

write (konec b= ); readln (b);

write (kolichestvo razbieniy h= ); readln (h);

x: =a;

x1: =a;

for i: =0 to h-1 do begin

n: = (b-a) /h;

x: =a+i*n;

x1: =x1+n;

l: =f (x,x1);

int: =int+l;

end;

writeln (integral raven =, int: 10: 4);

readln;

end;

begin

Rung (x);

Gold (x);

kvad (x);

readln;

end.

Рисунок 1-полученные значения

2. Составим Блок-схему алгоритма программы

Рисунок 2 - Блок-схема алгоритма

Делись добром ;)