Matlab differential equation verification Consider $y^{\prime \prime} + y = 0$ and its solution candidate $\cos(t)$. Using MATLAB I would like to substitute the candidate into the differential equation and get verification that it is indeed a solution. How can I do this? I already know that the candidate is a solution, however, when I learn the procedure I will apply it to the other differential equations and solution candidates.

The general solution to your problem can be computed by Laplace Transform
, and then you'll get:
$$y''(t)+y(t)=0\Longleftrightarrow$$
$$\frac{\text{d}^2y(t)}{\text{d}t^2}+y(t)=0\Longleftrightarrow$$
$$y(t)=y(0)\sin(t)+y'(0)\cos(t)\Longleftrightarrow$$
$$y(t)=c_2\sin(t)+c_1\cos(t)$$

Checking your $\cos(t)$ solution:
$$\frac{\text{d}^2}{\text{d}t^2}\cos(t)+\cos(t)=0\Longleftrightarrow$$
$$-\cos(t)+\cos(t)=0\Longleftrightarrow$$
$$\cos(t)-\cos(t)=0\Longleftrightarrow$$
$$0=0$$
