Find the solution of the given initial value problem for ty'+2y=t^2-t+1, y(1)=1/2, t>0.

Again, the integrating factor comes to use.

t dy/dt + 2y = t^{2} - t + 1

dy/dt + 2y/t = = t - 1 + 1/t

μ dy/dt + 2μy/t = μ(t - 1 + 1/t)

Let dμ/dt = 2μ/t.

μ dy/dt + y dμ/dt = μ(t - 1 + 1/t)

μy = ∫ μ(t - 1 + 1/t) dt

y = (1/μ) ∫ μ(t - 1 + 1/t) dt

Find μ from it's equation.

dμ/dt = 2μ/t

∫ dμ/μ = ∫ 2dt/t

ln |μ| = 2 ln |t| + C = ln t^{2} + C

μ = At^{2}

Plug μ in.

y = (1/(At^{2})) ∫ At^{2}(t - 1 + 1/t) dt

y = (1/t^{2}) ∫ (t^{3} - t^{2} + t) dt

y = (t^{4}/4 - t^{3}/3 + t^{2}/2 + C) / t^{2}

y = t^{2}/4 - t/3 + 1/2 + C/t^{2}

Before using the initial value, let's check the general solution.

t * (d/dt)(t^{2}/4 - t/3 + 1/2 + C/t^{2}) + 2(t^{2}/4 - t/3 + 1/2 + C/t^{2})

= t * (t/2 - 1/3 + 0 - 2C/t^{3}) + 2(t^{2}/4 - t/3 + 1/2 + C/t^{2})

= t^{2}/2 - t/3 - 2C/t^{2} + t^{2}/2 - 2t/3 + 1 + 2C/t^{2}

= t^{2} - t + 1

It checks out.

Now since we have that y = 1/2 at t = 1, plug it in to the general solution to find C.

1/2 = 1^{2}/4 - 1/3 + 1/2 + C/1^{2}

C = 1/2 - 1/4 + 1/3 - 1/2 = 1/12

So the desired solution is y = t^{2}/4 - t/3 + 1/2 + 1/(12t^{2}).