solve the differential equation y y cosxSolutionFirst we s
solve the differential equation y\'\' - y = cosx
Solution
First we solve the homogeneous ODE
y\'\'-y=0
y\'\'=y
General solution to this is
y=A sin(x)+B cos(x)
Now we need to find particular solution to get general solution to given inhomogeneous ODE
We can guess this based on the inhomogeneous part which is cos(x)
Usually we would take the guess: R cos(x)+S sin(x)
But here cos(x) is already a solution so the guess becomes
yp=x(R cos(x)+S sin(x))=xv ,v=R cos(x)+S sin(x)
yp\'=v+xv\'
yp\'\'=2v\'+xv\'\'
Substituting gives
2v\'+xv\'\'-xv=cos(x)
Here we use the fact that v is a solution to homogeneous ode hence:xv\'\'-xv=0
So,
2v\'=cos(x)
-2R sin(x)+2S cos(x)=cos(x)
So, R=0,S=1/2
Hence general solution is
y=A sin(x)+B cos(x)+sin(x)/2

