p24: Pseudospectra of Davies’s complex harmonic oscillator

p24: Pseudospectra of Davies’s complex harmonic oscillator#

%config InlineBackend.figure_format = 'svg'
from chebPy import cheb
from numpy import dot,argsort,zeros,real,imag,meshgrid,eye,diag,arange
from scipy.linalg import solve,eig,svd,svdvals
from matplotlib.pyplot import figure,plot,title,axis,contour
N = 70; D, x = cheb(N); x = x[1:N];
L = 6.0; x = L*x; D = D/L;
A = -dot(D,D);
A = A[1:N,1:N] + (1+3j)*diag(x**2);
lam, v = eig(A)
fig = figure()
plot(real(lam),imag(lam),"o")
axis([0, 50, 0, 40])

h = 0.5 # Smaller the value, finer the plot
x = arange(0,50+h,h); y = arange(0,40+h,h); xx,yy = meshgrid(x,y,indexing='ij');
zz = xx + 1j*yy;
I = eye(N-1); sigmin = zeros((len(x),len(y))) 
for i in range(0,len(x)):
    for j in range(0,len(y)):
        sigmin[i,j] = min(svdvals(zz[i,j]*I - A));

levels = 10.0**arange(-4.5,0.0,0.5);
contour(xx,yy,sigmin,levels,colors = 'k');
_images/ada6cb54484ccc8dff8c0de59dd0c6817cfae83d9cd609699bb71c2b43c48cf8.svg