Final step in solving differential equation

I can't figure out the last step of the following question:

Show that the general solution of the differential equation: $dy/dx + y\tan x=1$ is given by: $y\sec x=\ln(\sec x + \tan x) + C$

This is what I've worked out so far:

To make things easier let $u(x)=\exp(\int\! \tan(x)\,\mathrm dx)=\sec(x)$

Multyply both sides by $u(x): \sec(x)\frac {dy(x)} {dx} + {\sec(x)}{\tan(x)}y(x)=\sec(x)$

Then substitute $\sec(x)\tan(x)= \frac {d\sec(x)} {dx}$

$\sec(x) \dfrac {dy(x)}{dx}+ \dfrac{d \sec(x)} {dx}y(x)= \sec(x)$

Using the reverse product rule of the LHS:

$\displaystyle\frac d {dx} (\sec(x)y(x))dx= \int \sec(x)\,dx$

then integrating both sides with respect to x $\int \frac d {dx} (\sec(x)y(x))dx= \int \sec(x)dx$

Therefore: $\sec(x)y= -\log(\cos(\tfrac x 2)- \sin(\tfrac x 2))+\log(\cos(\tfrac x 2) + \sin(\tfrac x 2)) + C$

Where do I go from here to find the solution (given in the question)? Thanks in advance!

-
I have edited your post to format the equations with $\LaTeX$. There were some ambiguities in the reverse product step, as well as integrating both sides. You have submitted a few questions now, so I would suggest learning some basic $\LaTeX$ commands. –  process91 Sep 2 '12 at 22:31

You have a slightly unusual but essentially correct version of an integral of $\sec x$. There is an issue of missing absolute value signs, which are also missing in the problem's version, which should have been $\log(|\sec x+\tan x|$).

To see it is (apart from negativity issues) the same as the standard one used in the problem, we show that $$\frac{\cos(x/2)+\sin(x/2)}{\cos(x/2)-\sin(x/2)}=\sec x+\tan x.$$ To see that this is enough, note that $\log a-\log b=\log(a/b)$.

Multiply top and bottom by $\cos(x/2)+\sin(x/2)$.

At the bottom we get $\cos^2(x/2)-\sin^2(x/2)$, which by a double angle formula is equal to $\cos x$. On top we get $\cos^2(x/2)+\sin^2(x/2)+2\cos(x/2)\sin(x/2)$, which is $1+\sin x$.

So we end up with $\frac{1+\sin x}{\cos x}$, which is $\sec x+\tan x$.

-
Thank you! The absolute value signs aren't present in this question (not a typo/error), but this doesn't impact the question does it? –  Enrico S Sep 2 '12 at 23:10
Yes it does impact the question. When $\sec x+\tan x$ is negative, there is a problem with taking the logarithm! But in fact there is a solution when $\sec x +\tan x$ is negative. Your expression is somewhat "wronger" than the expression in the problem (which is also wrong). You get into problems when either $\cos(x/2)+\sin(x/2)$ or $\cos(x/2)-\sin(x/2)$ is negative, while the official version has issues only when exactly one of them is negative. Actually, the constants of integration could also be different when $\sec x+\tan x$ is positive than when it is negative. –  André Nicolas Sep 2 '12 at 23:54
okay thanks, so now I understand the difference between the two (with and without) but I'm still confused on how to evaluate to integral without using logs. I checked my textbook again and there is nothing about this so help on this issue would be much appreciated –  Enrico S Sep 3 '12 at 0:21
The logs are a necessary part of the integral, whether in the form $\log(|\sec x+\tan x|)$ or in your form (slightly changed) $-\log(|\cos(x/2)-\sin(x/2)|)+\log(|\cos(x/2)+\sin(x/2)|)$. –  André Nicolas Sep 3 '12 at 1:42

Since they're handing you a solution, $$y = \frac{\ln|\sec x+\tan x| + C}{\sec x} = (\cos x) \ln|\sec x+\tan x| + C\cos x,$$ you can diffentiate, finding $dy/dx$, and plug it into the equation in place of $y$, and see if the two sides are equal.

In that way, you verify that it's a solution. The next question is whether it's general, i.e. there are no other solutions. That might follow from a theorem stated in a section of a textbook that you recently read.

-