Ordinary differential equations

I want to solve the differential equation:

dy/dx=sin(x) + y.tan(x)

Using the integrating factor method I rearrange in the required form of :

dy/dx + g(x)y = h(x) to give:

dy/dx - tan(x).y = sin(x)

The integrating factor p(x) = exp[Sg(x) dx] where in this case

g(x) = -tan(x) (S represents integration !)

But the integral of tan(x) depends on whether x is negative or positive, and since -pi/2 < x < pi/2 I'm left in a bit of a pickle as to how to proceed! If I use the two integrals for the positive and negative values and integrate between limits things get a bit messy, and I grind to a halt.

If I use the modulus sign for tan (x) and push on then I obtain the integrating factor of p(x)= cos(x).

On multiplying through the differential equation by p(x), the R.H.S. then becomes Cos(x)Sin(x). Following the proceedure for the I.F. method, I first write the l.h.s. as d/dx[p(x)y] and then integrate both sides. I now have the problem of trying to integrate Cos(x)Sin(x) and again grind to a halt.

The final answer for the initial condition y(0)= 1/2 :

y = sec x -1/2 cos x but it's the integrating factor I'm after to get there.

The general solution before applying the initial conditions is:

y = C sec x -1/2 Cos x

I have tried to go in reverse from the G.S. but didn't get far!

I apologise if it seems I'm coming on here only to take and not give to the forum, I 've had to re-register after last year, not that I was the most prolific/helpfull poster anyway.

Any help would be much appreciated.

Cheers.