Higher order differential equations, undetermined coefficients?

y''+y=2*x*sin(x)

my Yp=(Ax+B)cos(x)+(Cx+D)sin(x)

but the answers say that Yp is supposed to be (Ax^2+Bx)cos(x)+(Cx^2+Dx)sin(x)

Can anyone explain why an extra x was multiplied in Yp?

When i put Yp in the equation (y''+y), it worked fine as in i didn't get 0=2*x*sin(x)

using superposition, already found Yc, so please don't thread derail.

re: Higher order differential equations, undetermined coefficients?

Well, I'm not sure what to say. You say "using superposition, already found Yc, so please don't thread derail" but it is precisely yh that is important! You got yh= C1cos(x)+ C2sin(x), didn't you? So your "Bcos(x)" and "Dsin(x)" gives you nothing new. You also say "When i put Yp in the equation (y''+y= 2x sin(x)), it worked fine as in i didn't get 0=2*x*sin(x)" and I don't see how that is at all relevant.

If y= (Ax+ B)cos(x)+ (Cx+ D)sin(x), then y'= Acos(x)- (Ax+ B)sin(x)+ Csin(x)+ (Cx+ D)cos(x)= (Cx+A+D)cos(x)- (Ax+B- C)sin(x) and y''= Ccos(x)- (Cx+A+D)sin(x)- Asin(x)- (Ax+B-C)cos(x)=

-(Ax+ B- 2C)cos(x)- (Cx+ 2A+ D)sin(x) adding y= (Ax+B)cos(x)+ (Cx+D)sin(x) cancels those terms giving 2C cos(x)+ 2A sin(x) which has no "x" multiplying the sine or cosine and so **cannot** be equal to 2x sin(x) for any choice of A and B.

And, of course, those terms cancelled out precisely because cos(x) and sin(x) satified the associated homogenous equation.

re: Higher order differential equations, undetermined coefficients?