ODE Steps for Systems of ODEs
Overview
Examples
This help page gives a few examples of using the command ODESteps to solve systems of ordinary differential equations.
See Student[ODEs][ODESteps] for a general description of the command ODESteps and its calling sequence.
with⁡Student:-ODEs:
high_order_ode1≔diff⁡y⁡x,x,x,x+3⁢diff⁡y⁡x,x,x+4⁢diff⁡y⁡x,x+2⁢y⁡x=0
high_order_ode1≔ⅆ3ⅆx3y⁡x+3⁢ⅆ2ⅆx2y⁡x+4⁢ⅆⅆxy⁡x+2⁢y⁡x=0
ODESteps⁡high_order_ode1
Let's solveⅆ3ⅆx3y⁡x+3⁢ⅆ2ⅆx2y⁡x+4⁢ⅆⅆxy⁡x+2⁢y⁡x=0•Highest derivative means the order of the ODE is3ⅆ3ⅆx3y⁡x▫Convert linear ODE into a system of first order ODEs◦Define new variabley1⁡xy1⁡x=y⁡x◦Define new variabley2⁡xy2⁡x=ⅆⅆxy⁡x◦Define new variabley3⁡xy3⁡x=ⅆ2ⅆx2y⁡x◦Isolate forⅆⅆxy3⁡xusing original ODEⅆⅆxy3⁡x=−3⁢y3⁡x−4⁢y2⁡x−2⁢y1⁡xConvert linear ODE into a system of first order ODEsy2⁡x=ⅆⅆxy1⁡x,y3⁡x=ⅆⅆxy2⁡x,ⅆⅆxy3⁡x=−3⁢y3⁡x−4⁢y2⁡x−2⁢y1⁡x•Define vectory→⁡x=y3⁡xy1⁡xy2⁡x•System to solveⅆⅆxy→⁡x=A·y→⁡x•To solve the system find eigenvalues and eigenvectors ofAA=−3−2−4001100•Eigenpairs of A−1,−1−11,−1+I,−1+I−12−I21,−1−I,−1−I−12+I21•Consider eigenpair−1,−1−11•Solution to homogeneous system from eigenpairy→1⁡x=•Consider complex eigenpair, complex conjugate eigenvalue can be ignored−1+I,−1+I−12−I21•Solution from eigenpair•Use Euler identity to write solution in terms of sin and cos•Simplify expression•Both real and imaginary parts are solutions to the homogeneous systemy→2⁡x=,y→3⁡x=•General solution to the system of ODEsy→⁡x=_C1⁢y→1⁡x+_C2⁢y→2⁡x+_C3⁢y→3⁡x•Substitute solutions into the general solutiony→⁡x=++•First component of the vector is the solution to the ODEy⁡x=−ⅇ−x⁢_C2+_C3⁢sin⁡x+_C2−_C3⁢cos⁡x+_C1
macro⁡Y=y→:
sys2≔diff⁡Y⁡x,x=Matrix⁡7,1,−4,3·Y⁡x
sys2≔ⅆⅆxy→⁡x=71−43·y→⁡x
ODESteps⁡sys2
Let's solveⅆⅆxy→⁡x=71−43·y→⁡x•System to solveⅆⅆxy→⁡x=A·y→⁡x•To solve the system find eigenvalues and eigenvectors ofAA=71−43•Eigenpairs of A5,−121,5,00•Consider eigenpair, with eigenvalue of algebraic multiplicity 25,−121•First solution from eigenvalue5y→1⁡x=•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→+v→•Note that thexmultiplyingv→makes this solution linearly independent to the 1st solution obtained fromλ=5•substitutey→2⁡xinto the systemλ⁢ⅇλ⁢x⁢x⁢v→+p→+v→+ⅇλ⁢x⁢v→=ⅇλ⁢x⁢A·x⁢v→+p→+v→•Use the fact thatv→is an eigenvector ofAλ⁢ⅇλ⁢x⁢x⁢v→+p→+v→+ⅇλ⁢x⁢v→=ⅇλ⁢x⁢λ⁢v→+λ⁢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 system−λ⁢I+A·p→=v→•Choosep→to use in the second solution to the system from eigenvalue5·p→=−121•Choice ofp→p→=−140•second solution from eigenvalue5y→2⁡x=•General solution to the system of ODEsy→⁡x=_C1⁢y→1⁡x+_C2⁢y→2⁡x•Substitute solutions into the general solutiony→⁡x=+
sys3≔diff⁡y1⁡x,x,diff⁡y2⁡x,x=Matrix⁡1,2,3,2·y1⁡x,y2⁡x+1,exp⁡x
sys3≔ⅆⅆxy1⁡xⅆⅆxy2⁡x=y1⁡x+2⁢y2⁡x+13⁢y1⁡x+2⁢y2⁡x+ⅇx
ODESteps⁡sys3
Let's solveⅆⅆxy1⁡xⅆⅆxy2⁡x=y1⁡x+2⁢y2⁡x+13⁢y1⁡x+2⁢y2⁡x+ⅇx•Define vectory→⁡x=y1⁡xy2⁡x•System to solveⅆⅆxy→⁡x=1232·y→⁡x+1ⅇx•Define forcing functionf→⁡x=1ⅇx•To solve the system find eigenvalues and eigenvectors ofAA=1232•Eigenpairs of A4,231,−1,−11•Consider eigenpair4,231•Solution to homogeneous system from eigenpairy→1⁡x=•Consider eigenpair−1,−11•Solution to homogeneous system from eigenpairy→2⁡x=•General solution to the system of ODEs wherey→p⁡xis a particular solution to the systemy→⁡x=_C1⁢y→1⁡x+_C2⁢y→2⁡x+y→p⁡x▫Fundamental matrix◦The fundamental matrix is defined as the matrix with columns that are the solutions to the homogeneous system with initial condition being the basis vector in the standard basis atx=0Φ⁡x◦Compute the solution to the homogeneous system for each basis vector of the standard basis being the inital condition atx=0ⅆⅆxy→⁡x=A·y→⁡x◦LetBbe the matrix with solutions to the homogeneous system as columns evaluated atx=0B=23−111◦For each basis vector we need to solve the system of linear equations forC→jwhich contains the values to multiply each homogeneous solution by to get the basis vector as the intital conditionB·C→j=eˆj◦Equation which must be executed for each basis vectorC→j=·eˆj◦ComputeC→jfor j =1C→1=35−35◦1st column of the fundamental matrix+=3⁢ⅇ−x5+2⁢ⅇ4⁢x5−3⁢ⅇ−x5+3⁢ⅇ4⁢x5◦ComputeC→jfor j =2C→2=3525◦2nd column of the fundamental matrix+=−2⁢ⅇ−x5+2⁢ⅇ4⁢x52⁢ⅇ−x5+3⁢ⅇ4⁢x5Fundamental matrixΦ⁡x=3⁢ⅇ−x5+2⁢ⅇ4⁢x5−2⁢ⅇ−x5+2⁢ⅇ4⁢x5−3⁢ⅇ−x5+3⁢ⅇ4⁢x52⁢ⅇ−x5+3⁢ⅇ4⁢x5▫Find a particular solution to the system of ODEs using variation of paramaters◦Let the particular solution be the fundamental matrix multiplied byv→⁡xand solve forv→⁡xy→x⁡x=Φ⁡x·v→⁡x◦Take the derivative of the particular solutionⅆⅆxy→x⁡x=ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦Substitute particular solution and it's 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 it's 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=·f→⁡x◦Integrate to solve forv→⁡xv→⁡x=∫0x·f→⁡sⅆs◦Plugv→⁡xinto the equation for the particular solutiony→x⁡x=Φ⁡x·∫0x·f→⁡sⅆs◦Plug in the fundamental matrix and the forcing function and computey→x⁡x=7⁢ⅇ4⁢x30−ⅇx3+12−2⁢ⅇ−x57⁢ⅇ4⁢x20−34+2⁢ⅇ−x5Find a particular solution to the system of ODEs using variation of paramatersy→x⁡x=7⁢ⅇ4⁢x30−ⅇx3+12−2⁢ⅇ−x57⁢ⅇ4⁢x20−34+2⁢ⅇ−x5•Plug particular solution back into general solutiony→⁡x=_C1⁢y→1⁡x+_C2⁢y→2⁡x+7⁢ⅇ4⁢x30−ⅇx3+12−2⁢ⅇ−x57⁢ⅇ4⁢x20−34+2⁢ⅇ−x5•Solution to the system of ODEsy1⁡xy2⁡x=−30⁢_C2−12⁢ⅇ−x30+20⁢_C1+7⁢ⅇ4⁢x30−ⅇx3+1220⁢_C2+8⁢ⅇ−x20−34+20⁢_C1+7⁢ⅇ4⁢x20
sys4≔diff⁡y1⁡x,x=y1⁡x+2⁢y2⁡x,diff⁡y2⁡x,x=3⁢y1⁡x+2⁢y2⁡x+exp⁡x
sys4≔ⅆⅆxy1⁡x=y1⁡x+2⁢y2⁡x,ⅆⅆxy2⁡x=3⁢y1⁡x+2⁢y2⁡x+ⅇx
ODESteps⁡sys4
Let's solveⅆⅆxy1⁡x=y1⁡x+2⁢y2⁡x,ⅆⅆxy2⁡x=3⁢y1⁡x+2⁢y2⁡x+ⅇx•Define vectory→⁡x=y1⁡xy2⁡x•Convert system into a vector equationⅆⅆxy→⁡x=+0ⅇx•System to solveⅆⅆxy→⁡x=1232·y→⁡x+0ⅇx•Define forcing functionf→⁡x=0ⅇx•To solve the system find eigenvalues and eigenvectors ofAA=1232•Eigenpairs of A−1,−11,4,231•Consider eigenpair−1,−11•Solution to homogeneous system from eigenpairy→1⁡x=•Consider eigenpair4,231•Solution to homogeneous system from eigenpairy→2⁡x=•General solution to the system of ODEs wherey→p⁡xis a particular solution to the systemy→⁡x=_C1⁢y→1⁡x+_C2⁢y→2⁡x+y→p⁡x▫Fundamental matrix◦The fundamental matrix is defined as the matrix with columns that are the solutions to the homogeneous system with initial condition being the basis vector in the standard basis atx=0Φ⁡x◦Compute the solution to the homogeneous system for each basis vector of the standard basis being the inital condition atx=0ⅆⅆxy→⁡x=A·y→⁡x◦LetBbe the matrix with solutions to the homogeneous system as columns evaluated atx=0B=−12311◦For each basis vector we need to solve the system of linear equations forC→jwhich contains the values to multiply each homogeneous solution by to get the basis vector as the intital conditionB·C→j=eˆj◦Equation which must be executed for each basis vectorC→j=·eˆj◦ComputeC→jfor j =1C→1=−3535◦1st column of the fundamental matrix+=3⁢ⅇ−x5+2⁢ⅇ4⁢x5−3⁢ⅇ−x5+3⁢ⅇ4⁢x5◦ComputeC→jfor j =2C→2=2535◦2nd column of the fundamental matrix+=−2⁢ⅇ−x5+2⁢ⅇ4⁢x52⁢ⅇ−x5+3⁢ⅇ4⁢x5Fundamental matrixΦ⁡x=3⁢ⅇ−x5+2⁢ⅇ4⁢x5−2⁢ⅇ−x5+2⁢ⅇ4⁢x5−3⁢ⅇ−x5+3⁢ⅇ4⁢x52⁢ⅇ−x5+3⁢ⅇ4⁢x5▫Find a particular solution to the system of ODEs using variation of paramaters◦Let the particular solution be the fundamental matrix multiplied byv→⁡xand solve forv→⁡xy→x⁡x=Φ⁡x·v→⁡x◦Take the derivative of the particular solutionⅆⅆxy→x⁡x=ⅆⅆxΦ⁡x·v→⁡x+Φ⁡x·ⅆⅆxv→⁡x◦Substitute particular solution and it's 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 it's 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=·f→⁡x◦Integrate to solve forv→⁡xv→⁡x=∫0x·f→⁡sⅆs