|
1 | 1 | # # Eigenvalue problem |
2 | 2 |
|
3 | | -# ## Standard eigenvalue problem |
4 | | - |
5 | | -# In analogy to linear algebra, many differential equations may be posed as eigenvalue problems. |
6 | | -# That is, for some differential operator ``\mathop{L}``, there are a family of functions |
7 | | -# ``\mathop{u}_i(x)`` such that |
8 | | -# ```math |
9 | | -# \mathop{L} \mathop{u}_i(x) = λ_i \mathop{u}_i(x), |
10 | | -# ``` |
11 | | -# where ``λ_i`` is the ``i^{th}`` eigenvalue of the ``L`` and has a corresponding |
12 | | -# *eigenfunction* ``\mathop{u}_i(x)``. |
13 | | -# A classic eigenvalue problem is known as the quantum harmonic oscillator where |
14 | | -# ```math |
15 | | -# \mathop{L} = -\frac{1}{2}\frac{\mathop{d}^2}{\mathop{dx}^2} + \frac{1}{2} x^2, |
16 | | -# ``` |
17 | | -# and one demands that ``\mathop{u}(∞) = \mathop{u}(-∞) = 0``. |
18 | | -# Because we expect the solutions to be exponentially suppressed for large ``x``, |
19 | | -# we can approximate this with Dirichlet boundary conditions at a 'reasonably large' ``x`` |
20 | | -# without much difference. |
21 | | - |
22 | | -# We can express this in ApproxFun as the following: |
23 | | -using ApproxFun |
24 | | -using LinearAlgebra |
25 | | - |
26 | | -x = Fun(-8..8) |
27 | | -V = x^2/2 |
28 | | -L = -𝒟^2/2 + V |
29 | | -S = space(x) |
30 | | -B = Dirichlet(S) |
31 | | -λ, v = ApproxFun.eigs(B, L, 500,tolerance=1E-10); |
| 3 | +include("Eigenvalue_standard.jl") |
32 | 4 |
|
33 | 5 | # Note that boundary conditions must be specified in the call to `eigs`. |
34 | 6 | # Plotting the first ``20`` eigenfunctions offset vertically by their eigenvalue, we see |
35 | 7 |
|
36 | 8 | import Plots |
| 9 | +using LinearAlgebra: norm |
37 | 10 | p = Plots.plot(V; legend=false, ylim=(-Inf, λ[22])) |
38 | 11 | for k=1:20 |
39 | | - Plots.plot!(real(v[k]/norm(v[k]) + λ[k])) |
| 12 | + Plots.plot!(real(v[k]/norm(v[k]) + λ[k]), ) |
40 | 13 | end |
41 | 14 | p |
42 | 15 |
|
|
46 | 19 | # For problems with different contraints or boundary conditions, |
47 | 20 | # `B` can be any zero functional constraint, e.g., `DefiniteIntegral()`. |
48 | 21 |
|
49 | | -# ## Self-adjoint Eigenvalue Problem |
50 | | -# Ref: |
51 | | -# [J. L. Aurentz & R. M. Slevinsky (2019), arXiv:1903.08538](https://arxiv.org/abs/1903.08538) |
52 | | - |
53 | | -# We solve the confined anharmonic oscillator |
54 | | -# ```math |
55 | | -# \left[-\frac{d^2}{dx^2} + V(x)\right] u = λu, |
56 | | -# ``` |
57 | | -# where ``u(\pm 10) = 0``, ``V(x) = ωx^2 + x^4``, and ``ω = 25``. |
58 | | - |
59 | | -# Define parameters |
60 | | -ω = 25.0 |
61 | | -d = -10..10; |
62 | | -S = Legendre(d) # Equivalently, Ultraspherical(0.5, d) |
63 | | -NS = NormalizedPolynomialSpace(S) # NormalizedLegendre |
64 | | -D1 = Conversion(S, NS) |
65 | | -D2 = Conversion(NS, S); |
66 | | - |
67 | | -# Construct the differential operator |
68 | | -V = Fun(x -> ω * x^2 + x^4, S) |
69 | | -L = -Derivative(S, 2) + V; |
70 | | - |
71 | | -# Basis recombination to transform to one that satisfies Dirichlet boundary conditions |
72 | | -B = Dirichlet(S) |
73 | | -QS = QuotientSpace(B) |
74 | | -Q = Conversion(QS, S) |
75 | | -R = D1*Q; |
76 | | - |
77 | | -# This inversion is computed approximately, such that |
78 | | -# ``\mathrm{C}^{-1} \mathrm{C} ≈ \mathrm{I}`` up to a certain bandwidth |
79 | | -C = Conversion(domainspace(L), rangespace(L)) |
80 | | -P = cache(PartialInverseOperator(C, (0, ApproxFun.bandwidth(L, 1) + ApproxFun.bandwidth(R, 1) + ApproxFun.bandwidth(C, 2)))); |
81 | | - |
82 | | -A = R'D1*P*L*D2*R |
83 | | -B = R'R; |
84 | | - |
85 | | -# We impose a cutoff to obtain approximate finite matrix representations |
86 | | -n = 3000 |
87 | | -SA = Symmetric(A[1:n,1:n], :L) |
88 | | -SB = Symmetric(B[1:n,1:n], :L) |
89 | | -λ = eigvals(SA, SB)[1:round(Int, 3n/5)]; |
| 22 | +include("Eigenvalue_symmetric.jl") |
90 | 23 |
|
91 | 24 | # We plot the eigenvalues |
92 | 25 | import Plots |
|
0 commit comments