Systems of ODEs with IVP - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


ODE Steps for Systems of ODEs with IVP

 

Overview

Examples

Overview

• 

This help page gives a few examples of using the command ODESteps to solve systems of ordinary differential equations with initial values.

• 

See Student[ODEs][ODESteps] for a general description of the command ODESteps and its calling sequence.

Examples

> 

with⁡Student:-ODEs:

> 

high_order_ivp1≔diff⁡y⁡x,x,x,x+3⁢diff⁡y⁡x,x,x+4⁢diff⁡y⁡x,x+2⁢y⁡x=0,eval⁡diff⁡y⁡x,x,x=0=−1,eval⁡diff⁡y⁡x,x,x,x=0=2,y⁡0=1

high_order_ivp1≔ⅆ3ⅆx3y⁡x+3⁢ⅆ2ⅆx2y⁡x+4⁢ⅆⅆxy⁡x+2⁢y⁡x=0,ⅆ2ⅆx2y⁡xx=0|ⅆ2ⅆx2y⁡xx=0=2,ⅆⅆxy⁡xx=0|ⅆⅆxy⁡xx=0=−1,y⁡0=1

(1)
> 

ODESteps⁡high_order_ivp1

Let's solveⅆ3ⅆx3y⁡x+3⁢ⅆ2ⅆx2y⁡x+4⁢ⅆⅆxy⁡x+2⁢y⁡x=0,ⅆ2ⅆx2y⁡xx=0|ⅆ2ⅆx2y⁡xx=0=2,ⅆⅆxy⁡xx=0|ⅆⅆxy⁡xx=0=−1,y⁡0=1•Highest derivative means the order of the ODE is3ⅆ3ⅆx3y⁡x•Characteristic polynomial of ODEr3+3⁢r2+4⁢r+2=0•Roots of the characteristic polynomialr=−1,−1−I,−1+I•Solution fromr=−1y1⁡x=ⅇ−x•Solutions fromr=−1−Iandr=−1+Iy2⁡x=ⅇ−x⁢sin⁡x,y3⁡x=ⅇ−x⁢cos⁡x•General solution of the ODEy⁡x=c__1⁢y1⁡x+c__2⁢y2⁡x+c__3⁢y3⁡x•Substitute in solutions and simplifyy⁡x=ⅇ−x⁢c__1+c__2⁢sin⁡x+c__3⁢cos⁡x•Use the initial conditiony⁡0=11=c__1+c__3•Calculate the 1st derivative of the solutionⅆⅆxy⁡x=−ⅇ−x⁢c__1+c__2⁢sin⁡x+c__3⁢cos⁡x+ⅇ−x⁢c__2⁢cos⁡x−c__3⁢sin⁡x•Use the initial conditionⅆⅆxy⁡xx=0|ⅆⅆxy⁡xx=0=−1−1=−c__1−c__3+c__2•Calculate the 2nd derivative of the solutionⅆ2ⅆx2y⁡x=ⅇ−x⁢c__1+c__2⁢sin⁡x+c__3⁢cos⁡x−2⁢ⅇ−x⁢c__2⁢cos⁡x−c__3⁢sin⁡x+ⅇ−x⁢−c__2⁢sin⁡x−c__3⁢cos⁡x•Use the initial conditionⅆ2ⅆx2y⁡xx=0|ⅆ2ⅆx2y⁡xx=0=22=c__1−2⁢c__2•Solve for the unknown coefficientsc__1=2,c__2=0,c__3=−1•Solution to the IVPy⁡x=ⅇ−x⁢2−cos⁡x

(2)
> 

macro⁡Y=y1⁡x,y2⁡x:

> 

ivpsys2≔diff⁡Y,x=%.⁡Matrix⁡7,1,`-`⁡4,3,Y,eval⁡Y,x=0=1,1

ivpsys2≔ⅆⅆxy1⁡xⅆⅆxy2⁡x=71−43·y1⁡xy2⁡x,y1⁡0y2⁡0=11

(3)
> 

ODESteps⁡ivpsys2

