Replicating Runge's phenomenon with ApproxFun

The problem is that Fun(f, Taylor(-1..1), n) does not approximate f as an n-th order polynomial as you might expect:

f(x) \approx \sum_{k = 0}^n f_k x^k \, ,

but rather as a truncated Fourier series with only non-negative frequency components:

f(x) \approx \sum_{k = 0}^n f_k e^{i \pi k (x + 1)} \, .

What you’re plotting is the real part of that approximation:

\sum_{k = 0}^n f_k \cos(\pi k (x + 1)) \, ,

(As it turns out, you end up with all real f_k here, so only \cos terms appear in the real part.) This is dominated by oscillations at the highest frequency, n / 2, and is not subject to the Runge phenomenon.

The documentation is a bit sparse on this: Spaces · ApproxFun.jl. It does introduce Taylor as a space closely related to Fourier, but doesn’t spell out how various domains are mapped to the unit circle when using these spaces.

3 Likes