352 - Topic 13 - Linear DEs with variation of parameters

30 days ago by Professor352

Solving Linear Non-homogeneous Differential Equations using variation of parameters

 

John Travis

Mississippi College

 

 

Variation of Parameters

 

What happens if you can't figure out an appropriate differential operator that annihilates the right-hand side?


# Solutions of the homogeneous problem var('t') # a2 = t^2 # coefficient of the second derivative term # a1 = -2*t # coefficient of the first deriviata2 =ive term # a0 = 2 # coefficient of the unknown y term a2 = 1 a1 = -3 a0 = -4 # g = 3*t^2 g = 4*t-5*exp(-t) Y = function('Y')(t) # let's verify DE = a2*diff(Y,t,2) + a1*diff(Y,t)+a0*Y-g # Here are the two solutions to the associated homogeneous equation. # y1 = t # y2 = t^2 y1 = exp(4*t) y2 = exp(-t) pretty_print(DE,"= 0") pretty_print("Y1 = ", y1) pretty_print("Y2 = ", y2) pretty_print("The homogeneous equation evaluated for Y = y1 is = ",a2*diff(y1,t,2) + a1*diff(y1,t) + a0*y1) pretty_print("The homogeneous equation evaluated for Y = y2 is = ",a2*diff(y2,t,2) + a1*diff(y2,t) + a0*y2) # desolve(DE==g,Y) # Now, focus on a particular solution for the non-homogeneous problem using these two solutions from above u1 = function('u1')(t) u2 = function('u2')(t) CONDITION = diff(u1,t)*y1 + diff(u2,t)*y2 y = u1*y1 + y2*u2 pretty_print("Using y = ",y) yp = diff(y,t)-CONDITION pretty_print("and y' = ",yp) ypp = diff(yp,t) pretty_print("and y'' = ",ypp) pretty_print("Now. plug y, yp, and ypp into the original non-homogeneous DE in the form left-g(t) = 0.") assume(t>0) DE = (a2*ypp + a1*yp + a0*y-g).simplify_full() pretty_print(DE) pretty_print("So, using this result with the hypothesis that u1'y1+u2'y2=0 means we have to solve the following two equations...") pretty_print(CONDITION,"= 0") pretty_print(DE,"= 0") # Set up the matrix solver to solve this 2x2 ugly system M = matrix([[y1,y2],[diff(y1,t),diff(y2,t)]]) show("Whole matrix = ",M) W = det(M) show("Determinant of this =",W) A1 = copy(M) A1[:,0] = vector([0,1]) u1p = det(A1)*g/(a2*W) # notice the adjustment if the leading coeffient is not a one A2 = copy(M) A2[:,1] = vector([0,1]) u2p = det(A2)*g/(a2*W) # here too pretty_print("u1' = ",u1p) pretty_print("u2' = ",u2p) pretty_print("and by simple integration yields:") u1 = integrate(u1p,t) u2 = integrate(u2p,t) pretty_print("u1 = ",u1) pretty_print("u2 = ",u2) pretty_print("and therefore gives a particular solution to the non-homogeneous problem") y = u1*y1+u2*y2 pretty_print(y.expand()) DEleft = (a2*diff(y,t,2) + a1*diff(y,t) + a0*y).simplify_full() pretty_print("plugged into the left side for y = ",DEleft.expand()) 
       

                                
                            

                                

Let's try this on a higher order differential equation.

In this case, just to check let's use a constant coefficient problem with a "known" right-hand side.

