# Solving the Differential equation $y' = y \tan(x) + \cot(x)$

I am asked to solve the following differential equation:

$$y' = y \tan(x) + \cot(x)$$

What I have so far is

\begin{align*} y' - (\tan x) y &= \cot(x)\\ \\ I &= e^{\int - \tan(x) dx} = \cos(x)\\ \\ \cos(x) \left( y' - y \tan(x) \right) &= \cos(x) \cot(x)\\ y' \cos(x) - y \sin(x) &= \cos(x) \cot(x)\\ \int y' \cos(x) - y \sin(x) &= \int \cos(x) \cot(x) dx\\ \\ y \cos(x) &= \int \frac{cos^2(x)}{\sin(x)}\\ y \cos(x) &= \int \frac{1-sin^2(x)}{\sin(x)}\\ &= \int \csc(x) - \sin(x) \ dx\\ &= - \ln \vert \csc(x) + \cot(x) \vert + \cos(x) + C\\ \\ \therefore y &= - \frac{\ln \vert \csc(x) + \cot(x) \vert}{\cos(x)} + 1 + C \sec(x) \end{align*}

The thing is: I am having a hard time comparing my result to the textbook's solution and to Wolfram's solution.

Textbook's solution: $$\sec(x) \left( \frac{x}{2} + \frac{\sin(2x)}{4} + C \right)$$

Is my solution correct?

Thank you.

• Your answer is correct and is equivalent to WA's. The textbook answer is wrong – David Quinn Aug 9 '16 at 19:41
• Hi @DavidQuinn thank you for your input. How could I go from my answer to Wolfram's (or the opposite)? What kind of transformation did you do? – bru1987 Aug 9 '16 at 19:42
• Use $\csc x+\cot x=\cot(\frac x2)$ – David Quinn Aug 9 '16 at 19:50

\begin{align} y'(x)-y \tan x &=\sec x \tan x \left( \frac{x}{2} + \frac{\sin 2x }{4} + C \right)+\sec x \left( \frac{1}{2} + \frac{\cos 2x }{2} \right) \\&\hspace{4mm} -\sec x\left(\frac{x}{2}+\frac{\sin 2x }{4} + C \right)\tan x \\ &= \frac{1 + \cos 2x }{2\cos x}\\&=\cos x \end{align} i.e. the textbook's answer is for the RHS being $\cos x$ rather than $\cot x$.
Since $\ln \vert \csc(x) + \cot(x) \vert=\ln{|\frac{1+\cos{x}}{\sin{x}}|}=\ln{|\frac{2\cos^2{(x/2)}}{2\sin{(x/2)\cos(x/2)}}|}=\ln{\cos{(x/2)}}-\ln{\sin(x/2)}$, your solution is same as WolphramAlpha's.