Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Course Project, Differential Ecuations 2018

Views: 22

Final Project, Differential Ecuations

Lic. Carlos Gámez

Jacqueline Sofía Guevara Hernández GH16006

Abelardo Ernesto Hernández Herrera HH16009

Thursday November 22th 2018

Problem 1. Solving a long initial value problem (IVP) .Solve the following initial value problem:

(D2)3(D2+9)y=(x2)ex+xsin(3x);y(0)=y(0)=y(0)=y(0)(3)=y(0)(4)=1(D-2)^3 (D^2+9)y= (x^2)e^x + xsin(3x) ; y_{(0)}=y'_{(0)}=y''_{(0)}=y^{(3)}_{(0)}=y^{(4)}_{(0)}=1

Also verify that your solution satisfies the (IVP) that is, verify that the solution i) satisfies the differential equation and that ii) satisfies the initial conditions.

Tip: Look for documentation in the textbook and the PDF in the website where a 4-th order equation is solved using a SageMath worksheet

At first it's necesary to know the characteristic equation and it will be useful to solve for "r" of:

(r2)3(r2+9)=0(r-2)^3(r^2+9)=0
r = var('r') show(solve((r-2)^3 * (r^2+9)==0,r))
[r=(3i)\displaystyle r = \left(-3 i\right), r=(3i)\displaystyle r = \left(3 i\right), r=2\displaystyle r = 2]

Having the solutions of "r", the characteristic equation will be:

yc(x)=(C1+C2x+C3x2)e2x+C4cos(3x)+C5sin(3x)y_{c(x)}=(C_{1} + C_{2}x + C_{3}x^2)e^{2x} + C_{4}cos(3x)+ C_{5}sin(3x)

Note: The characteristic equation have three constants being multiplying by e2xe^{2x} because "r" have root 2 three times.

An initial idea for the particular solution for the equation could be:

yp(x)=(Ax2+Bx+C)ex+(Dx+E)sin(3x)+(Fx+G)cos(3x)y_{p(x)}=(Ax^2+Bx+C)e^{x} +(Dx+E)sin(3x)+(Fx+G)cos(3x)

But there are repeated solutions with yc(x)y_{c(x)}, so it'll be needed to multiply the second and third term by xx to avoid duplicity.

so yp(x)y_{p(x)} has to be:

yp(x)=(Ax2+Bx+C)ex+(Dx2+Ex)sin(3x)+(Fx2+Gx)cos(3x)y_{p(x)}= (Ax^2+Bx+C)e^{x}+(Dx^2+Ex)sin(3x)+(Fx^2+Gx)cos(3x)

It's evident that the first term does not need to be multiplied by a factor. of xx because there are not repeated solutions with ycy_{c} that has: e2xe^{2x}, that is different to ypy_{p} that has: exe^{x}

and the general solution will be:

y(x)=yp(x)+yc(x)y_{(x)}=y_{p(x)}+y_{c(x)}

D=var('D') #To find the entire form of the differential operator, we expand the equation using the command: show(expand((D-2)^3*(D^2+9)))
D56D4+21D362D2+108D72\displaystyle D^{5} - 6 \, D^{4} + 21 \, D^{3} - 62 \, D^{2} + 108 \, D - 72

With the expansion of the differential operator and taking yy as ypy_{p} in the initial equation, the equation result as:

[D56D4+21D362D2+108D72]yp=(x2)ex+xsin(3x)[D^5 - 6D^4 + 21D^3 - 62D^2 + 108D - 72]y_{p}=(x^2)e^x + xsin(3x)

Where it'll be necesary to know the 1st, 2nd, 3rd, 4th and 5th derivates of ypy_{p} to find the coeficients A,B,C,D,E,F,GA,B,C,D,E,F,G.

