function run_kut_fkt; { FORWARD deklarierte Funktion } begin end; function derivation; { } { Allgemeines Beispiel : Lineare DGL zweiter Ordnung } { } { y'' + F(x)y' + G(x)y + H(x) = 0 } { } { Durch die Substitution : dy/dx = y' = z erhaelt man das DGL-System } { } { dy/dx = z } { dz/dx = - [ F(x)z + G(x)y + H(x) ] } { } { Spezielles Beispiel : F(x) = 1/x G(x) = 1/(x*x) } { } { H(x) = -(9x + (x*x*x + 1)/(x*x)) } { } { Man erhaelt : dy/dx = z } { } { dz/dx = -[ z/x + y/(x*x) - 9x - (x*x*x + 1)/(x*x) ] } { } { Es ist : x = coeff[0] , y = coeff[1] , z = coeff[2] } { } begin case index of 1 : derivation:=coeff[2]; { dy/dx = z } 2 : derivation:=-(coeff[2]/coeff[0]+coeff[1]/sqr(coeff[0])-9.0*coeff[0]-(coeff[0]*sqr(coeff[0])+1.0)/sqr(coeff[0])); { dz/dx = .... } end; end; function anal_fkt(x:real) : real; { Analytische Loesung } begin anal_fkt:=x*sqr(x)+1; end; var coeff : CoeffType_TL; h : real; i : byte; begin clrscr; writeln('Loesung einer homogenen DGL 2. Ordnung'); writeln; coeff[0]:=1.0; { Anfangsbedingung : x = 1.0 } coeff[1]:=2.0; { Anfangsbedingung : y = 2.0 } coeff[2]:=3.0; { Anfangsbedingung : z = y'= 3.0 } h:=1.0; { Schrittweite : h = 1.0 } writeln(' x y y analytisch'); writeln; writeln(coeff[0]:7:4,coeff[1]:12:3,anal_fkt(coeff[0]):12:3); repeat lin_dgl_sys(coeff,h,2); { Loesung des linearen Dgl-systems } { mit Schrittweitensteuerung } coeff[0]:=coeff[0]+h; { x = x + h } writeln(coeff[0]:7:4,coeff[1]:12:3,anal_fkt(coeff[0]):12:3); until coeff[0]>=15.0; end.