Let's solve a 2nd order nonhomogeneous equation \( y''-y'-2y=\cos(x)\), \(y(0)=-1\), \(y'(0)=2\).
(%i1) | eq: 'diff(y,x,2)-'diff(y,x)-2*y = cos(x); |
(%i2) | gsol: ode2(eq,y,x); |
(%i3) | psol:ic2(gsol,x=0,y=-1,'diff(y,x)=2); |
Now let's verify the solution by plugging it in.
(%i4) | diff(rhs(psol),x,2)-diff(rhs(psol),x)-2*rhs(psol); |
(%i6) | factor(%o4); |
Now for a picture of the solution, noting that the \(e^{2x}\) will make the solution blow up as \(x\) grows:
(%i9) | wxplot2d(rhs(psol),[x,0,2]); |