C:\Si5\Ingmah\symbmalab\DGLn_N4_2.doc, Seie /5 Prof. Dr. R. Kessler, Homepage: hp://www.home.hs-karlsruhe.de/~kero/ Malab5 5.3 symbolisches Lösen von DGLn % Beispiele aus Malab 4.3 Suden Ediion Handbuch Seie 222»» dsolve('dy=+y^2') % find he general soluion ans =an(+c)» % OK Jez mi iniial condiion y()=:» y=dsolve('dy=+y^2','y()=') % add he iniial condiion y = an(+/4*pi)» % les ry an second order differenial equaion wih wo iniial condiions:» y=dsolve('d2y=cos(2*x)-y','dy()=','y()=') ergib y = 2*cos(x)^2-+(-2*cos(x)^2+2)*cos()» y = simple(y) % looks like i can be simplified ergib y = 2*cos(x)^2-+(-2*cos(x)^2+2)*cos()» % Im Tex S. 223 (Suden ediion handbook) seh eine andere Formel:» % -/3*cos(2*x)+4/3*cos(x) % Applying he iniial condiion y() and y()= gives» y=dsolve('d2y-2*dy-3*y=','y()=','y()=') => y =/(exp(-)-exp(3))*exp(-)-/(exp(-)-exp(3))*exp(3*)» y=simple(y) => y =(exp(-)-exp(3*))/(exp(-)-exp(3))» ezplo(y,[-6,2]) ( e x p ( - ) - e x p ( 3 ) ) / ( e x p ( - ) - e x p ( 3 ) ) 5-5 - - 5-6 - 5-4 - 3-2 - 2
C:\Si5\Ingmah\symbmalab\DGLn_N4_2.doc, Seie 2/5 Jez Beispiele Jeweils vorher clear und symbolische Variable deklarieren : clear; =sym('') % symbolic variable, Nr» % Nr : y +2*y +2*y = /( exp()*cos() )» y=dsolve('d2y+2*dy+2*y = /( exp()*cos() )') y=*exp(-)*sin()+log(cos())*exp(-)*cos()+c*exp(-)*sin()+c2*exp(-)*cos() clear; =sym(''), a=sym('a'), b=sym('b') % creaes symbolic variables,,a,b % DGL Nr 2 is y' + a*y = 2*exp(b*x); y() = 2 y=dsolve('dy+a*y = 2*exp(b*)', 'y()=2') % DGL Nr 2 clear; =sym(''), %symbolic variable, % DGL Nr 3: *y''-(+)*y'-2*(-)*y = **, y=dsolve('*d2y-(+)*dy-2*(-)*y = **') y = -/2*^2+C*(exp(-)+3**exp(-))+C2*(-+exp(-3*)+3*exp(-3*)*)*exp(2*) % DGL Nr 4: (*-)*y'+2**y = cos(), y()=; y=dsolve('(*-)*dy + 2**y = cos() ') % Alg. Lös. Nr 4 y=dsolve('(*-)*dy + 2**y = cos() ', 'y()=') % Spez. Lös. Nr 4 y = (sin()-)/(^2-) ezplo(y) ( s i n ( ) - ) / ( 2 - ). 5. 5 -. 5 - - 6-4 - 2 2 4 6 % DGL Nr 5: **y''-2**y' +2*y = 2***-x y=dsolve('**d2y-2**dy+2*y = 2***-') % DGL Nr 5 y = ^3+*log()++C*+C2*^2 ans =*(^2+log()++C+C2*) clear; =sym(''),a=sym('a') % symbolic variables,, a Nr 6 % DGL Nr 6: *y'+a*y =2***, a reell, y()= y=dsolve('*dy+a*y =2***','y()=') % Nr 6 y = 2*^3/(3+a)+^(-a)*(a+)/(3+a) % Nr 7 : (+)*( 2*y*y -exp(2*) + y*y = y=dsolve('(+)*( 2*y*Dy-exp(2*) + y*y = ','y()=-') % Nr 7 clear; =sym('') % symbolic variable, % Nr 8: **y'' +(4**-2*)*y' + (4**-4*+2)*y=***exp(-2*). y=dsolve('**d2y +(4**-2*)*Dy + (4**-4*+2)*y=***exp(-2*)') % Nr. 8 => y = /2*^3*exp(-2*)+C**exp(-2*)+C2*^2*exp(-2*)
C:\Si5\Ingmah\symbmalab\DGLn_N4_2.doc, Seie 3/5 clear; =sym('') % symbolic variable,» % Nr 9: y' +(5-4*)*y + (-)*y*y +4'-6 =. y=dsolve(' Dy +(5-4*)*y + (-)*y*y +4*-6 =') % Nr 9 y = (2*C*exp(*(-2))+(2*-)*exp(*(-3)))/(C*exp(*(-2))+*exp(*(-3))) clear; =sym(''); a=sym('a'); % symbolic variable,,a Nr % Nr : *y''-(2*a*+)*y'+a*(a*+)*y=* y=dsolve('*d2y-(2*a*+)*dy+a*(a*+)*y=*') % Nr. => y = (a*+)/a^3+c*exp(a*)+c2*^2*exp(a*) clear; =sym(''); % symbolic variable, Nr % Nr : y''' + 4*y'' + 5*y' + 2*y = cos(); y=dsolve(' D3y + 4*D2y + 5*Dy + 2*y = cos()') % Nr y = -/*cos()+/5*sin()+c*exp(-2*)+c2*exp(-)+c3*exp(-)* clear; =sym(''); % symbolic variable, Nr 2 : (*-)*y'+2**y = sin(), y()=; y=dsolve('(*-)*dy+2**y = sin()','y()='), % Nr 2 y = (-cos()+)/(^2-)» ezplo(y) ( - c o s ( ) + ) / ( 2 - ). 8. 6. 4. 2 -. 2 -. 4 -. 6-5 - 4-3 - 2-2 3 4 5 clear; =sym(''); % symbolic variable, Nr 3 % **y' - 2**y + y*y =, y()=2 y=dsolve('**dy - 2**y + y*y = ', 'y()=2'), % Nr. 2 y = ^2/(-/2)» ezplo(y) 2 / ( - / 2 ) 5-5 - - 6-4 - 2 2 4 6 clear; =sym(''); % symbolic variable, Nr 4 % Nr 4: **y'' + *y' -y= * y()=7/3; y'()=2/3 y=dsolve('**d2y + *Dy -y= *',' Dy()=2/3', 'y()=7/3'), % Nr 4 y = /3*^2+(^2+)/ clear; =sym(''); % symbolic variable, Nr 5
C:\Si5\Ingmah\symbmalab\DGLn_N4_2.doc, Seie 4/5» % Nr 5: *(-)*y' -(2*+)*y + y*y =-2*,» y= dsolve('*(-)*dy -(2*+)*y + y*y =-2*'), % Nr 5 => y = (C+^2)/(+C) clear; =sym(''); % symbolic variable, Nr 6» % Nr 6 ***y'' -**y' +*y= ***ln(x), y = ^2*log()-2*^2+C*+C2**log()» y=simple(y) => y = *(*log()-2*+c+c2*log()) clear; =sym(''); % symbolic variable, Nr 7 % Nr 7: y'+ (2*-) *y + (-x)* y*y =x, y()= y=dsolve(' Dy+ (2*-) *y + (-)* y*y =', 'y()='), % Nr 7 y = -2*exp(-)/(2-2*exp(-)*)» ezplo(y) - 2 e x p ( - ) / ( 2-2 e x p ( - ) ). 9. 8. 7. 6. 5. 4. 3. 2. - 6-5 - 4-3 - 2-2 3 4 clear; =sym(''); % symbolic variable, Nr 8 % Nr 8: **y'' + (4**-2*)*y' + (4**-4*+2)*y = ** Hinweis:mi» y=dsolve('** D2y + (4**-2*)* Dy + (4**-4*+2)* y = **' ), % Nr 8 y = /4*+C**exp(-2*)+C2*^2*exp(-2*) clear; =sym(''); % symbolic variable, Nr 9 % Nr 9: y''' +3 *y'' -4*y = exp()*cos() y= dsolve(' D3y +3 * D2y -4*y = exp()*cos()'), % Nr. 9 y = 2/25*sin()*exp()-3/5*exp()*cos()+C*exp()+C2*exp(-2*)+C3**exp(-2*) clear; =sym(''); % symbolic variable, Nr 2 % Nr 2: *(-) * y' -(2*+) * y + y*y = -2*, y=dsolve(' *(-) * Dy -(2*+) * y + y*y = -2*'), % Nr 2 => y = (C+^2)/(+C) clear; =sym(''); % symbolic variable, Nr 2 % Nr 2: ** y''+(4**-2*)*y'+(4** -4* +2) * y= ** * exp(-2*) * sin() y=dsolve(' ** D2y + (4** -2*) * Dy + (4** -4* +2) * y = ** * exp(-2*) * sin() '), % Nr 2 y = -*exp(-2*)*sin()+c**exp(-2*)+c2*^2*exp(-2*) Help-Infos in Malab 5.3» help dsolve DSOLVE Symbolic soluion of ordinary differenial equaions. DSOLVE('eqn','eqn2',...) acceps symbolic equaions represening ordinary differenial equaions and iniial condiions. Several
C:\Si5\Ingmah\symbmalab\DGLn_N4_2.doc, Seie 5/5 equaions or iniial condiions may be grouped ogeher, separaed by commas, in a single inpu argumen. By defaul, he independen variable is ''. The independen variable may be changed from '' o some oher symbolic variable by including ha variable as he las inpu argumen. The leer 'D' denoes differeniaion wih respec o he independen variable, i.e. usually d/d. A "D" followed by a digi denoes repeaed differeniaion; e.g., D2 is d^2/d^2. Any characers immediaely following hese differeniaion operaors are aken o be he dependen variables; e.g., D3y denoes he hird derivaive of y(). Noe ha he names of symbolic variables should no conain he leer "D". Iniial condiions are specified by equaions like 'y(a)=b' or 'Dy(a) = b' where y is one of he dependen variables and a and b are consans. If he number of iniial condiions given is less han he number of dependen variables, he resuling soluions will obain arbirary consans, C, C2, ec. Three differen ypes of oupu are possible. For one equaion and one oupu, he resuling soluion is reurned, wih muliple soluions o a nonlinear equaion in a symbolic vecor. For several equaions and an equal number of oupus, he resuls are sored in lexicographic order and assigned o he oupus. For several equaions and a single oupu, a srucure conaining he soluions is reurned. If no closed-form (explici) soluion is found, an implici soluion is aemped. When an implici soluion is reurned, a warning is given. If neiher an explici nor implici soluion can be compued, hen a warning is given and he empy sym is reurned. In some cases concerning nonlinear equaions, he oupu will be an equivalen lower order differenial equaion or an inegral. Examples: dsolve('dx = -a*x') reurns ans = exp(-a*)*c x = dsolve('dx = -a*x','x() = ','s') reurns x = exp(-a*s) y = dsolve('(dy)^2 + y^2 = ','y() = ') reurns y =[ sin()] [ -sin()] S = dsolve('df = f + g','dg = -f + g','f() = ','g() = 2') reurns a srucure S wih fields S.f = exp()*cos()+2*exp()*sin() S.g = -exp()*sin()+2*exp()*cos() Y = dsolve('dy = y^2*(-y)') Warning: Explici soluion could no be found; implici soluion reurned. Y = +/y-log(y)+log(-+y)+c= dsolve('df = f + sin()', 'f(pi/2) = ') dsolve('d2y = -a^2*y', 'y() =, Dy(pi/a) = ') S = dsolve('dx = y', 'Dy = -x', 'x()=', 'y()=') S = dsolve('du=v, Dv=w, Dw=-u','u()=, v()=, w()=') w = dsolve('d3w = -w','w()=, Dw()=, D2w()=') y = dsolve('d2y = sin(y)'); prey(y) See also SOLVE, SUBS.