reset() A,B,C,D,E,F,G = var('A,B,C,D,E,F,G') eq0,eq1,eq2,eq3,eq4,eq5 = var('eq0,eq1,eq2,eq3,eq4,eq5') y(x)=(A*x^2+B*x+C)*exp(x)+ (D*x^2 + E*x)*sin(3*x)+(F*x^2+G*x)*cos(3*x) #Here it's deffined the first, second, third, fourth and fifth derivates of yp eq0 = y(x) eq1 = diff(y(x),x) eq2 = diff(y(x),x,2) eq3 = diff(y(x),x,3) eq4 =diff(y(x),x,4) eq5 = diff(y(x),x,5) #Having the values of each derivated, then it's replaced the values and simplify with the original equation, notice that we equal to 0 the original eq. and assigned it in f(x) f(x) = eq5 - 6*eq4 + 21*eq3 - 62*eq2 + 108*eq1 - 72*eq0 -(x^2)*exp(x) - x*sin(3*x) show(f(x))
x2ex+276(2Dx+E)cos(3x)54(2Fx+G)cos(3x)162Dcos(3x)+524Fcos(3x)10(Ax2+Bx+C)ex+28(2Ax+B)ex50Aex54(2Dx+E)sin(3x)276(2Fx+G)sin(3x)+524Dsin(3x)+162Fsin(3x)xsin(3x)\displaystyle -x^{2} e^{x} + 276 \, {\left(2 \, D x + E\right)} \cos\left(3 \, x\right) - 54 \, {\left(2 \, F x + G\right)} \cos\left(3 \, x\right) - 162 \, D \cos\left(3 \, x\right) + 524 \, F \cos\left(3 \, x\right) - 10 \, {\left(A x^{2} + B x + C\right)} e^{x} + 28 \, {\left(2 \, A x + B\right)} e^{x} - 50 \, A e^{x} - 54 \, {\left(2 \, D x + E\right)} \sin\left(3 \, x\right) - 276 \, {\left(2 \, F x + G\right)} \sin\left(3 \, x\right) + 524 \, D \sin\left(3 \, x\right) + 162 \, F \sin\left(3 \, x\right) - x \sin\left(3 \, x\right)
To find the coefficients A,B,C,D,E,F,GA,B,C,D,E,F,G It's necessary to create a system of equations given values for xx.
R1,R2,R3,R4,R5,R6,R7=var('R1,R2,R3,R4,R5,R6,R7') # R1,R2,R3,R4,R5,R6,R7 Will be the equations of the new system created to find the values of the coefficients. R1 =f(x).subs(x=0) show(solve(R1,A))
[A=1425B15C8125D+13825E+26225F2725G\displaystyle A = \frac{14}{25} \, B - \frac{1}{5} \, C - \frac{81}{25} \, D + \frac{138}{25} \, E + \frac{262}{25} \, F - \frac{27}{25} \, G]
R2= f(x).subs(x=1) show(solve(R2,B))
[B=118(6E(46cos(3)9sin(3))+26F(16cos(3)15sin(3))+26D(15cos(3)+16sin(3))6G(9cos(3)+46sin(3))4Ae10Ceesin(3))e(1)\displaystyle B = -\frac{1}{18} \, {\left(6 \, E {\left(46 \, \cos\left(3\right) - 9 \, \sin\left(3\right)\right)} + 26 \, F {\left(16 \, \cos\left(3\right) - 15 \, \sin\left(3\right)\right)} + 26 \, D {\left(15 \, \cos\left(3\right) + 16 \, \sin\left(3\right)\right)} - 6 \, G {\left(9 \, \cos\left(3\right) + 46 \, \sin\left(3\right)\right)} - 4 \, A e - 10 \, C e - e - \sin\left(3\right)\right)} e^{\left(-1\right)}]
R3= f(x).subs(x=2) show(solve(R3,C))
[C=15(D(471cos(6)+154sin(6))+F(154cos(6)471sin(6))+3E(46cos(6)9sin(6))3G(9cos(6)+46sin(6))+11Ae2+4Be22e2sin(6))e(2)\displaystyle C = \frac{1}{5} \, {\left(D {\left(471 \, \cos\left(6\right) + 154 \, \sin\left(6\right)\right)} + F {\left(154 \, \cos\left(6\right) - 471 \, \sin\left(6\right)\right)} + 3 \, E {\left(46 \, \cos\left(6\right) - 9 \, \sin\left(6\right)\right)} - 3 \, G {\left(9 \, \cos\left(6\right) + 46 \, \sin\left(6\right)\right)} + 11 \, A e^{2} + 4 \, B e^{2} - 2 \, e^{2} - \sin\left(6\right)\right)} e^{\left(-2\right)}]
R4=f(x).subs(x=3) show(solve(R4,D))
[D=2F(100cos(9)747sin(9))+6E(46cos(9)9sin(9))6G(9cos(9)+46sin(9))+28Ae32Be310Ce39e33sin(9)2(747cos(9)+100sin(9))\displaystyle D = -\frac{2 \, F {\left(100 \, \cos\left(9\right) - 747 \, \sin\left(9\right)\right)} + 6 \, E {\left(46 \, \cos\left(9\right) - 9 \, \sin\left(9\right)\right)} - 6 \, G {\left(9 \, \cos\left(9\right) + 46 \, \sin\left(9\right)\right)} + 28 \, A e^{3} - 2 \, B e^{3} - 10 \, C e^{3} - 9 \, e^{3} - 3 \, \sin\left(9\right)}{2 \, {\left(747 \, \cos\left(9\right) + 100 \, \sin\left(9\right)\right)}}]
R5= f(x).subs(x=4) show(solve(R5,E))
[E=D(1023cos(12)+46sin(12))+F(46cos(12)1023sin(12))3G(9cos(12)+46sin(12))+7Ae46Be45Ce48e42sin(12)3(46cos(12)9sin(12))\displaystyle E = -\frac{D {\left(1023 \, \cos\left(12\right) + 46 \, \sin\left(12\right)\right)} + F {\left(46 \, \cos\left(12\right) - 1023 \, \sin\left(12\right)\right)} - 3 \, G {\left(9 \, \cos\left(12\right) + 46 \, \sin\left(12\right)\right)} + 7 \, A e^{4} - 6 \, B e^{4} - 5 \, C e^{4} - 8 \, e^{4} - 2 \, \sin\left(12\right)}{3 \, {\left(46 \, \cos\left(12\right) - 9 \, \sin\left(12\right)\right)}}]
R6=f(x).subs(x=5) show(solve(R6,F))
[F=2D(1299cos(15)8sin(15))+6E(46cos(15)9sin(15))6G(9cos(15)+46sin(15))20Ae522Be510Ce525e55sin(15)2(8cos(15)+1299sin(15))\displaystyle F = \frac{2 \, D {\left(1299 \, \cos\left(15\right) - 8 \, \sin\left(15\right)\right)} + 6 \, E {\left(46 \, \cos\left(15\right) - 9 \, \sin\left(15\right)\right)} - 6 \, G {\left(9 \, \cos\left(15\right) + 46 \, \sin\left(15\right)\right)} - 20 \, A e^{5} - 22 \, B e^{5} - 10 \, C e^{5} - 25 \, e^{5} - 5 \, \sin\left(15\right)}{2 \, {\left(8 \, \cos\left(15\right) + 1299 \, \sin\left(15\right)\right)}}]
R7= f(x).subs(x=6) show(solve(R7,G))
[G=D(1575cos(18)62sin(18))F(62cos(18)+1575sin(18))+3E(46cos(18)9sin(18))37Ae616Be65Ce618e63sin(18)3(9cos(18)+46sin(18))\displaystyle G = \frac{D {\left(1575 \, \cos\left(18\right) - 62 \, \sin\left(18\right)\right)} - F {\left(62 \, \cos\left(18\right) + 1575 \, \sin\left(18\right)\right)} + 3 \, E {\left(46 \, \cos\left(18\right) - 9 \, \sin\left(18\right)\right)} - 37 \, A e^{6} - 16 \, B e^{6} - 5 \, C e^{6} - 18 \, e^{6} - 3 \, \sin\left(18\right)}{3 \, {\left(9 \, \cos\left(18\right) + 46 \, \sin\left(18\right)\right)}}]
The equations calculated previously are those that make up our system.
reset() A,B,C,D,E,F,G=var('A,B,C,D,E,F,G') eq1= A == 14/25*B - 1/5*C - 81/25*D + 138/25*E + 262/25*F - 27/25*G eq2= B == -1/18*(6*E*(46*cos(3) - 9*sin(3)) + 26*F*(16*cos(3) - 15*sin(3)) + 26*D*(15*cos(3) + 16*sin(3)) - 6*G*(9*cos(3) + 46*sin(3)) - 4*A*e - 10*C*e - e - sin(3))*e^(-1) eq3= C == 1/5*(D*(471*cos(6) + 154*sin(6)) + F*(154*cos(6) - 471*sin(6)) + 3*E*(46*cos(6) - 9*sin(6)) - 3*G*(9*cos(6) + 46*sin(6)) + 11*A*e^2 + 4*B*e^2 - 2*e^2 - sin(6))*e^(-2) eq4= D == -1/2*(2*F*(100*cos(9) - 747*sin(9)) + 6*E*(46*cos(9) - 9*sin(9)) - 6*G*(9*cos(9) + 46*sin(9)) + 28*A*e^3 - 2*B*e^3 - 10*C*e^3 - 9*e^3 - 3*sin(9))/(747*cos(9) + 100*sin(9)) eq5= E == -1/3*(D*(1023*cos(12) + 46*sin(12)) + F*(46*cos(12) - 1023*sin(12)) - 3*G*(9*cos(12) + 46*sin(12)) + 7*A*e^4 - 6*B*e^4 - 5*C*e^4 - 8*e^4 - 2*sin(12))/(46*cos(12) - 9*sin(12)) eq6= F == 1/2*(2*D*(1299*cos(15) - 8*sin(15)) + 6*E*(46*cos(15) - 9*sin(15)) - 6*G*(9*cos(15) + 46*sin(15)) - 20*A*e^5 - 22*B*e^5 - 10*C*e^5 - 25*e^5 - 5*sin(15))/(8*cos(15) + 1299*sin(15)) eq7= G == 1/3*(D*(1575*cos(18) - 62*sin(18)) - F*(62*cos(18) + 1575*sin(18)) + 3*E*(46*cos(18) - 9*sin(18)) - 37*A*e^6 - 16*B*e^6 - 5*C*e^6 - 18*e^6 - 3*sin(18))/(9*cos(18) + 46*sin(18)) show(solve([eq1,eq2,eq3,eq4,eq5,eq6,eq7],A,B,C,D,E,F,G))
[[A=(110)\displaystyle A = \left(-\frac{1}{10}\right), B=(1425)\displaystyle B = \left(-\frac{14}{25}\right), C=(267250)\displaystyle C = \left(-\frac{267}{250}\right), D=(38788)\displaystyle D = \left(-\frac{3}{8788}\right), E=(1379514098)\displaystyle E = \left(\frac{1379}{514098}\right), F=(2313182)\displaystyle F = \left(-\frac{23}{13182}\right), G=(251114244)\displaystyle G = \left(-\frac{251}{114244}\right)]]

