# Thread: initial value problem

1. ## initial value problem

I'm in a numerical analysis class and I'm trying to approximate an initial value problem. I get the approximation using Forward Euler and other methods, but I'm not sure what the true answer is. I haven't done ODE's in a while.

Does anyone know how to solve the problem?
y'(t) = y - t^2 + 1, t in [0,2]
y(0) = 2

Thanks for any help in advance.

2. Originally Posted by PvtBillPilgrim
I'm in a numerical analysis class and I'm trying to approximate an initial value problem. I get the approximation using Forward Euler and other methods, but I'm not sure what the true answer is. I haven't done ODE's in a while.

Does anyone know how to solve the problem?
y'(t) = y - t^2 + 1, t in [0,2]
y(0) = 2

Thanks for any help in advance.
This is the same thing as $\frac{\,dy}{\,dt}-y=1-t^2$

Now apply the method of the integrating factor, since this equation is linear.

Thus, our integrating factor is $\varrho=e^{-\int\,dt}=e^{-t}$

Thus, we now have $\frac{d}{\,dt}\left[e^{-t}y\right]=e^{-t}-t^{2}e^{-t}$

Now, integrate both sides:

$e^{-t}y=-e^{-t}-\int e^{-t}t^2\,dt$

[I leave you to evaluate the integral on the right side of the equation. You will need to apply integration by parts twice.]

Thus, $y=-e^t\cdot\left[\int e^{-t}t^2\,dt\right]+C$

Then apply the initial condition $y(0)=2$ to find $C$.

Can you take it from here?

--Chris