I tried to solve the following simple equation using another approach which seems correct to me but I'm getting a different result than the standard approach :
The ODE : $$ y' = \tan(x) y + \sin(x) $$ on $I = ] -\pi / 2 ; \pi/2[$
By standard approach I mean just solving the homogeneous equation then using variation of constant to find a particular solution but I tried something else :
- I turned the equation to $y' - \tan(x)y = \sin(x)$
I divided both sides on $\tan(x)$ for all $x$ different from $0$, I got $y' - y = \cos(x)$
I solved $y' - y = 0$ , intuitively, $ke^x$ is a solution
I looked for a particular solution by supposing that $y = a\cos(x) + b\sin(x)$ and replaced in the equation to find $a,b$ by comparison to second member : $cos(x)$
I joined both solutions : $y = ke^x - 1/2 \cos(x) - 1/2 \sin(x) $ for all $x$s different from $0$.
I then tried to solve it for $0$, I directly replaced $0$ in the initial equation, I got $y' = 0y + 0$ thus $y = \lambda$.
So for $x$ in $I - \{0\} $ we have $y = ke^x - 1/2 cos(x) - 1/2 sin(x) $ otherwise it's just $y = \lambda $.
I can't find the error in what I've done so please tell me what's wrong .
If you divide by $\tan(x)$ then you get $$\frac {y'}{\tan(x)} -y = \cos(x)$$ And not $$y' - y = \cos(x)$$
You should just rewrite it ( Multiply both side by $\cos(x)$ ) $$\cos(x)y' - \sin(x)y = \sin(2x)/2$$ $$(y \cos(x))'=\sin(2x)/2$$ And integrate
$$y \cos(x)=\frac 12\int \sin(2x)dx +K$$ $$y \cos(x)=-\frac 14\cos(2x) +K$$ $$y \cos(x)=-\frac 14(2\cos^2(x)-1) +K$$ $$\boxed{y(x)=-\frac 12\cos(x) +\frac K{\cos(x)}}$$