At this point, it's necessary verify if the calculated coefficients A,B,C,D,E,F,GA, B, C, D, E, F, G satisfies as a solution of ypy_{p}

reset() A=-(1/10) B=-(14/25) C= -(267/250) D= -(3/8788) E= (1379/514098) F= -(23/13182) G= -(251/114244) y(x)=(A*x^2+B*x+C)*exp(x)+ (D*x^2 + E*x)*sin(3*x)+(F*x^2+G*x)*cos(3*x) eq0 = y(x) eq1 = diff(y(x),x) eq2 = diff(y(x),x,2) eq3 = diff(y(x),x,3) eq4 =diff(y(x),x,4) eq5 = diff(y(x),x,5) F(x) = eq5 - 6*eq4 + 21*eq3 - 62*eq2 + 108*eq1 - 72*eq0 W(x) = (x^2)*exp(x)+x*sin(3*x) #This is taken of the original Eq. # If f(x) - W(x) is equal to 0 the coefficients A,B,C,D,E,F,G are correct show(F(x).simplify_full())
x2ex+(4xcos(x)2x)sin(x)\displaystyle x^{2} e^{x} + {\left(4 \, x \cos\left(x\right)^{2} - x\right)} \sin\left(x\right)
show(W(x).simplify_full())
x2ex+(4xcos(x)2x)sin(x)\displaystyle x^{2} e^{x} + {\left(4 \, x \cos\left(x\right)^{2} - x\right)} \sin\left(x\right)
h(x) = F(x) - W(x) show(h(x).simplify_full())
0\displaystyle 0
As it was said at the beggining of the problem the characteristic equations is:
yc(x)=(C1+C2x+C3x2)e2x+C4cos(3x)+C5sin(3x)y_{c(x)}=(C_{1} + C_{2}x + C_{3}x^2)e^{2x} + C_{4}cos(3x)+ C_{5}sin(3x)
Knowing the general solution will be the sum of both solutions ypy_{p} and ycy_{c} and having the IVP:
y(0)=y(0)=y(0)=y(0)(3)=y(0)(4)=1y_{(0)}=y'_{(0)}=y''_{(0)}=y^{(3)}_{(0)}=y^{(4)}_{(0)}=1

