QuantEcon / lecture-julia.myst

Lecture source for "Quantitative Economics with Julia"
https://julia.quantecon.org/intro.html
53 stars 43 forks source link

Add back in ApproxFun example without dependencies #200

Open jlperla opened 1 year ago

jlperla commented 1 year ago

In the iterative_methods_sparsity section on orthogonal polynomials, I removed the following code, which we can add back in at some point - hopefully compartmentalized.

    using ApproxFun
    N = 10000
    S = Chebyshev(-1.0..1.0)  # form Chebyshev basis
    x = points(S, N)  # chooses Chebyshev nodes
    y = g.(x)
    g_approx = Fun(S,ApproxFun.transform(S,y))  # transform fits the polynomial
    @show norm(g_approx.(x) - g.(x), Inf)
    plot(x_display, g_approx.(x_display), label = L"P_{10000}(x)")
    plot!(x_display, g.(x_display), w = 3, label = L"g(x)")