Let's solveⅆⅆxy1⁡xⅆⅆxy2⁡x=71−43·y1⁡xy2⁡x,y1⁡0y2⁡0=11•Define vectory→⁡x=y1⁡xy2⁡x•System to solveⅆⅆxy→⁡x=71−43·y→⁡x•Define the coefficient matrixA=71−43•Rewrite the system asⅆⅆxy→⁡x=A·y→⁡x•To solve the system, find the eigenvalues and eigenvectors ofA•Eigenpairs ofA5,−121,5,00•Consider eigenpair, with eigenvalue of algebraic multiplicity 25,−121•First solution from eigenvalue5y→1⁡x=ⅇ5⁢x⋅−121•Form of the 2nd homogeneous solution wherep→is to be solved for,λ=5is the eigenvalue, andv→is the eigenvectory→2⁡x=ⅇλ⁢x⁢x⁢v→+p→•Note that thexmultiplyingv→makes this solution linearly independent to the 1st solution obtained fromλ=5•Substitutey→2⁡xinto the homogeneous systemλ⁢ⅇλ⁢x⁢x⁢v→+p→+ⅇλ⁢x⁢v→=ⅇλ⁢x⁢A·x⁢v→+p→•Use the fact thatv→is an eigenvector ofAλ⁢ⅇλ⁢x⁢x⁢v→+p→+ⅇλ⁢x⁢v→=ⅇλ⁢x⁢λ⁢x⁢v→+A·p→•Simplify equationλ⁢p→+v→=A·p→•Make use of the identity matrixIλ⋅I·p→+v→=A·p→•Conditionp→must meet fory→2⁡xto be a solution to the homogeneous systemA−λ⋅I·p→=v→•Choosep→to use in the second solution to the homogeneous system from eigenvalue571−43−5⋅1001·p→=−121•Choice ofp→p→=−140•Second solution from eigenvalue5y→2⁡x=ⅇ5⁢x⋅x⋅−121+−140•General solution to the system of ODEsy→=c__1⁢y→1⁡x+c__2⁢y→2⁡x•Substitute solutions into the general solutiony→=c__1⁢ⅇ5⁢x⋅−121+c__2⁢ⅇ5⁢x⋅x⋅−121+−140▫Fundamental matrix◦Letφ⁡xbe the matrix whose columns are the independent solutions of the homogeneous system.φ⁡x=−ⅇ5⁢x2ⅇ5⁢x⁢−x2−14ⅇ5⁢xⅇ5⁢x⁢x◦The fundamental matrix,Φ⁡xis a normalized version ofφ⁡xsatisfyingΦ⁡0=IwhereIis the identity matrixΦ⁡x=φ⁡x·φ⁡0−1◦Substitute the value ofφ⁡xandφ⁡0Φ⁡x=−ⅇ5⁢x2ⅇ5⁢x⁢−x2−14ⅇ5⁢xⅇ5⁢x⁢x·−12−1410−1◦Evaluate and simplify to get the fundamental matrixΦ⁡x=ⅇ5⁢x⁢2⁢x+1ⅇ5⁢x⁢x−4⁢ⅇ5⁢x⁢xⅇ5⁢x⁢1−2⁢x•Remember that the fundamental matrix has columns that are basis vectors atx=0, so the solution to the IVP is the columns of the fundamental matrix multiplied by the entries of the initial condition vectory→⁡x=Φ⁡x·11•Compute solution to the IVPy→⁡x=ⅇ5⁢x⁢2⁢x+1+ⅇ5⁢x⁢x−4⁢ⅇ5⁢x⁢x+ⅇ5⁢x⁢1−2⁢x•Solution to the system of ODEsy1⁡xy2⁡x=ⅇ5⁢x⁢3⁢x+1ⅇ5⁢x⁢−6⁢x+1

(4)
> 

ivpsys3≔diff⁡Y,x=Matrix⁡1,2,3,2·Y+1,exp⁡x,eval⁡Y,x=1=0,−1

ivpsys3≔ⅆⅆxy1⁡xⅆⅆxy2⁡x=y1⁡x+2⁢y2⁡x+13⁢y1⁡x+2⁢y2⁡x+ⅇx,y1⁡1y2⁡1=0−1

(5)
> 

ODESteps⁡ivpsys3

