In [2]:
from resources306 import *
#%matplotlib inline

Eigenvalues for various methods for heat equation¶

In [13]:
alpha = sp.symbols('alpha')
alphamax = 2*np.pi
for sigma in [.6]:
    lambda_pde = sp.exp(-sigma*alpha**2)
    lambda_euler = 1 + 2*sigma*(sp.cos(alpha)-1)
    lambda_be = 1/(1 - 2*sigma*(sp.cos(alpha)-1))
    lambda_cn = (1-sigma*(1-sp.cos(alpha)))/(1+sigma*(1-sp.cos(alpha)))
    expressionplot(lambda_pde,alpha,0,alphamax,label='exact')
    expressionplot(lambda_euler,alpha,0,alphamax,label='Euler')
    expressionplot(lambda_be,alpha,0,alphamax,label='BE')
    expressionplot(lambda_cn,alpha,0,alphamax,label='CN')
for v in [-1,0,1]: plt.axhline(v,color='k',alpha=0.25)
plt.legend(); plt.xlabel('wavenumber $\\alpha$',fontsize=15)
plt.text(np.pi,.7,f'$\sigma=${sigma}',fontsize=30,color='m',alpha=0.5,ha='center');

Why is the eigenvalue periodic in $\alpha$?¶

Changing $\alpha$ by an integer multiple of $2\pi$ is invisible on the grid:

In [18]:
M = 10
pi = np.pi
ii = np.linspace(0,M+1,500)
i  = np.linspace(0,M+1,M+2)
def doplot(alpha):
    plt.plot(ii,np.real(np.exp(1j*alpha*ii)))
    plt.plot(i ,np.real(np.exp(1j*alpha*i)),'o')
    plt.xlabel('x',fontsize=15)
doplot(.3)
In [20]:
doplot(0.3 + 2*pi)
In [5]:
doplot(0.3 + 4*pi)
In [ ]: