# First order linear equation

#### find_the_fun

##### Active member
Find the gernal solution of $$\displaystyle cosx\frac{dy}{dx}+(sinx)y=1$$

So $$\displaystyle \frac{dy}{dx}+\frac{sinx}{cosx}y=\frac{1}{cosx}$$
$$\displaystyle \frac{dy}{dx}+tan(x)y=csc(x)$$ therefore $$\displaystyle P(x)=tan(x)$$
Let $$\displaystyle \mu (x) = e^{\int P(x) dx}=e^{\int tan(x) dx} =\frac{1}{cosx}$$

multiply both sides of the equation by integrating factor
$$\displaystyle \frac{dy}{dx} \frac{1}{cosx}+y\frac{tanx}{cosx}=\frac{1}{cos^2x}$$

$$\displaystyle \frac{d}{dx}[\mu(x)y]=\frac{d}{dx}[\frac{1}{cosx}y]$$ use product rule $$\displaystyle (\frac{1}{cosx})'y+\frac{1}{cosx}y'=\frac{tanx}{cosx}y+\frac{1}{cosx}\frac{dy}{dx}$$

Question 1: how come when we use the product rule and take the derivative of y with respect x we get $$\displaystyle \frac{dy}{dx}$$ and not 0? I say 0 because the derivative of a constant is 0 and aren't we treating y as a constant?

Next step: integrate

$$\displaystyle \int \frac{d}{dx}[\frac{1}{cosx}y]dx = \int \frac{1}{cosx} x$$
$$\displaystyle \frac{y}{cosx}=\ln{|-cosx|}+C$$
and $$\displaystyle y=\ln{|-cosx|}cosx+Ccosx$$

Question 2: the back of book has $$\displaystyle y=sinx+Ccosx$$ Where did sin(x) come from?

#### MarkFL

Staff member
Re: first order linear equation

This is how I would work the problem, and I hope to answer your questions along the way.

First, write the ODE in standard linear form:

$$\displaystyle \frac{dy}{dx}+\tan(x)y=\sec(x)$$

Compute the integrating factor:

$$\displaystyle \mu(x)=e^{\int\tan(x)\,dx}=\sec(x)$$

Hence, we find:

$$\displaystyle \sec(x)\frac{dy}{dx}+\sec(x)\tan(x)y=\sec^2(x)$$

Since $y$ is a function of $x$, when it is differentiated with respect to $x$, we cannot treat it as a constant, so we must write $$\displaystyle \frac{dy}{dx}$$. Thus, the left side is the differentiation of a product.

$$\displaystyle \frac{d}{dx}\left(\sec(x)y \right)=\sec^2(x)$$

Integrating with respect to $x$, we find:

$$\displaystyle \sec(x)y=\tan(x)+C$$

Multiply through by $\cos(x)$ (observing that $$\displaystyle \tan(x)\cos(x)=\frac{\sin(x)}{\cos(x)}\cos(x)=\sin(x)$$):

$$\displaystyle y(x)=\sin(x)+C\cos(x)$$

And this is our general solution.

#### find_the_fun

##### Active member
Re: first order linear equation

How do you integrate $$\displaystyle \sec^2(x)$$ to get $$\displaystyle \tan(x)+C$$?

#### MarkFL

Staff member
Re: first order linear equation

How do you integrate $$\displaystyle \sec^2(x)$$ to get $$\displaystyle \tan(x)+C$$?
This comes from:

$$\displaystyle \frac{d}{dx}\left(\tan(x)+C \right)=\sec^2(x)$$

#### Ackbach

##### Indicium Physicus
Staff member
Re: first order linear equation

Find the gernal solution of $$\displaystyle cosx\frac{dy}{dx}+(sinx)y=1$$

So $$\displaystyle \frac{dy}{dx}+\frac{sinx}{cosx}y=\frac{1}{cosx}$$
$$\displaystyle \frac{dy}{dx}+tan(x)y=csc(x)$$ therefore $$\displaystyle P(x)=tan(x)$$
Let $$\displaystyle \mu (x) = e^{\int P(x) dx}=e^{\int tan(x) dx} =\frac{1}{cosx}$$

multiply both sides of the equation by integrating factor
$$\displaystyle \frac{dy}{dx} \frac{1}{cosx}+y\frac{tanx}{cosx}=\frac{1}{cos^2x}$$

$$\displaystyle \frac{d}{dx}[\mu(x)y]=\frac{d}{dx}[\frac{1}{cosx}y]$$ use product rule $$\displaystyle (\frac{1}{cosx})'y+\frac{1}{cosx}y'=\frac{tanx}{cosx}y+\frac{1}{cosx}\frac{dy}{dx}$$

Question 1: how come when we use the product rule and take the derivative of y with respect x we get $$\displaystyle \frac{dy}{dx}$$ and not 0? I say 0 because the derivative of a constant is 0 and aren't we treating y as a constant?
To answer this question: we're not treating $y$ as a constant. We are treating $y=y(x)$ as a function of $x$, in which case we must use the chain rule.