Let's solveⅆⅆxy1⁡xⅆⅆxy2⁡x=y1⁡x+2⁢y2⁡x+13⁢y1⁡x+2⁢y2⁡x+ⅇx,y1⁡1y2⁡1=0−1•Define vectory→⁡x=y1⁡xy2⁡x•System to solveⅆⅆxy→⁡x=1232·y→⁡x+1ⅇx•Define the forcing functionf→⁡x=1ⅇx•Define the coefficient matrixA=1232•Rewrite the system asⅆⅆxy→⁡x=A·y→⁡x+f→•To solve the system, find the eigenvalues and eigenvectors ofA•Eigenpairs ofA−1,−11,4,231•Consider eigenpair−1,−11•Solution to homogeneous system from eigenpairy→1=ⅇ−x⋅−11•Consider eigenpair4,231•Solution to homogeneous system from eigenpairy→2=ⅇ4⁢x⋅231•General solution of the system of ODEs can be written in terms of the particular solutiony→p⁡xy→⁡x=c__1⁢y→1+c__2⁢y→2+y→p⁡x▫Fundamental matrix◦Letφ⁡xbe the matrix whose columns are the independent solutions of the homogeneous system.φ⁡x=−ⅇ−x2⁢ⅇ4⁢x3ⅇ−xⅇ4⁢x◦The fundamental matrix,Φ⁡x,1is a normalized version ofφ⁡xsatisfyingΦ⁡1,1=IwhereIis the identity matrixΦ⁡x=φ⁡x·φ⁡1−1◦Substitute the value ofφ⁡xandφ⁡1Φ⁡x,1=−ⅇ−x2⁢ⅇ4⁢x3ⅇ−xⅇ4⁢x·−ⅇ−12⁢ⅇ43ⅇ−1ⅇ4−1◦Evaluate and simplify to get the fundamental matrixΦ⁡x,1=3⁢ⅇ1−x5+2⁢ⅇ−4+4⁢x5−2⁢ⅇ1−x5+2⁢ⅇ−4+4⁢x5−3⁢ⅇ1−x5+3⁢ⅇ−4+4⁢x52⁢ⅇ1−x5+3⁢ⅇ−4+4⁢x5▫Find a particular solution of the system of ODEs using variation of parameters◦Let the particular solution be the fundamental matrix multiplied byv→⁡xand solve forv→⁡xy→p⁡x=Φ⁡x·v→⁡x◦Take the derivative of the particular solutionⅆⅆxy→p⁡x=ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦Substitute particular solution and its derivative into the system of ODEsⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x=A·Φ⁡x·v→⁡x+f→⁡x◦The fundamental matrix has columns that are solutions to the homogeneous system so its derivative follows that of the homogeneous systemA·Φ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x=A·Φ⁡x·v→⁡x+f→⁡x◦Cancel like termsΦ⁡x·ⅆⅆxv→⁡x=f→⁡x◦Multiply by the inverse of the fundamental matrixⅆⅆxv→⁡x=Φ⁡x−1·f→⁡x◦Integrate to solve forv→⁡xv→⁡x=∫0xΦ⁡s−1·f→⁡sⅆs◦Plugv→⁡xinto the equation for the particular solutiony→p⁡x=Φ⁡x·∫0xΦ⁡s−1·f→⁡sⅆs◦Plug in the fundamental matrix and the forcing function and computey→p⁡x=7⁢ⅇ4⁢x30+12−ⅇx3−2⁢ⅇ−x57⁢ⅇ4⁢x20−34+2⁢ⅇ−x5•Plug particular solution back into general solutiony→⁡x=c__1⁢y→1+c__2⁢y→2+7⁢ⅇ4⁢x30+12−ⅇx3−2⁢ⅇ−x57⁢ⅇ4⁢x20−34+2⁢ⅇ−x5•Remember that the fundamental matrix has columns that are basis vectors atx=1, so we can use the fundamental matrix to solve the IVP. Define the initial condition vectora→=0−1•From here on we will writeΦ⁡x,1asΦ⁡xΦ⁡x=Φ⁡x,1•This is the form of the solutiony→⁡x=Φ⁡x·a→−yp⁡1+yp⁡x•Since the fundamental matrix is the identity atx=1, evaluating this solution atx=1gives the initial condition as requiredy→⁡1=a→−yp⁡1+yp⁡1▫Show that this solution solves the ODE◦First calculateⅆⅆxy→⁡xⅆⅆxy→⁡x=ⅆⅆxΦ⁡x·a→−yp⁡1+ⅆⅆxyp⁡x◦Useⅆⅆxyp⁡x=ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡xfound while computingyp⁡xⅆⅆxy→⁡x=ⅆⅆxΦ⁡x·a→−yp⁡1+ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦The columns of the fundamental matrix are solutions to the homogeneous system so its derivative follows that of the homogeneous system, that isⅆⅆxΦ⁡x=A·Φ⁡xⅆⅆxy→⁡x=A·Φ⁡x·a→−yp⁡1+A·Φ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦Recall that when finding the particular solution to the system we foundf→⁡x=Φ⁡x·ⅆⅆxv→⁡xⅆⅆxy→⁡x=A·Φ⁡x·a→−yp⁡1+A·yp⁡x+f→⁡x◦Group termsⅆⅆxy→⁡x=A·Φ⁡x·a→−yp⁡1+yp⁡x+f→⁡x◦Usingy→⁡x=Φ⁡x·a→−yp⁡1+yp⁡x, it is clear thaty→⁡xis a solution to the systemⅆⅆxy→⁡x=A·y→⁡x+f→⁡x•Solution to the system of ODEsy1⁡xy2⁡x=−ⅇ1−x5−3⁢ⅇ−4+4⁢x10+12+ⅇ2−x5−ⅇx3+2⁢ⅇ−3+4⁢x15ⅇ1−x5−9⁢ⅇ−4+4⁢x20−34−ⅇ2−x5+ⅇ−3+4⁢x5

