In [27]:
using ApproxFun, SingularIntegralEquations, RiemannHilbert, Plots, QuadGK, DualNumbers, ComplexPhasePortrait
import ApproxFunBase: SequenceSpace, BasisFunctional, ℓ⁰, SpaceOperator, piece, pieces, npieces
import ApproxFun: eigs
import ApproxFunOrthogonalPolynomials: Recurrence
import RiemannHilbert: RiemannDual, logpart, finitepart, istieltjes, LogNumber
import SingularIntegralEquations: ⁺, ⁻
using RiemannHilbert.KdV
In [196]:
V = x -> 1.2exp(-x^2)
d = -10..10 # computational domain
D = Derivative()
λ,Q = eigs(Dirichlet(d), D^2 + Fun(V,d), 500)
scatter(λ, zero.(λ); xlims=(-2,2))
Out[196]:
Associated with the continuous spectrum is the reflection coefficient. This can be calculated:
In [218]:
R = ReflectionCoefficient(V)
R(0.1)
Out[218]:
Behind the scenes, its solving an ODE for $\psi$ on (-∞,0] and $\phi_\pm$ on [0,∞), by truncating the domain:
In [214]:
M = 10
V = x -> 1.2exp(-x^2)
V₋,V₊ = Fun(V, (-M)..0), Fun(V, 0..M)
k = 1
@time ψ = [ivp(); D^2 + (V₋ + k^2)] \ [exp(-im*k*(-M)), -im*k*(exp(-im*k*(-M))), 0.0]
F = qr([rdirichlet(space(V₊)); rneumann(); D^2 + (V₊ + k^2)])
φ₊ = F \ [exp(im*k*M), im*k*(exp(im*k*M)), 0.0]
φ₋ = F \ [exp(-im*k*M), -im*k*(exp(-im*k*M)), 0.0]
plot(imag(ψ); legend=:bottomleft, label="\\psi", title="k = $k, imaginary part")
plot!(imag(φ₊); label="\\phi\\_+")
plot!(imag(φ₋); label="\\phi\\_-")
Out[214]:
In [215]:
a,b = [φ₋(0) φ₊(0);
φ₋'(0) φ₊'(0) ] \ [ψ(0); ψ'(0)]
plot(imag(ψ); legend=:bottomleft, label="\\psi", title="k = $k, imaginary part")
plot!(imag(a*φ₋ + b*φ₊); label="a\\phi\\_+ + b\\phi\\_-")
Out[215]:
In [220]:
q = Q[findmax(λ)[2]]
q = q/norm(q)
plot(x -> -V(x), -10,10; label="potential", legend=:bottomright, ylims=(-2.5,2.5), linestyle=:dot)
plot!(-findmax(λ)[1]+abs2(q); label="eigenfunction")
plot!(abs2(ψ+a*φ₋ + b*φ₊)+k; label="wave")
Out[220]:
In [221]:
V = x -> 0.1exp(-x^2)
d = -10..10 # computational domain
D = Derivative()
λ,Q = eigs(Dirichlet(d), D^2 + Fun(V,d), 500)
scatter(λ, zero.(λ); xlims=(-2,2))
Out[221]:
The first step is to expand $R$ into a Chebyshev expansion. We use tFun
which takes advantage of parallelisation:
In [222]:
@time ρ = tFun(R, -5.0..5, 300)
plot(ρ)
Out[222]:
For any $t$ and $x$ we can construct the jump function, but we would need to deform for large $t$ and $x$. Lets keep life simple and take $t = x = 0$, in which case we get the following jump:
In [223]:
k = Fun(identity, space(ρ))
G = [1-abs2.(ρ) -conj.(ρ);
ρ 1.0];
We can now find the solution to $\Phi_+ = \Phi_- G$. RiemannHilbert.jl uses the transpose version ($\Phi_+ = G \Phi_-$) so we transpose twice:
In [224]:
@time Φ = transpose(rhsolve(transpose(G), 2*4*200)); # asymptotic to I
Φ = [1 1]*Φ; # asymptotic to [1 1]
It worked!
In [225]:
Φ(0.1+0.0im) ≈ Φ(0.1-0.0im)*G(0.1)
Out[225]:
We can then recover $V$ from Φ
. I'm not going to show that since there's a bug 😳
In [234]:
ψ(0.0)/a - (φ₋(0.0) + ρ(1)*φ₊(0.0))
Out[234]:
In [227]:
Φ(1.0-0.0im)
Out[227]:
In [230]:
Φ(1.0+0.0im)
Out[230]:
In [219]:
R(1)
Out[219]:
In [232]:
ψ(0.0)/a
Out[232]:
In [231]:
(ϕ₋)(0.0)
Out[231]:
In [233]:
ϕ₊(0.0)
Out[233]:
In [ ]:
S = []
In [164]:
ψ(-10.0)exp(im*1*(-10.0))
Out[164]:
In [146]:
Φ(1-0.0im)
Out[146]:
In [158]:
ϕ₊(0.0)
Out[158]:
In [151]:
ϕ₋(1)
Out[151]:
In [ ]: