Метод прогонки
Листинг программы для решения краевой задачи для дифференциального уравнения второго порядка методом прогонки.
program ejler10; uses Crt; Type VEC = array [0..15] of real; var Y:VEC; x:array[0..20]of real; Yy:array [0..15,0..4] of real; a,b,h,E,delta: real; i,j,N,k:integer; function F(x:real; var Yh:real):real; begin F:=2*sqrt(x)+2*Y[i]; end; BEGIN ClrScr; write('Vvedite tochnost vishisleniy :E='); readln(E); write('Vvedite nachalniy shag :h='); readln(h); write('Vvedite cherez probel konchi otrezkaintegrirovaniya [a,b] :'); read(a,b); N:=Round((b-a)/h); write('Vvedite nachalnie ysloviya :Y[0]='); readln(Y[0]); x[0]:=a; for i:=0 to n do begin x[i]:=a+i*h; k:=0; Yy[1,0]:=y[0]+h*F(x[0],y[0]); for j:=2 to n do begin if i=2 then begin repeat k:=k+1; Yy[1,k]:=y[0]+(h/2)*(F(x[0],y[0])+F(x[1],Yy[1,k-1])); until Abs(Yy[1,k]-Yy[1,k-1])<=e; y[1]:=Yy[1,k]; end; end; k:=0; Yy[i,0]:=y[i-1]+h*f(x[i],y[i-1]); Yy[i,0]:=f(x[i],Yy[i,0]); repeat k:=k+1; Yy[i,k]:=y[i-1]+(h/2)*(f(x[i-1],y[i-1])+Yy[i,k-1]); until(Abs(Yy[i,k]-Yy[i,k-1])<=e)or (k=4); if Abs(Yy[i,4]-Yy[i,3])>0 then h:=h/2 else y[i]:=Yy[i,k]; end; for i:=0 to n do writeln('y',i,'=',y[i]:8:6,';'); while not keypressed do; END.