We could calculate de coefficients C1,C2,C3,C4,C5C_{1} , C_{2} , C_{3} , C_{4} , C_{5}

reset() C1,C2,C3,C4,C5 = var('C1,C2,C3,C4,C5') y,yp,yc = var('y,yp,yc') A=-(1/10) B=-(14/25) C= -(267/250) D= -(3/8788) E= (1379/514098) F= -(23/13182) G= -(251/114244) yp(x)= (A*x^2+B*x+C)*exp(x)+ (D*x^2 + E*x)*sin(3*x)+(F*x^2+G*x)*cos(3*x) yc(x) =(C1 + C2*x + C3*x^2)*exp(2*x) + C4*cos(3*x) + C5*sin(3*x) y(x)= yp(x) + yc(x) #This is the general solution of de equations show(y(x))
1342732(598x2+753x)cos(3x)+C4cos(3x)+(C3x2+C2x+C1)e(2x)1250(25x2+140x+267)ex11028196(351x22758x)sin(3x)+C5sin(3x)\displaystyle -\frac{1}{342732} \, {\left(598 \, x^{2} + 753 \, x\right)} \cos\left(3 \, x\right) + C_{4} \cos\left(3 \, x\right) + {\left(C_{3} x^{2} + C_{2} x + C_{1}\right)} e^{\left(2 \, x\right)} - \frac{1}{250} \, {\left(25 \, x^{2} + 140 \, x + 267\right)} e^{x} - \frac{1}{1028196} \, {\left(351 \, x^{2} - 2758 \, x\right)} \sin\left(3 \, x\right) + C_{5} \sin\left(3 \, x\right)
r,r1,r2,r3,r4 = var('r,r1,r2,r3,r4') #Here r1,r2,r3,r4,r5 will be the equations of the new system to find C1,C2,C3,C4,C5 # All this equations are equal to 1 because of the IVP r1 = diff(y(x),x).subs(x=0) show(r1)
2C1+C2+3C52328002914280500\displaystyle 2 \, C_{1} + C_{2} + 3 \, C_{5} - \frac{23280029}{14280500}
r2= diff(y(x),x,2).subs(x=0) show(r2)
4C1+4C2+2C39C4169609177140250\displaystyle 4 \, C_{1} + 4 \, C_{2} + 2 \, C_{3} - 9 \, C_{4} - \frac{16960917}{7140250}
r3= diff(y(x),x,3).subs(x=0) show(r3)
8C1+12C2+12C327C54705173914280500\displaystyle 8 \, C_{1} + 12 \, C_{2} + 12 \, C_{3} - 27 \, C_{5} - \frac{47051739}{14280500}
r4= diff(y(x),x,4).subs(x=0) show(r4)
16C1+32C2+48C3+81C4329112477140250\displaystyle 16 \, C_{1} + 32 \, C_{2} + 48 \, C_{3} + 81 \, C_{4} - \frac{32911247}{7140250}
r=y(x).subs(x=0) show(r)
C1+C4267250\displaystyle C_{1} + C_{4} - \frac{267}{250}
reset() C1,C2,C3,C4,C5 = var('C1,C2,C3,C4,C5') eq1= 2*C1 + C2 + 3*C5 - 23280029/14280500 ==1 eq2= 4*C1 + 4*C2 + 2*C3 - 9*C4 - 16960917/7140250 ==1 eq3= 8*C1 + 12*C2 + 12*C3 - 27*C5 - 47051739/14280500 ==1 eq4= 16*C1 + 32*C2 + 48*C3 + 81*C4 - 32911247/7140250 ==1 eq5= C1 + C4 - 267/250==1 show(solve([eq1,eq2,eq3,eq4,eq5],C1,C2,C3,C4,C5))
[[C1=(774782371293)\displaystyle C_{1} = \left(\frac{774782}{371293}\right), C2=(4333028561)\displaystyle C_{2} = \left(-\frac{43330}{28561}\right), C3=(10202197)\displaystyle C_{3} = \left(\frac{1020}{2197}\right), C4=(173701992823250)\displaystyle C_{4} = \left(-\frac{1737019}{92823250}\right), C5=(4850123556939500)\displaystyle C_{5} = \left(-\frac{4850123}{556939500}\right)]]
reset() # To verify if C1,C2,C3,C4,C5 are the correct coefficients of the general solution is needed to apply the the differential operator and see if them satisfy the equality y,yp,yc = var('y,yp,yc') C1=774782/371293 C2=-(43330/28561) C3=(1020/2197) C4=-(1737019/92823250) C5 = -(4850123/556939500) A=-(1/10) B=-(14/25) C= -(267/250) D= -(3/8788) E= (1379/514098) F= -(23/13182) G= -(251/114244) yp(x)= (A*x^2+B*x+C)*exp(x)+ (D*x^2 + E*x)*sin(3*x)+(F*x^2+G*x)*cos(3*x) yc(x) =(C1 + C2*x + C3*x^2)*exp(2*x) + C4*cos(3*x) + C5*sin(3*x) y(x)= yp(x) + yc(x) show(y(x).simplify_full())
1139234875(971750x2+1223625x+10422114)cos(x)3+1185646500(971750x2+1223625x+10422114)cos(x)+2371293(86190x2281645x+387391)e(2x)1250(25x2+140x+267)ex11670818500(4(570375x24481750x+14550369)cos(x)2570375x2+4481750x14550369)sin(x)\displaystyle -\frac{1}{139234875} \, {\left(971750 \, x^{2} + 1223625 \, x + 10422114\right)} \cos\left(x\right)^{3} + \frac{1}{185646500} \, {\left(971750 \, x^{2} + 1223625 \, x + 10422114\right)} \cos\left(x\right) + \frac{2}{371293} \, {\left(86190 \, x^{2} - 281645 \, x + 387391\right)} e^{\left(2 \, x\right)} - \frac{1}{250} \, {\left(25 \, x^{2} + 140 \, x + 267\right)} e^{x} - \frac{1}{1670818500} \, {\left(4 \, {\left(570375 \, x^{2} - 4481750 \, x + 14550369\right)} \cos\left(x\right)^{2} - 570375 \, x^{2} + 4481750 \, x - 14550369\right)} \sin\left(x\right)
eq0 = y(x) eq1 = diff(y(x),x) eq2 = diff(y(x),x,2) eq3 = diff(y(x),x,3) eq4 =diff(y(x),x,4) eq5 = diff(y(x),x,5) f(x) = eq5 - 6*eq4 + 21*eq3 - 62*eq2 + 108*eq1 - 72*eq0 show(f(x).simplify_full())
72C10x10+72(15C10C9)x936(155C10+2C827C9)x8+72(210C10C7+12C862C9)x74(7560C10+18C6189C7+868C82646C9)x6+12(2520C106C5+54C6217C7+588C81512C9)x56(12C490C5+310C6735C7+1680C82520C9)x48(9C354C4+155C5315C6+630C7840C8)x312(6C227C3+62C4105C5+180C6210C7)x212(6C118C2+31C342C4+60C560C6+6)x+108C1124C2+126C3144C4+120C5+108\displaystyle -72 \, C_{10} x^{10} + 72 \, {\left(15 \, C_{10} - C_{9}\right)} x^{9} - 36 \, {\left(155 \, C_{10} + 2 \, C_{8} - 27 \, C_{9}\right)} x^{8} + 72 \, {\left(210 \, C_{10} - C_{7} + 12 \, C_{8} - 62 \, C_{9}\right)} x^{7} - 4 \, {\left(7560 \, C_{10} + 18 \, C_{6} - 189 \, C_{7} + 868 \, C_{8} - 2646 \, C_{9}\right)} x^{6} + 12 \, {\left(2520 \, C_{10} - 6 \, C_{5} + 54 \, C_{6} - 217 \, C_{7} + 588 \, C_{8} - 1512 \, C_{9}\right)} x^{5} - 6 \, {\left(12 \, C_{4} - 90 \, C_{5} + 310 \, C_{6} - 735 \, C_{7} + 1680 \, C_{8} - 2520 \, C_{9}\right)} x^{4} - 8 \, {\left(9 \, C_{3} - 54 \, C_{4} + 155 \, C_{5} - 315 \, C_{6} + 630 \, C_{7} - 840 \, C_{8}\right)} x^{3} - 12 \, {\left(6 \, C_{2} - 27 \, C_{3} + 62 \, C_{4} - 105 \, C_{5} + 180 \, C_{6} - 210 \, C_{7}\right)} x^{2} - 12 \, {\left(6 \, C_{1} - 18 \, C_{2} + 31 \, C_{3} - 42 \, C_{4} + 60 \, C_{5} - 60 \, C_{6} + 6\right)} x + 108 \, C_{1} - 124 \, C_{2} + 126 \, C_{3} - 144 \, C_{4} + 120 \, C_{5} + 108
h(x)=(x^2)*exp(x)+ x*sin(3*x) show(h(x).simplify_full())
x2ex+(4xcos(x)2x)sin(x)\displaystyle x^{2} e^{x} + {\left(4 \, x \cos\left(x\right)^{2} - x\right)} \sin\left(x\right)
#If g(x) it's equal to 0, it affirms that the find general solution y(x) it's correct. g(x) = f(x) - h(x) g(x).simplify_full()
0