reset() pretty_print(html("Consider the differential equation $y'''- 4y' = 30e^{3t}$, which we can solve using known differential operators (annihilators)")) # Solutions of the homogeneous problem var('t') a3 = 1 # coefficient of the third derivative term a2 = 0 # coefficient of the second derivative term a1 = -4 # coefficient of the first deriviative term a0 = 0 # coefficient of the unknown y term g = 30*exp(3*t) Y = function('Y')(t) # let's verify DE = a3*diff(Y,t,3) + a2*diff(Y,t,2) + a1*diff(Y,t) + a0*Y - g # Here are the three solutions to the associated homogeneous equation. y1 = 1 y2 = exp(-2*t) y3 = exp(2*t) pretty_print(DE,"= 0") pretty_print("Evaluated for Y = ",y1," is = ",a3*diff(y1,t,3) + a2*diff(y1,t,2) + a1*diff(y1,t,1) + a0*y1) pretty_print("Evaluated for Y = ",y2," is = ",a3*diff(y2,t,3) + a2*diff(y2,t,2) + a1*diff(y2,t,1) + a0*y2) pretty_print("Evaluated for Y = ",y3," is = ",a3*diff(y3,t,3) + a2*diff(y3,t,2) + a1*diff(y3,t,1) + a0*y3) # desolve(DE==g,Y) # Now, focus on a particular solution for the non-homogeneous problem using these two solutions from above u1 = function('u1')(t) u2 = function('u2')(t) u3 = function('u3')(t) y = u1*y1 + y2*u2 + y3*u3 pretty_print("Our guess for a particular solution should then be of the form") pretty_print(y) CONDITION1 = diff(u1,t)*y1 + diff(u2,t)*y2 + diff(u3,t)*y3 yp = diff(y,t)-CONDITION1 # removing terms that we are setting equal to zero pretty_print("differentiate and then removing ",CONDITION1) pretty_print("leaves y' =",yp) CONDITION2 = diff(u1,t)*diff(y1,t) + diff(u2,t)*diff(y2,t) + diff(u3,t)*diff(y3,t) ypp = diff(yp,t)-CONDITION2 pretty_print("differentiating again and removing ",CONDITION2) pretty_print("leaves y'' = ",ypp) yppp = diff(ypp,t) pretty_print("y''' =",yppp) # Now. put y, yp, ypp, adn yppp into the original non-homogeneous DE in the form left-g(t) = 0. assume(t>0) DE = (a3*yppp + a2*ypp + a1*yp + a0*y - g).simplify_full() pretty_print("Plugging this into the original DE in the form left-right=0 gives:") pretty_print(DE) # We may have to help out a bit by simplifying by hand # DE = (DE/(2*exp(-2*t))).simplify_full() # This is done by hand to simplify better pretty_print("Combining this result with the CONDITION1 and CONDITION 2 hypotheses means we have to solve the following three equations...") pretty_print(CONDITION1,"= 0") pretty_print(CONDITION2,"= 0") pretty_print(DE.expand(),"= 0") # Set up the matrix solver to solve this 3x3 ugly system M = matrix([[y1,y2,y3],[diff(y1,t),diff(y2,t),diff(y3,t)],[diff(y1,t,2),diff(y2,t,2),diff(y3,t,2)]]) show("Whole matrix = ",M) W = det(M) show("Determinant of this =",W) A1 = copy(M) A1[:,0] = vector([0,0,1]) u1p = det(A1)*g/(a3*W) # presumes the coefficient of the y''' term is a one A2 = copy(M) A2[:,1] = vector([0,0,1]) u2p = det(A2)*g/(a3*W) A3 = copy(M) A3[:,2] = vector([0,0,1]) u3p = det(A3)*g/(a3*W) pretty_print("u1' = ",u1p) pretty_print("u2' = ",u2p) pretty_print("u3' = ",u3p) pretty_print("and by simple integration yields:") u1 = integrate(u1p,t) u2 = integrate(u2p,t) u3 = integrate(u3p,t) pretty_print("u1 = ",u1) pretty_print("u2 = ",u2) pretty_print("u3 = ",u3) pretty_print("and therefore gives a particular solution to the non-homogeneous problem") y = u1*y1+u2*y2+u3*y3 pretty_print(y) DEleft = (a3*diff(y,t,3) + a2*diff(y,t,2) + a1*diff(y,t) + a0*y).simplify_full() pretty_print("plugged into the left side for y = ",DEleft) 
       
Consider the differential equation , which we can solve using known differential operators (annihilators)

                                
                            