(6)
> 

ivpsys4≔diff⁡w⁡x,x=w⁡x+2⁢z⁡x,diff⁡z⁡x,x=3⁢w⁡x+2⁢z⁡x+exp⁡x,w⁡−1=2,z⁡−1=−2

ivpsys4≔ⅆⅆxw⁡x=w⁡x+2⁢z⁡x,ⅆⅆxz⁡x=3⁢w⁡x+2⁢z⁡x+ⅇx,w⁡−1=2,z⁡−1=−2

(7)
> 

ODESteps⁡ivpsys4

Let's solveⅆⅆxw⁡x=w⁡x+2⁢z⁡x,ⅆⅆxz⁡x=3⁢w⁡x+2⁢z⁡x+ⅇx,w⁡−1=2,z⁡−1=−2•Define vectorw→⁡x=w⁡xz⁡x•Convert system into a vector equationⅆⅆxw→⁡x=1232·w→⁡x+0ⅇx•System to solveⅆⅆxw→⁡x=1232·w→⁡x+0ⅇx•Define the forcing functionf→⁡x=0ⅇx•Define the coefficient matrixA=1232•Rewrite the system asⅆⅆxw→⁡x=A·w→⁡x+f→•To solve the system, find the eigenvalues and eigenvectors ofA•Eigenpairs ofA−1,−11,4,231•Consider eigenpair−1,−11•Solution to homogeneous system from eigenpairw→1=ⅇ−x⋅−11•Consider eigenpair4,231•Solution to homogeneous system from eigenpairw→2=ⅇ4⁢x⋅231•General solution of the system of ODEs can be written in terms of the particular solutionw→p⁡xw→⁡x=c__1⁢w→1+c__2⁢w→2+w→p⁡x▫Fundamental matrix◦Letφ⁡xbe the matrix whose columns are the independent solutions of the homogeneous system.φ⁡x=−ⅇ−x2⁢ⅇ4⁢x3ⅇ−xⅇ4⁢x◦The fundamental matrix,Φ⁡x,−1is a normalized version ofφ⁡xsatisfyingΦ⁡−1,−1=IwhereIis the identity matrixΦ⁡x=φ⁡x·φ⁡−1−1◦Substitute the value ofφ⁡xandφ⁡−1Φ⁡x,−1=−ⅇ−x2⁢ⅇ4⁢x3ⅇ−xⅇ4⁢x·−ⅇ2⁢ⅇ−43ⅇⅇ−4−1◦Evaluate and simplify to get the fundamental matrixΦ⁡x,−1=3⁢ⅇ−1−x5+2⁢ⅇ4+4⁢x5−2⁢ⅇ−1−x5+2⁢ⅇ4+4⁢x5−3⁢ⅇ−1−x5+3⁢ⅇ4+4⁢x52⁢ⅇ−1−x5+3⁢ⅇ4+4⁢x5▫Find a particular solution of the system of ODEs using variation of parameters◦Let the particular solution be the fundamental matrix multiplied byv→⁡xand solve forv→⁡xw→p⁡x=Φ⁡x·v→⁡x◦Take the derivative of the particular solutionⅆⅆxw→p⁡x=ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦Substitute particular solution and its derivative into the system of ODEsⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x=A·Φ⁡x·v→⁡x+f→⁡x◦The fundamental matrix has columns that are solutions to the homogeneous system so its derivative follows that of the homogeneous systemA·Φ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x=A·Φ⁡x·v→⁡x+f→⁡x◦Cancel like termsΦ⁡x·ⅆⅆxv→⁡x=f→⁡x◦Multiply by the inverse of the fundamental matrixⅆⅆxv→⁡x=Φ⁡x−1·f→⁡x◦Integrate to solve forv→⁡xv→⁡x=∫0xΦ⁡s−1·f→⁡sⅆs◦Plugv→⁡xinto the equation for the particular solutionw→p⁡x=Φ⁡x·∫0xΦ⁡s−1·f→⁡sⅆs◦Plug in the fundamental matrix and the forcing function and computew→p⁡x=ⅇ−x5+2⁢ⅇ4⁢x15−ⅇx3−ⅇ−x5+ⅇ4⁢x5•Plug particular solution back into general solutionw→⁡x=c__1⁢w→1+c__2⁢w→2+ⅇ−x5+2⁢ⅇ4⁢x15−ⅇx3−ⅇ−x5+ⅇ4⁢x5•Remember that the fundamental matrix has columns that are basis vectors atx=−1, so we can use the fundamental matrix to solve the IVP. Define the initial condition vectora→=2−2•From here on we will writeΦ⁡x,−1asΦ⁡xΦ⁡x=Φ⁡x,−1•This is the form of the solutiony→⁡x=Φ⁡x·a→−yp⁡−1+yp⁡x•Since the fundamental matrix is the identity atx=−1, evaluating this solution atx=−1gives the initial condition as requiredy→⁡−1=a→−yp⁡−1+yp⁡−1▫Show that this solution solves the ODE◦First calculateⅆⅆxy→⁡xⅆⅆxy→⁡x=ⅆⅆxΦ⁡x·a→−yp⁡−1+ⅆⅆxyp⁡x◦Useⅆⅆxyp⁡x=ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡xfound while computingyp⁡xⅆⅆxy→⁡x=ⅆⅆxΦ⁡x·a→−yp⁡−1+ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦The columns of the fundamental matrix are solutions to the homogeneous system so its derivative follows that of the homogeneous system, that isⅆⅆxΦ⁡x=A·Φ⁡xⅆⅆxy→⁡x=A·Φ⁡x·a→−yp⁡−1+A·Φ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦Recall that when finding the particular solution to the system we foundf→⁡x=Φ⁡x·ⅆⅆxv→⁡xⅆⅆxy→⁡x=A·Φ⁡x·a→−yp⁡−1+A·yp⁡x+f→⁡x◦Group termsⅆⅆxy→⁡x=A·Φ⁡x·a→−yp⁡−1+yp⁡x+f→⁡x◦Usingy→⁡x=Φ⁡x·a→−yp⁡−1+yp⁡x, it is clear thaty→⁡xis a solution to the systemⅆⅆxy→⁡x=A·y→⁡x+f→⁡x•Substitute in vector of dependent variablesw⁡xz⁡x=2⁢ⅇ3+4⁢x15−ⅇx3+ⅇ−2−x5+2⁢ⅇ−1−xⅇ3+4⁢x5−ⅇ−2−x5−2⁢ⅇ−1−x•Solution to the system of ODEsw⁡x=2⁢ⅇ3+4⁢x15−ⅇx3+ⅇ−2−x5+2⁢ⅇ−1−x,z⁡x=ⅇ3+4⁢x5−ⅇ−2−x5−2⁢ⅇ−1−x

(8)

See Also

diff

Int

Student

Student[ODEs]

Student[ODEs][ODESteps]