Now it's necessary to see if the y(x)y_{(x)} satisfies the initial conditios, to do that we have to evaluate in 0 the corresponding derivates

#If the answer of the evaluation is 1, it satisfies the initial conditions, the same way will be for the second, third and fourth derivates of y(x) r,r1,r2,r3 = var('r,r1,r2,r3') r=diff(y(x),x).subs(x=0) r.simplify_full()
1
r1=diff(y(x),x,2).subs(x=0) r1.simplify_full()
1
r2=diff(y(x),x,3).subs(x=0) r2.simplify_full()
1
r3=diff(y(x),x,4).subs(x=0) r3.simplify_full()
1
Because the answers after to the evaluation were 1, y(x)y(x) satisfies the initial conditions.
So the general solution of the equation is:

y(x)=(1/342732)(598x2+753x)cos(3x)+(2/371293)(86190x2281645x+387391)e(2x)(1/250)(25x2+140x+267)ex(1/1028196)(351x22758x)sin(3x)(1737019/92823250)cos(3x)(4850123/556939500)sin(3x)y_{(x)}=(-1/342732)(598x^2 + 753x)cos(3x) + (2/371293)(86190x^2 - 281645x + 387391)e^{(2x)} - (1/250)(25x^2 + 140x + 267)e^x - (1/1028196)(351x^2 - 2758x)sin(3x) - (1737019/92823250)cos(3x) - (4850123/556939500)sin(3x)

