Consider the following heat equation: $$ u_t=u_{xx} \quad\text{ on }\quad(0,\pi) $$ with mix boundary condition $u'(0)+u(0)=0$ and $u'(\pi)+u(\pi)=0$. The eigenfunctions of the laplacian are $$ e^{-x},n\cos(nx)-\sin(nx),\forall n\geq 1. $$
To solve it numerically, I use the standard finite difference, i.e., forward Euler in time and the central difference in space. That is $$ \frac{u^{n+1}_i-u^n_i}{dt}=\frac{u^n_{i-1}-2u^n_{i}+u^n_{i+1}}{h^2} $$ where $u_i^n=u(x_i,t_n)$.
If I take the initial condition as $u_0=e^{-x}$, the numerical solution looks good. However, if $u(x,0)=\cos x-\sin x$, the result is not good.
Let $u(x,0)=\cos x-\sin x$. Then the exact solution should be $e^{-t}(\cos x-\sin x)$. The following figures are the absolutely error and solution at time $T=10$,
It seems that the shape of the numerical solution looks like $e^{-x}$ the first eigenfunction of laplacian with the boundary condition.
I am quite confused about this result.


Just to wrap up the question:
The underlying dynamics in this problem are unstable, because $e^{-x}$ is an eigenfunction of the Laplacian with a positive eigenvalue in this situation. Thus although the true dynamics started from $\cos(x)-\sin(x)$ are just exponential decay, the numerical dynamics deviate slightly from this, enough that effectively a contribution to $u(t,\cdot)$ from $e^{-x}$ appears. The true dynamics then grow this new contribution exponentially, and so do the numerical dynamics. This happens with pretty much any numerical method you might try to use for such a problem.
Physically this is caused by the fact that the boundary condition on the left gives positive feedback: the inward flux at $0$ is proportional to $-u'(0)$ which is proportional to $u(0)$, so effectively you have a situation along the lines of $\frac{d}{dt} u(t,0)=u(t,0)$.