Solving first order initial value problem numerically

I want to find the solution $y_0(t)$ of the linear first-order ordinary differential equation

$$y'-(1/t)y= t \text{sin}(t)$$

satisfying the initial condition $y(\pi /2)=0$. I know how to do this analytically using the integrating factor and such, but how do I solve for this numerically (and what exactly does that mean anyway)?

Thanks for any input.

• numerically means picking a scheme i.e. shooting method to solve the ode by numerically stepping through time to get a solution that matches the conditions? does any of what I just said make sense? – Chinny84 Mar 26 '15 at 16:53
• – jm324354 Mar 26 '15 at 16:55
• so I am basically guessing the solution, what you said makes sense, but I still don't understand where to start. – Akaichan Mar 26 '15 at 16:55
• – LutzL Mar 26 '15 at 17:29

$$y'-(1/t)y= t \text{sin}(t)$$

Let $y(t)=tz(t),y'(t)=z(t)+tz'(t)$, So: $$z+tz'-z=t\sin t\implies z'=\sin t\implies z=-\cos t+\color{grey}{\rm C}$$ So: $$y=\color{grey}{\rm C}t-t\cos t$$ Now: $$y(\pi/2)=\color{grey}{\rm C}\pi/2-(\pi/2)(0)=0\implies \color{grey}{\rm C}=0$$ So: $$y(t)=-t\cos t$$

• I think @Akaichan is asking for a numerical solution. – KittyL Mar 27 '15 at 10:48
• @KittyL he says "I want to find the solution y0(t) of the linear first-order ordinary differential equation" and if he knows the function he can get all values of y for any t! – RE60K Mar 27 '15 at 11:19
• He also says "I know how to do this analytically using the integrating factor and such, but how do I solve for this numerically (and what exactly does that mean anyway)". So he knows the function and he can get all values of y. However he just wanted to know what it means by "solving it numerically". – KittyL Mar 27 '15 at 12:31
• Oh @KittyL you were right. – RE60K Mar 27 '15 at 12:32

I do not understand your question. Is it like:

" I know the analytical solution and how to put in required boundary condition. How do I impose boundary conditions into a numerical solution, because I have nowhere to plug them in and myself verify / check up answer like in the analytical situation? "

If that is your question, the answer is:

You don't need to do all that. You choose RK4 or whatever method, simply plug in $y(\pi/2) = 0$ and press the RUN button.

Else I cannot say.