And appliying the command:.Simplify_full() to simplify the equation, y(x)y_{(x)} result as:

y(x)=(1/139234875)(971750x2+1223625x+10422114)(cos(x))3+(1/185646500)(971750x2+1223625x+10422114)cos(x)+(2/371293)(86190x2281645x+387391)e(2x)(1/250)(25x2+140x+267)ex(1/1670818500)(4(570375x24481750x+14550369)(cos(x))2570375x2+4481750x14550369)sin(x)y_{(x)}=(-1/139234875)(971750x^2 + 1223625x + 10422114)(cos(x))^3 + (1/185646500)(971750x^2 + 1223625x + 10422114)cos(x) + (2/371293)(86190x^2 - 281645x + 387391)e^{(2x)} - (1/250)(25x^2 + 140x + 267)e^x - (1/1670818500)(4(570375x^2 - 4481750x + 14550369)(cos(x))^2 - 570375x^2 + 4481750x - 14550369)sin(x)

Problem 2. Power Series.

Find the first 6 nonzero terms in each of two linearly independent solutions of the form Cnxn\sum C_{n}x^{n}:

xy+sin(x)y+xy=0.xy^{\prime \prime}+\sin \left(x\right)y^{\prime}+xy=0.

In this problem we have a second order linear homogeneous differential equation, so to find the two solutions linearly independent we need to take a ordinary point x=ax=a such that the solution is:

y(x)=n=0Cn(xa)ny\left(x\right)=\sum_{n=0}^{\infty}C_{n}\left(x-a\right)^{n}

For simplicity we take a=0a=0.

To check that x=0x=0 is an ordinary point we can rewrite the differential equation as:

y+sin(x)xy+y=0.y^{\prime \prime}+\frac{\sin \left(x\right)}{x}y^{\prime}+y=0.

Now with P(x)=sin(x)xP\left(x\right)=\frac{\sin \left(x\right)}{x} and Q(x)=1Q\left(x\right)=1, we have to show that P(x)P\left(x\right) and Q(x)Q\left(x\right) are analytical in x=0x=0 because it's a constant. With x=0x=0 it is evident that Q(x)Q\left(x\right) is analytic, but for P(x)P\left(x\right) we have:

limx0P(x)=1\lim_{x \rightarrow 0}P\left(x\right)=1

And x=0x=0 is an ordinary point. Since we know that x = 0 is an ordinary point we can proceed with its solution.

Since we need the first six nonzero terms, we will use the first eleven terms ( from n=0n=0 to n=10n=10 ) of the solution Cnxn\sum C_{n}x^{n}.