Consider the differential equation , which we can solve using known differential operators (annihilators)

                                
reset() pretty_print(html("Consider the differential equation $y'''+ 4y' = tan(t)$, which we can solve using known differential operators (annihilators)")) # Solutions of the homogeneous problem var('t') a3 = 1 # coefficient of the third derivative term a2 = 0 # coefficient of the second derivative term a1 = 4 # coefficient of the first deriviative term a0 = 0 # coefficient of the unknown y term g = tan(t) Y = function('Y')(t) # let's verify DE = a3*diff(Y,t,3) + a2*diff(Y,t,2) + a1*diff(Y,t) + a0*Y - g # Here are the three solutions to the associated homogeneous equation. y1 = 1 y2 = cos(2*t) y3 = sin(2*t) pretty_print(DE,"= 0") pretty_print("Evaluated for Y = ",y1," is = ",a3*diff(y1,t,3) + a2*diff(y1,t,2) + a1*diff(y1,t,1) + a0*y1) pretty_print("Evaluated for Y = ",y2," is = ",a3*diff(y2,t,3) + a2*diff(y2,t,2) + a1*diff(y2,t,1) + a0*y2) pretty_print("Evaluated for Y = ",y3," is = ",a3*diff(y3,t,3) + a2*diff(y3,t,2) + a1*diff(y3,t,1) + a0*y3) # desolve(DE==g,Y) # Now, focus on a particular solution for the non-homogeneous problem using these two solutions from above u1 = function('u1')(t) u2 = function('u2')(t) u3 = function('u3')(t) y = u1*y1 + y2*u2 + y3*u3 pretty_print("Our guess for a particular solution should then be of the form") pretty_print(y) CONDITION1 = diff(u1,t)*y1 + diff(u2,t)*y2 + diff(u3,t)*y3 yp = diff(y,t)-CONDITION1 # removing terms that we are setting equal to zero pretty_print("differentiate and then removing ",CONDITION1) pretty_print("leaves y' =",yp) CONDITION2 = diff(u1,t)*diff(y1,t) + diff(u2,t)*diff(y2,t) + diff(u3,t)*diff(y3,t) ypp = diff(yp,t)-CONDITION2 pretty_print("differentiating again and removing ",CONDITION2) pretty_print("leaves y'' = ",ypp) yppp = diff(ypp,t) pretty_print("y''' =",yppp) # Now. put y, yp, ypp, adn yppp into the original non-homogeneous DE in the form left-g(t) = 0. assume(t>0) DE = (a3*yppp + a2*ypp + a1*yp + a0*y - g).simplify_full() pretty_print("Plugging this into the original DE in the form left-right=0 gives:") pretty_print(DE) # We may have to help out a bit by simplifying by hand # DE = (DE/(2*exp(-2*t))).simplify_full() # This is done by hand to simplify better pretty_print("Combining this result with the CONDITION1 and CONDITION 2 hypotheses means we have to solve the following three equations...") pretty_print(CONDITION1,"= 0") pretty_print(CONDITION2,"= 0") pretty_print(DE.expand(),"= 0") # Set up the matrix solver to solve this 3x3 ugly system M = matrix([[y1,y2,y3],[diff(y1,t),diff(y2,t),diff(y3,t)],[diff(y1,t,2),diff(y2,t,2),diff(y3,t,2)]]) show("Whole matrix = ",M) W = det(M) show("Determinant of this =",W) A1 = copy(M) A1[:,0] = vector([0,0,1]) u1p = det(A1)*g/W A2 = copy(M) A2[:,1] = vector([0,0,1]) u2p = det(A2)*g/W A3 = copy(M) A3[:,2] = vector([0,0,1]) u3p = det(A3)*g/W pretty_print("u1' = ",u1p) pretty_print("u2' = ",u2p) pretty_print("u3' = ",u3p) pretty_print("and by simple integration yields:") u1 = integrate(u1p,t) u2 = integrate(u2p,t) u3 = integrate(u3p,t) pretty_print("u1 = ",u1) pretty_print("u2 = ",u2) pretty_print("u3 = ",u3) pretty_print("and therefore gives a particular solution to the non-homogeneous problem") y = u1*y1+u2*y2+u3*y3 pretty_print(y) DEleft = (a3*diff(y,t,3) + a2*diff(y,t,2) + a1*diff(y,t) + a0*y).simplify_full() pretty_print("plugged into the left side for y = ",DEleft) 
       
Consider the differential equation , which we can solve using known differential operators (annihilators)

                                
                            
