JuliaApproximation / ApproxFunExamples

Examples for using ApproFun.jl
MIT License
24 stars 7 forks source link

Add image method example #5

Closed Gyoshi closed 4 years ago

Gyoshi commented 4 years ago

Add a new example of solving the heat equation with discontinuities at the boundaries using the image method. Also: Small fix to Floquet.ipynb, and change wording in existing heat equation example (Robin -> Mixed).


On the new example: The implementation is quite 'manual'. Please let me know if there is a better way to do it. There are many parts of ApproxFun that I do not know about yet, so I am wondering if there is a more intended way.

In particular, in the part where (inspired by the FAQ) I build the "Vandermonde" matrix with only the even numbered coefficients:

V = zeros(n, m)
for k = 1:m
   V[:,k] = Fun(S,[zeros(2*k-1);1]).(xarray)
end

c₀ = zeros(2*m)
c₀[2:2:end] = V\v # do the fit

Is there perhaps some built-in way to create a new space and then just use Fun(S, u₀) instead? Of course, an issue here is that we need a subspace of CosSpace, but then on a different domain as well, hence the function sampling + linear fit.

Perhaps some kind of more general approach using QuotientSpace?

dlfivefifty commented 4 years ago

Thanks! I'm in the process of redesigning the underpinnings of ApproxFun via ContinuumArrays.jl / OrthogonalPolynomialsQuasi.jl, after which this will be a lot more elegant (and faster): S[xarray, 1:n]