I know the method of constructing solutions. For example I have a BVP:$$ u_{xx} + u = 0 $$subjected to:$$ u_{x}(0) = f_1, $$$$ u_{x}(1) = f_2 $$If I want to check the correctness of my numerical implementation, just plug in $u(x) = \sin(x)$ and then $f_1 = \cos(0), f_2 = \cos(1)$ and then run the script for implementation. If the graphs of the numerical solution and that of $u(x) = \sin(x)$ approximately matches then I have the correct implementation.This may present some problems when constructing solutions with not-so-simple differential equations. Currently I am having trouble finding one for:$u_t = ku_{xx}$. Are there any other methods or is there a simple function for this one?
How to check the correctness of my implementation of a numerical scheme for differential equation
numerical analysis
The Method of Manufactured Solutions (PDF link) goes more as less as follows. You pick a solution that excites enough modes of your operator and satisfies the boundary and initial conditions, and you then turn the crank to get a right-hand-side function that you can implement. Though, just bare sines and cosines are a poor choice since they might be eigenfunctions of your operator and lead to a solution that has false accuracy. A product of transcendental functions is usually used.After you have implemented that RHS function, you should generate a range of numerical solutions on a sequence of successively finer meshes. Then you should compute the difference between your computed values to the exact value on each mesh in some norm or other metric. The choice of that norm should be based on the convergence theory that you have for your numerical method. At that point, the goal is to check to see if your method achieves the order of accuracy that the theory predicts. This is typically $O(h^{(p+k)})$ where $h$ is the mesh size, $p$ is the order of the method, and $k$ is dependent on the norm you chose. If, for small enough $h$, your method behaves like the theory predicts, then you've made one measure of the accuracy/correctness of your implementation. 