y(x)=c0+c1x+c2x2+c3x3+c4x4+c5x5+c6x6+c7x7+c8x8+c9x9+c10x10y\left(x\right)=c_0+c_1x+c_2x^2+c_3x^3+c_4x^4+c_5x^5+c_6x^6+c_7x^7+c_8x^8+c_9x^9+c_{10}x^{10}.
reset() x,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10 = var('x,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10') # The y(x) solution is defined as the first terms of the power series (from n=0 to n=10). y = C0+C1*x+C2*x^2+C3*x^3+C4*x^4+C5*x^5+C6*x^6+C7*x^7+C8*x^8+C9*x^9+C10*x^10 # Now this "y" is added to the differential equation (de). The "expand" command is used so that the coefficients of each x are easy to identify. De = expand(x*diff(y,x,2)+(taylor(sin(x),x,0,10))*diff(y,x)+x*y) %md The differential equation with our $y\left(x\right)$ is:

The differential equation with our y(x)y\left(x\right) is:

show(De)
136288C10x18+140320C9x171504C10x16+145360C8x16+151840C7x151560C9x15+112C10x14+160480C6x141630C8x14+172576C5x131720C7x13+340C9x1353C10x12+190720C4x121840C6x12+115C8x12+C10x11+1120960C3x1111008C5x11+7120C7x1132C9x11+10C10x10+1181440C2x1011260C4x10+120C6x1043C8x10+C9x10+1362880C1x9+90C10x911680C3x9+124C5x976C7x9+C8x9+9C9x912520C2x8+130C4x8C6x8+C7x8+8C8x8+72C9x815040C1x7+140C3x756C5x7+C6x7+7C7x7+56C8x7+160C2x623C4x6+C5x6+6C6x6+42C7x6+1120C1x512C3x5+C4x5+5C5x5+30C6x513C2x4+C3x4+4C4x4+20C5x416C1x3+C2x3+3C3x3+12C4x3+C1x2+2C2x2+6C3x2+C0x+C1x+2C2x\displaystyle \frac{1}{36288} \, C_{10} x^{18} + \frac{1}{40320} \, C_{9} x^{17} - \frac{1}{504} \, C_{10} x^{16} + \frac{1}{45360} \, C_{8} x^{16} + \frac{1}{51840} \, C_{7} x^{15} - \frac{1}{560} \, C_{9} x^{15} + \frac{1}{12} \, C_{10} x^{14} + \frac{1}{60480} \, C_{6} x^{14} - \frac{1}{630} \, C_{8} x^{14} + \frac{1}{72576} \, C_{5} x^{13} - \frac{1}{720} \, C_{7} x^{13} + \frac{3}{40} \, C_{9} x^{13} - \frac{5}{3} \, C_{10} x^{12} + \frac{1}{90720} \, C_{4} x^{12} - \frac{1}{840} \, C_{6} x^{12} + \frac{1}{15} \, C_{8} x^{12} + C_{10} x^{11} + \frac{1}{120960} \, C_{3} x^{11} - \frac{1}{1008} \, C_{5} x^{11} + \frac{7}{120} \, C_{7} x^{11} - \frac{3}{2} \, C_{9} x^{11} + 10 \, C_{10} x^{10} + \frac{1}{181440} \, C_{2} x^{10} - \frac{1}{1260} \, C_{4} x^{10} + \frac{1}{20} \, C_{6} x^{10} - \frac{4}{3} \, C_{8} x^{10} + C_{9} x^{10} + \frac{1}{362880} \, C_{1} x^{9} + 90 \, C_{10} x^{9} - \frac{1}{1680} \, C_{3} x^{9} + \frac{1}{24} \, C_{5} x^{9} - \frac{7}{6} \, C_{7} x^{9} + C_{8} x^{9} + 9 \, C_{9} x^{9} - \frac{1}{2520} \, C_{2} x^{8} + \frac{1}{30} \, C_{4} x^{8} - C_{6} x^{8} + C_{7} x^{8} + 8 \, C_{8} x^{8} + 72 \, C_{9} x^{8} - \frac{1}{5040} \, C_{1} x^{7} + \frac{1}{40} \, C_{3} x^{7} - \frac{5}{6} \, C_{5} x^{7} + C_{6} x^{7} + 7 \, C_{7} x^{7} + 56 \, C_{8} x^{7} + \frac{1}{60} \, C_{2} x^{6} - \frac{2}{3} \, C_{4} x^{6} + C_{5} x^{6} + 6 \, C_{6} x^{6} + 42 \, C_{7} x^{6} + \frac{1}{120} \, C_{1} x^{5} - \frac{1}{2} \, C_{3} x^{5} + C_{4} x^{5} + 5 \, C_{5} x^{5} + 30 \, C_{6} x^{5} - \frac{1}{3} \, C_{2} x^{4} + C_{3} x^{4} + 4 \, C_{4} x^{4} + 20 \, C_{5} x^{4} - \frac{1}{6} \, C_{1} x^{3} + C_{2} x^{3} + 3 \, C_{3} x^{3} + 12 \, C_{4} x^{3} + C_{1} x^{2} + 2 \, C_{2} x^{2} + 6 \, C_{3} x^{2} + C_{0} x + C_{1} x + 2 \, C_{2} x

