Skip to content

Instantly share code, notes, and snippets.

@YingboMa
Last active July 31, 2020 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YingboMa/016f31bf71925fab32ecef3d545c90a3 to your computer and use it in GitHub Desktop.
Save YingboMa/016f31bf71925fab32ecef3d545c90a3 to your computer and use it in GitHub Desktop.
using Plots, FastGaussQuadrature, FastTransforms
fejer1(N) = FastTransforms.fejernodes1(Float64, N), FastTransforms.fejerweights1(FastTransforms.FastTransforms.chebyshevmoments1(Float64, N))
fejer2(N) = FastTransforms.fejernodes2(Float64, N), FastTransforms.fejerweights2(FastTransforms.FastTransforms.chebyshevmoments2(Float64, N))
clenshawcurtis(N) = FastTransforms.clenshawcurtisnodes(Float64, N), FastTransforms.clenshawcurtisweights(FastTransforms.FastTransforms.chebyshevmoments1(Float64, N))
x = range(-1.2, stop = 1.2, length = 1000)
y = range(-0.4, stop = 0.4, length = 1000÷3)
r(z, x, w) = sum(k->w[k]/(z - x[k]), eachindex(x))
ϕ(z) = log((z+1)/(z-1))
quadrature_contour(xs, w; kwargs...) = contour(x, y, (x, y) -> abs(r(x + y*im, xs, w) - ϕ(x + y*im)); levels=map(i->1/10^i, 0:10), aspect_ratio=1, colorbar=false, xlimits=(-1.5, 1.5), ylimits=(-0.5, 0.5), kwargs...)
plts = [quadrature_contour(clenshawcurtis(64)...; title="Clenshaw-Curtis"),
quadrature_contour(gausslegendre(64)...; title="Gauss-Legendre"),
quadrature_contour(fejer1(64)...; title="Fejér 1"),
quadrature_contour(fejer2(64)...; title="Fejér 2"),]
plot(plts..., layout=(2, 2), dpi=400, titlefontsize=10)
@YingboMa
Copy link
Author

YingboMa commented Jul 31, 2020

clenshaw_vs_gauss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment