# Solving differentialequation $y'=y*tan(x)+4sin(x)$

So I'm pretty new to differential equations and I currently struggle with this one.

First things first. I know it's an first order linear differential equation with an undertermined coefficient. To solve it I have to find the particulate and the uniform (is this the right term?) solutions.

The general solution is then $y = y_h + y_p$

$y'=y\cdot \tan(x)+4\sin(x)$

1. uniform solution

$y_h'=y_h\cdot \tan(x)$

$\int\frac{y_h'}{y_h} dx = \int \tan(x) dx$

$\int\frac{1}{y_h} dy = \int \tan(x) dx$

$\ln|y_h| = -\ln(\cos(x))+c$

$\ln|y_h| = \ln(cos^{-1}(x))+c$

$|y_h| = e^c\cdot \frac{1}{\cos(x)}$

$y_h = C\cdot \frac{1}{\cos(x)}$

1. particulate solution

I use the uniform solution.

$y_p = C(x)\cdot \frac{1}{\cos(x)}$

$y_p' = C'(x)\cdot \frac{1}{\cos(x)}+C(x)\cdot \tan(x)\cdot 1/\cos(x)$

$y_p' = C'(x)\cdot \frac{1}{\cos(x)}+y_h\cdot \tan(x)$

Back into y':

$C'(x)\cdot \frac{1}{\cos(x)}+ y\cdot \tan(x) = y\cdot \tan(x)+4\sin(x)$

$C'(x) = 4\sin(x)\cos(x)$

Integrating gives:

$C(x) = -2\cos^2(x)$

Back into $y_p'$:

$y_p = -2\cos^2(x) \cdot \frac{1}{\cos(x)}$

$y_p = -2\cos(x)$

Now everything back together.

$y = y_h + y_p$

$y = C\cdot \frac{1}{\cos(x)} - 2\cos(x)$

I definitly got something wrong… I'm pretty sure that we learned it this way or I might messed something up. Thanks for the help, I tried solving it now for quite some time.

• "Homogeneous" is the word, not uniform. – Bobson Dugnutt Feb 29 '16 at 19:50
• The step where you go from $y_p' = C'(x) / \cos(x) + C(x) tan(x) / cos(x)$ to $y_p' = C'(x) / \cos(x) + y_h tan(x)$ is wrong. The $C$ in the expressions for $y_p$ and $y_h$ have nothing to do with each other. For $y_h$, $C$ is a constant that will be determined by boundary/initial conditions. For $y_p$, $C(x)$ is something altogether different and also a function of $x$ (i.e., not constant). It is independent of the boundary/initial conditions and has nothing to do with $C$. It's a property of the particular solution you seek. Maybe you should call it something else to avoid confusion. – nukeguy Feb 29 '16 at 19:54
• I don(t understand where is your final problem: $y = C\cdot \frac{1}{\cos(x)} - 2\cos(x)$ is solution of $y'=y\cdot \tan(x)+4\sin(x)$ and indeed its general solution. – Jean Marie Feb 29 '16 at 20:02
• @Seen The statement in your calculus worksheet is poorly worded in my opinion. In any case, $c(x) f_h(x)$ is not a homogeneous solution unless $c(x)$ is constant. What you're trying to do here is not to find another homogeneous solution, but rather try to find a particular solution by guessing that it looks something like $c(x) f_h(x)$. You start off with $f_p(x) = c(x) f_h(x) = c(x)/cos(x)$, but then later on in your derivation you claim $f_h(x) = c(x)/cos(x)$. These two statements do not agree with each other. – nukeguy Mar 1 '16 at 15:51
• Actually, ignore the comment I posted earlier about your solution being wrong, I forgot a minus sign when I plugged it back in (I just deleted it so nobody else will get confused). The solution you have is actually correct -- as @JeanMarie pointed out, if you plug in $y= C / \cos(x) - 2 \cos(x)$ back into the differential equation, it is satisfied. Your definition of $C$ is just different from the $C$ in Jan Eerland's solution. As you noted, $\cos(2x) = 1+\cos^2(x)$. Try replacing $C$ with something like $C+1$ or $C-1$and you will see that your solutions are the same. – nukeguy Mar 1 '16 at 16:09

$$y'(x)=y(x)\tan(x)+4\sin(x)\Longleftrightarrow$$ $$y'(x)-y(x)\tan(x)=4\sin(x)\Longleftrightarrow$$

Let $\mu(x)=e^{\int-\tan(x)\space\text{d}x}=\cos(x)$;

Multiply both sides by $\mu(x)$:

$$y'(x)\cos(x)-y(x)\sin(x)=4\cos(x)\sin(x)\Longleftrightarrow$$

Substitute $-\sin(x)=\frac{\text{d}}{\text{d}x}\left(\cos(x)\right)$:

$$y'(x)\cos(x)-y(x)\cdot\frac{\text{d}}{\text{d}x}\left(\cos(x)\right)=4\cos(x)\sin(x)\Longleftrightarrow$$

Apply the reverse product rule to the left-hand side:

$$\frac{\text{d}}{\text{d}x}\left(y(x)\cos(x)\right)=4\cos(x)\sin(x)\Longleftrightarrow$$ $$\int\frac{\text{d}}{\text{d}x}\left(y(x)\cos(x)\right)\space\text{d}x=\int4\cos(x)\sin(x)\space\text{d}x\Longleftrightarrow$$ $$y(x)\cos(x)=-\cos(2x)+\text{C}\Longleftrightarrow$$ $$y(x)=\frac{-\cos(2x)+\text{C}}{\cos(x)}\Longleftrightarrow$$ $$y(x)=\text{C}\sec(x)-\cos(2x)\sec(x)$$

• Ok, so my answer is different than yours but could you elaborate on what I did wrong? – Seen Feb 29 '16 at 21:15
• Yes I can, but if you want to learn from your mistake find it yourself! – Jan Feb 29 '16 at 21:17
• So I used a different integral but $-2cos^2(x)$ is equivalent to $-cos(2x)-1$, so it actually should end up being the same. Thanks for the effort but could you know help me a little bit by elaborating? I'm still new to differential equations and I wasn't even sure if I did the scheme right or if I did error calculating. – Seen Feb 29 '16 at 21:31
• @JanEerland's technique is also different from yours. He does not try to solve for the homogeneous and particular parts of the solution separately. Instead, he uses an "integrating factor" technique, which works very well for 1st-order linear ordinary differential equations such as this one. (See: mathworld.wolfram.com/IntegratingFactor.html) – nukeguy Mar 1 '16 at 15:58