To find the values of C0,C1,C2,C3,C4,C5,C6,C7,C8,C9C_0,C_1,C_2,C_3,C_4,C_5,C_6,C_7,C_8,C_9 and C10C_{10} we rely on the principle of identity. Thanks to this we have a system of equations that will allow us to know the terms we are looking for.

Two cases are evaluated, the first where C0=0C_0=0 and C1=1C_1=1 and the second where C0=1C_0=1 and C1=0C_1=0. These values are assigned to C0C_0 and C1C_1 because they ensure that the solution y(x)y\left(x\right) that is found is linearly independent.

# Now with the help of the "coefficient" command, we can find the coefficients of x^n in "de". For the coefficients of x^n, a letter is assigned to facilitate its future use. # The coefficient of x^0 are not taken into account since they are zero. A = De.coefficient(x) B = De.coefficient(x^2) C = De.coefficient(x^3) D = De.coefficient(x^4) E = De.coefficient(x^5) F = De.coefficient(x^6) G = De.coefficient(x^7) H = De.coefficient(x^8) I = De.coefficient(x^9) J = De.coefficient(x^10) K = De.coefficient(x^11) L = De.coefficient(x^12) M = De.coefficient(x^13) N = De.coefficient(x^14) O = De.coefficient(x^15) P = De.coefficient(x^16) Q = De.coefficient(x^17) R = De.coefficient(x^18) # The coefficients are equated to zero, so we get a system of equations. Since there are 11 unknowns, we only need 11 equations to solve the system. eq1 = C0==0 # For the first case we take c0=0 and c1=1. eq2 = C1==1 eq3 = A==0 eq4 = B==0 eq5 = C==0 eq6 = D==0 eq7 = E==0 eq8 = F==0 eq9 = G==0 eq10 = H==0 eq11 = I==0 # The equations "eq12" and "eq13" will be used for the second case. eq12 = C0==1 # In the second case, c0=1 and c1=0. eq13 = C1==0

For the first case, c0=0c_0=0 and c1=1c_1=1, the values of the coefficients are:

# Now the system of equations is solved for the first case. show(solve([eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11],C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10)) # We got more nonzero terms than we needed in both cases, but we will only use the first six terms for the solution.
[[C0=0\displaystyle C_{0} = 0, C1=1\displaystyle C_{1} = 1, C2=(12)\displaystyle C_{2} = \left(-\frac{1}{2}\right), C3=0\displaystyle C_{3} = 0, C4=(118)\displaystyle C_{4} = \left(\frac{1}{18}\right), C5=(7360)\displaystyle C_{5} = \left(-\frac{7}{360}\right), C6=(1900)\displaystyle C_{6} = \left(\frac{1}{900}\right), C7=(157113400)\displaystyle C_{7} = \left(\frac{157}{113400}\right), C8=(1939690)\displaystyle C_{8} = \left(-\frac{19}{39690}\right), C9=(79738102400)\displaystyle C_{9} = \left(\frac{797}{38102400}\right), C10=(92330618000)\displaystyle C_{10} = \left(\frac{923}{30618000}\right)]]

Therefore the first linearly independent solutions is:

y1(x)=x12x2+118x47360x5+1900x6+157113400x7+O(x8).y_1\left(x\right)=x-\frac{1}{2}x^2+\frac{1}{18}x^4-\frac{7}{360}x^5+\frac{1}{900}x^6+\frac{157}{113400}x^7+O\left(x^8\right).

For the second case, c0=1c_0=1 and c1=0c_1=0, the values of the coefficients are:

# The system of equations is solved for the second case. Exchanging the equations "eq1" and "eq2" by "eq12" and "eq13" in the system of equations used in the first case. show(solve([eq12,eq13,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11],C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10))
[[C0=1\displaystyle C_{0} = 1, C1=0\displaystyle C_{1} = 0, C2=(12)\displaystyle C_{2} = \left(-\frac{1}{2}\right), C3=(16)\displaystyle C_{3} = \left(\frac{1}{6}\right), C4=0\displaystyle C_{4} = 0, C5=(160)\displaystyle C_{5} = \left(-\frac{1}{60}\right), C6=(1180)\displaystyle C_{6} = \left(\frac{1}{180}\right), C7=(15040)\displaystyle C_{7} = \left(-\frac{1}{5040}\right), C8=(12520)\displaystyle C_{8} = \left(-\frac{1}{2520}\right), C9=(1190720)\displaystyle C_{9} = \left(\frac{11}{90720}\right), C10=(1680400)\displaystyle C_{10} = \left(-\frac{1}{680400}\right)]]

And the second linearly independent solutions is:

y2(x)=112x2+16x3160x5+1180x615040x7+O(x8).y_2\left(x\right)=1-\frac{1}{2}x^2+\frac{1}{6}x^3-\frac{1}{60}x^5+\frac{1}{180}x^6-\frac{1}{5040}x^7+O\left(x^8\right).