# First Order Differential Equation $y' \cos x +y=\sec x+\tan x$

I'm stuck on a seemingly straight forward problem as follows: $$\cos x \frac{dy}{dx}+y=\sec x+\tan x$$

I have rearranged the equation to be: $$\frac{dy}{dx}+\sec x \cdot y=(\sec x+\tan x)\sec x$$

which is in a standard format to be solved.

Then, I have found the Integrating Factor (IF): $\sec x+\tan x$.

Altogether giving the equation:

$$\frac{d}{dx}[(\sec x+\tan x)y]=[(\sec x+\tan x)^2\cdot \sec x]dx$$

I am a bit confused as to carrying out the integration to find the general solution.I want to carry out integration on both sides but am struggling to find a manageable form.

The Answer is: $$y=\frac{1}{2}(\sec x+\tan x)+c(\sec x+\tan x)^{-1}$$

How do I reach this correct answer? Any help will be appreciated...

• I reformatted the formulas. See math notation guide.
– user147263
Jan 15, 2015 at 14:56

Hint: Integration on both sides.

The integral on the RHS is:

$$\int (\sec{x}+\tan{x})^2 \sec{x} dx$$

Transform them to $\sin{x}$ and $\cos{x}$:

$$\int (\frac{1+\sin{x}}{\cos{x}})^2 \frac{1}{\cos{x}}dx=\int (\frac{1+\sin{x}}{\cos{x}})^2 \frac{\cos{x}}{(\cos{x})^2}dx$$

Now substitute $u$ for $\sin{x}$.

$$\int \frac{1}{(1-u)^2} du = -\frac{1}{u-1}+C\\ =-\frac{1}{\sin{x}-1}+C$$

Then you can divide by $\sec{x}+\tan{x}$ on both sides of the differential equation to get

$$y=\frac{\frac{1}{1-\sin{x}}}{\sec{x}+\tan{x}}+\frac{C}{\sec{x}+\tan{x}}\\ =\frac{1}{(1-\sin{x})(\frac{\sin{x}+1}{\cos{x}})}+\frac{C}{\sec{x}+\tan{x}}\\ =\sec{x}+\frac{C}{\sec{x}+\tan{x}}$$

This is what I can get. Are you sure the answer is correct?

• Thank you!! But, could you go a few steps further to help please? Jan 15, 2015 at 15:32
• @pikayenga, check out my answer.
– abel
Jan 15, 2015 at 18:53

here is little different way of doing this. it is called variation of parameters. in this method you solve the hgs equation and look for a particular solution of the forced equation in the form of the hgs solution but now you let the constant of integration a function to be determined. i will illustrate the method on your question. we will need $\dfrac{dx}{\cos x} = d \ln (1 + \sin x) - d \ln \cos x$ which is equivalent to $(\sec x)^\prime = \ \ln \sec x + \tan x$ and we will need $$\dfrac{2dx}{\cos^3 x} -\dfrac{dx}{\cos x} = \dfrac{\sin x \ dx}{\cos^2 x}, \dfrac{2\sin x dx}{\cos^3 x} = \dfrac{dx}{\cos^2 x}$$

we will rewrite and solve the hgs equation $$0= \dfrac{dy}{y} + \dfrac{dx}{\cos x} = d \ln y+ d(\ln(1+\sin x)) - d(\ln \cos x)$$ has solution of the form $$y = \dfrac{C \cos x}{1 + \sin x}, \dfrac{dy}{dx} = \dfrac{dC}{dx}\dfrac{\cos x}{1 + \sin x} -\dfrac{C}{1+\sin x}$$ now, $$\cos x \dfrac{dy}{dx} + y = \dfrac{dC}{dx}\dfrac{\cos^2 x}{1 + \sin x} -\dfrac{C\cos x}{1+\sin x} + \dfrac{C \cos x}{1 + \sin x} = \dfrac{dC}{dx}\dfrac{\cos^2 x}{1 + \sin x}$$ equals the right hand side$$\dfrac{1+\sin x}{\cos x}$$ of the equation and gives $$\dfrac{dC}{dx} = \dfrac{(1 + \sin x)^2}{\cos^3 x} = \dfrac{2 + 2\sin x - \cos ^2 x}{\cos^3 x} = \dfrac{2}{\cos^3 x} +\dfrac{2\sin x}{\cos^3 x} -\dfrac{1}{\cos x}$$

therefore $$C = \dfrac{\sin x}{\cos^2 x} + \dfrac{1}{\cos^2 x}$$ and $$y = \dfrac{C \cos x}{1 + \sin x} = \dfrac{1}{\cos x}$$

we will verify that $y = \dfrac{1}{\cos x}$ is in fact a particular solution of $$\cos x \dfrac{dy}{dx} + y = \cos x \dfrac{\sin x}{\cos^2 x} + \dfrac{1}{\cos x} = \sec x + \tan x$$ The genral solution is $$y = y_P = y_{hgs} = \dfrac{1}{\cos x} + \dfrac{C \cos x}{1 + \sin x}= \sec x + C(\sec x - \tan x) = \sec x + \dfrac{C}{\sec x + \tan x}$$ by putting $C= -1$ we find that $\tan x$ is also a solution.

p.s. so the most general solution is $$y = k\tan x + (1-k) \sec x + C(\sec x + \tan x)$$ for any constants $k$ and $C.$

i wonder why there are two arbitrary constants for this first order differential equation?