# -*- coding: utf-8 -*-
"""
Created on Fri Oct 14 16:39:44 2022

@author: 102194
"""
import numpy as np
import matplotlib.pyplot as plt
import scipy.linalg as la
import scipy.sparse as sp
import scipy.sparse.linalg as sla

xmin = 0
xmax = 1

x = np.linspace(xmin,xmax,200)
h = x[1]-x[0]
N = len(x)

D1 = sp.diags([-1/(2*h),0,1/(2*h)],[-1,0,1],shape=(N,N))
D2 = 1/h**2*sp.diags([1,-2,1],[-1,0,1],shape=(N,N))

I = sp.eye(N)

#create matrix:
A = sp.csc_matrix(-D2)

# put in boundary condition
A[0,0] = 1; A[0,1]=0
A[-1,-1]=1; A[-1,-2] = 0

lam,v = sla.eigs(A,5,sigma=9)

plt.plot(x,v[:,0])