Separable ordinary differential equations
Solve the following ODE: $x^2+2y \cdot y'=0$
It is a separable ODE, since we can manage to separate the $x$'s and the $y$'s and put them on each side of the equation: $$2y\cdot y'=-x^2$$ Now we transform $y'=\dfrac{dy}{dx}$
And we proceed as we have explained: $$2y\cdot \dfrac{dy}{dx}=-x^2 \Rightarrow 2y\cdot dy=-x^2\cdot dx \Rightarrow \int 2y\cdot dy= \int -x^2\cdot dx \Rightarrow$$ $$\Rightarrow y^2=-\dfrac{x^3}{3}+C$$ Now, we solve for $y$ in terms of $x$: $$y(x)=\pm\sqrt{C-\dfrac{x^3}{3}}, \ C\in\mathbb{R}$$ We observe that we have not obtained a unique solution. This is because $f(x,y)=-\dfrac{x^2}{2y}$ which is not continuous at $y=0$.
$$y(x)=\pm\sqrt{C-\dfrac{x^3}{3}}, \ C\in\mathbb{R}$$
Solve the following PVI: $$\left\{\begin{matrix}y' = y\cdot \sin(x) \\ y(\pi) = -3 \end{matrix}\right.$$
It is a separable ODE; we have to divide by $y$, so we will have to check if $y=0$ is also a solution. Therefore, we have to distinguish two cases:
Case 1: If $y\neq0$ it is a separable ODE and we have: $$y'=y\cdot\sin(x) \Rightarrow \dfrac{1}{y}\cdot\dfrac{y'}{y}=\sin(x) \Rightarrow \dfrac{1}{y}\cdot\dfrac{dy}{dx}=\sin(x) \Rightarrow$$ $$\Rightarrow \dfrac{dy}{y}=\sin(x)\cdot dx \Rightarrow \int \dfrac{dy}{y}=\int \sin(x)\cdot dx \Rightarrow$$ $$\ln|y(x)|=-\cos(x)+C \Rightarrow |y(x)|=e^{-\cos(x)+C}=e^{-\cos(x)}\cdot e^{C}=k\cdot e^{-\cos(x)}, \ k > 0 \Rightarrow$$ $$\Rightarrow y(x)=k\cdot e^{-\cos(x)}, \ k\neq0$$ where $k$ is a constant to be determined by the initial conditions.
Case 2: If $y=0$. We see that this is a solution. Therefore we also have to consider it, however it does not satisfy the initial condition
Thus the general solution is: $$y(x)=k\cdot e^{-\cos(x)}, \ k\in\mathbb{R}$$ Now we can impose the initial conditions to determine $k$: $$y(\pi)=-3 \Rightarrow -3=k\cdot e^{-\cos(\pi)}=k\cdot e \Rightarrow k=-\dfrac{3}{e}$$
$$y(x)=-3\cdot e^{-(cos(x)+1)}$$