Consider the differential equation , which we can solve using known differential operators (annihilators)

                                
reset() pretty_print(html("Consider the differential equation $y'''- y'' + y' - y = tan(t)$, which we can solve using known differential operators (annihilators)")) # Solutions of the homogeneous problem var('t') a3 = 1 # coefficient of the third derivative term a2 = -1 # coefficient of the second derivative term a1 = 1 # coefficient of the first deriviative term a0 = -1 # coefficient of the unknown y term g = tan(t) Y = function('Y')(t) # let's verify DE = a3*diff(Y,t,3) + a2*diff(Y,t,2) + a1*diff(Y,t) + a0*Y - g # Here are the three solutions to the associated homogeneous equation. y1 = exp(t) y2 = cos(t) y3 = sin(t) pretty_print(DE,"= 0") pretty_print("Evaluated for Y = ",y1," is = ",a3*diff(y1,t,3) + a2*diff(y1,t,2) + a1*diff(y1,t,1) + a0*y1) pretty_print("Evaluated for Y = ",y2," is = ",a3*diff(y2,t,3) + a2*diff(y2,t,2) + a1*diff(y2,t,1) + a0*y2) pretty_print("Evaluated for Y = ",y3," is = ",a3*diff(y3,t,3) + a2*diff(y3,t,2) + a1*diff(y3,t,1) + a0*y3) # desolve(DE==g,Y) # Now, focus on a particular solution for the non-homogeneous problem using these two solutions from above u1 = function('u1')(t) u2 = function('u2')(t) u3 = function('u3')(t) y = u1*y1 + y2*u2 + y3*u3 pretty_print("Our guess for a particular solution should then be of the form") pretty_print(y) CONDITION1 = diff(u1,t)*y1 + diff(u2,t)*y2 + diff(u3,t)*y3 yp = diff(y,t)-CONDITION1 # removing terms that we are setting equal to zero pretty_print("differentiate and then removing ",CONDITION1) pretty_print("leaves y' =",yp) CONDITION2 = diff(u1,t)*diff(y1,t) + diff(u2,t)*diff(y2,t) + diff(u3,t)*diff(y3,t) ypp = diff(yp,t)-CONDITION2 pretty_print("differentiating again and removing ",CONDITION2) pretty_print("leaves y'' = ",ypp) yppp = diff(ypp,t) pretty_print("y''' =",yppp) # Now. put y, yp, ypp, adn yppp into the original non-homogeneous DE in the form left-g(t) = 0. assume(t>0) DE = (a3*yppp + a2*ypp + a1*yp + a0*y - g).simplify_full() pretty_print("Plugging this into the original DE in the form left-right=0 gives:") pretty_print(DE) # We may have to help out a bit by simplifying by hand # DE = (DE/(2*exp(-2*t))).simplify_full() # This is done by hand to simplify better pretty_print("Combining this result with the CONDITION1 and CONDITION 2 hypotheses means we have to solve the following three equations...") pretty_print(CONDITION1,"= 0") pretty_print(CONDITION2,"= 0") pretty_print(DE.expand(),"= 0") # Set up the matrix solver to solve this 3x3 ugly system M = matrix([[y1,y2,y3],[diff(y1,t),diff(y2,t),diff(y3,t)],[diff(y1,t,2),diff(y2,t,2),diff(y3,t,2)]]) show("Whole matrix = ",M) W = det(M) show("Determinant of this =",W) A1 = copy(M) A1[:,0] = vector([0,0,1]) u1p = det(A1)*g/W A2 = copy(M) A2[:,1] = vector([0,0,1]) u2p = det(A2)*g/W A3 = copy(M) A3[:,2] = vector([0,0,1]) u3p = det(A3)*g/W pretty_print("u1' = ",u1p) pretty_print("u2' = ",u2p) pretty_print("u3' = ",u3p) pretty_print("and by simple integration yields:") u1 = integrate(u1p,t) u2 = integrate(u2p,t) u3 = integrate(u3p,t) pretty_print("u1 = ",u1) pretty_print("u2 = ",u2) pretty_print("u3 = ",u3) pretty_print("and therefore gives a particular solution to the non-homogeneous problem") y = u1*y1+u2*y2+u3*y3 pretty_print(y) DEleft = (a3*diff(y,t,3) + a2*diff(y,t,2) + a1*diff(y,t) + a0*y).simplify_full() pretty_print("plugged into the left side for y = ",DEleft) 
       
Consider the differential equation , which we can solve using known differential operators (annihilators)

                                
                            
Consider the differential equation , which we can solve using known differential operators (annihilators)

                                
reset() pretty_print(html("Consider the differential equation $y'''- y'' + y' - y = tan(t)$)")) # Solutions of the homogeneous problem var('t') # a3 = t # coefficient of the third derivative term # a2 = -1 # coefficient of the second derivative term # a1 = -t # coefficient of the first deriviative term # a0 = 1 # coefficient of the unknown y term a3 = t a2 = -1 a1 = -t a0 = 1 # g = 8*t*exp(t) g = 8*t^2*exp(t) Y = function('Y')(t) # let's verify DE = a3*diff(Y,t,3) + a2*diff(Y,t,2) + a1*diff(Y,t) + a0*Y - g # Here are the three solutions to the associated homogeneous equation. # y1 = t # y2 = exp(t) # y3 = exp(-t) y1 = t y2 = exp(t) y3 = exp(-t) pretty_print(DE,"= 0") pretty_print("Evaluated for Y = ",y1," is = ",a3*diff(y1,t,3) + a2*diff(y1,t,2) + a1*diff(y1,t,1) + a0*y1) pretty_print("Evaluated for Y = ",y2," is = ",a3*diff(y2,t,3) + a2*diff(y2,t,2) + a1*diff(y2,t,1) + a0*y2) pretty_print("Evaluated for Y = ",y3," is = ",a3*diff(y3,t,3) + a2*diff(y3,t,2) + a1*diff(y3,t,1) + a0*y3) # desolve(DE==g,Y) # Now, focus on a particular solution for the non-homogeneous problem using these two solutions from above u1 = function('u1')(t) u2 = function('u2')(t) u3 = function('u3')(t) y = u1*y1 + y2*u2 + y3*u3 pretty_print("Our guess for a particular solution should then be of the form") pretty_print(y) CONDITION1 = diff(u1,t)*y1 + diff(u2,t)*y2 + diff(u3,t)*y3 yp = diff(y,t)-CONDITION1 # removing terms that we are setting equal to zero pretty_print("differentiate and then removing ",CONDITION1) pretty_print("leaves y' =",yp) CONDITION2 = diff(u1,t)*diff(y1,t) + diff(u2,t)*diff(y2,t) + diff(u3,t)*diff(y3,t) ypp = diff(yp,t)-CONDITION2 pretty_print("differentiating again and removing ",CONDITION2) pretty_print("leaves y'' = ",ypp) yppp = diff(ypp,t) pretty_print("y''' =",yppp) # Now. put y, yp, ypp, adn yppp into the original non-homogeneous DE in the form left-g(t) = 0. assume(t>0) DE = (a3*yppp + a2*ypp + a1*yp + a0*y - g).simplify_full() pretty_print("Plugging this into the original DE in the form left-right=0 gives:") pretty_print(DE) # We may have to help out a bit by simplifying by hand # DE = (DE/(2*exp(-2*t))).simplify_full() # This is done by hand to simplify better pretty_print("Combining this result with the CONDITION1 and CONDITION 2 hypotheses means we have to solve the following three equations...") pretty_print(CONDITION1,"= 0") pretty_print(CONDITION2,"= 0") pretty_print(DE.expand(),"= 0") # Set up the matrix solver to solve this 3x3 ugly system M = matrix([[y1,y2,y3],[diff(y1,t),diff(y2,t),diff(y3,t)],[diff(y1,t,2),diff(y2,t,2),diff(y3,t,2)]]) show("Whole matrix = ",M) W = det(M) show("Determinant of this =",W) A1 = copy(M) A1[:,0] = vector([0,0,1]) u1p = det(A1)*g/(a3*W) A2 = copy(M) A2[:,1] = vector([0,0,1]) u2p = det(A2)*g/(a3*W) A3 = copy(M) A3[:,2] = vector([0,0,1]) u3p = det(A3)*g/(a3*W) pretty_print("u1' = ",u1p) pretty_print("u2' = ",u2p) pretty_print("u3' = ",u3p) pretty_print("and by simple integration yields:") u1 = integrate(u1p,t) u2 = integrate(u2p,t) u3 = integrate(u3p,t) pretty_print("u1 = ",u1) pretty_print("u2 = ",u2) pretty_print("u3 = ",u3) pretty_print("and therefore gives a particular solution to the non-homogeneous problem") y = u1*y1+u2*y2+u3*y3 pretty_print(y.expand()) DEleft = (a3*diff(y,t,3) + a2*diff(y,t,2) + a1*diff(y,t) + a0*y).simplify_full() pretty_print("plugged into the left side for y = ",DEleft) 
       
Consider the differential equation )

                                
                            
Consider the differential equation )

                                
# Generalize this to a fourth order non-homogeneous DE