Trigonometric interpolation Tobin A. Driscoll Richard J. Braun
Up to this point, all of our global approximating functions have been polynomials. While they are versatile and easy to work with, they are not always the best choice.
Suppose we want to approximate a function f f f that is periodic, with one period represented by the standard interval [ − 1 , 1 ] [-1,1] [ − 1 , 1 ] . Mathematically, periodicity means that f ( x + 2 ) = f ( x ) f(x+2)=f(x) f ( x + 2 ) = f ( x ) for all real x x x . We could use polynomials to interpolate or project f f f . However, it seems more reasonable to replace polynomials by functions that are also periodic.
Definition 9.5.1 (Trigonometric polynomial)
For an integer n n n , a trigonometric polynomial of degree n n n is
p ( x ) = a 0 2 + ∑ k = 1 n a k cos ( k π x ) + b k sin ( k π x ) p(x) = \frac{a_0}{2} + \sum_{k=1}^n a_k \cos(k\pi x) + b_k \sin(k\pi x) p ( x ) = 2 a 0 + k = 1 ∑ n a k cos ( kπ x ) + b k sin ( kπ x ) for real constants a k , b k a_k,b_k a k , b k .
It turns out that trigonometric interpolation allows us to return to equally spaced nodes without any problems. We therefore define N = 2 n + 1 N=2n+1 N = 2 n + 1 equally spaced nodes inside the interval [ − 1 , 1 ] [-1,1] [ − 1 , 1 ] by
t k = 2 k N , k = − n , … , n . t_k = \frac{2k}{N}, \quad k=-n,\ldots,n. t k = N 2 k , k = − n , … , n . The formulas in this section require some minor but important adjustments if N N N is even instead. We have modified our standard indexing scheme here to make the symmetry within [ − 1 , 1 ] [-1,1] [ − 1 , 1 ] about x = 0 x=0 x = 0 more transparent. Note that the endpoints ± 1 \pm 1 ± 1 are not among the nodes.
As usual, we have sample values y − n , … , y n y_{-n},\ldots,y_n y − n , … , y n , perhaps representing values of a function f ( x ) f(x) f ( x ) at the nodes. We also now assume that the sample values can be extended periodically forever in both directions, so that y k + m N = y k y_{k+mN}=y_k y k + m N = y k for any integer m m m .
9.5.1 Cardinal functions ¶ We can explicitly state the cardinal function basis for equispaced trigonometric interpolation. It starts with
τ ( x ) = 2 N ( 1 2 + cos π x + cos 2 π x + ⋯ + cos n π x ) = sin ( N π x / 2 ) N sin ( π x / 2 ) . \tau(x) = \frac{2}{N} \left( \frac{1}{2} + \cos \pi x + \cos 2\pi x
+ \cdots + \cos n\pi x\right) = \frac{\sin(N\pi x/2)}{N\sin(\pi x/2)}. τ ( x ) = N 2 ( 2 1 + cos π x + cos 2 π x + ⋯ + cos nπ x ) = N sin ( π x /2 ) sin ( N π x /2 ) . You can directly check the following facts. (See Exercise 9.5.3 .)
Given the definition of τ in (9.5.3) ,
τ ( x ) \tau(x) τ ( x ) is a trigonometric polynomial of degree n n n .τ ( x ) \tau(x) τ ( x ) is 2-periodic.τ ( t k ) = 0 \tau(t_k)=0 τ ( t k ) = 0 for any nonzero integer k k k .lim x → 0 τ ( x ) = 1. \displaystyle \lim_{x \to 0} \tau(x) = 1. x → 0 lim τ ( x ) = 1. Given also the nodes t k t_k t k in (9.5.2) , the functions τ k ( x ) = τ ( x − t k ) \tau_k(x) = \tau(x-t_k) τ k ( x ) = τ ( x − t k ) form a cardinal basis for trigonometric interpolation.
Because the functions τ − n , … , τ n \tau_{-n},\ldots,\tau_n τ − n , … , τ n form a cardinal basis, the coefficients of the interpolant are just the sampled function values, i.e., the interpolant of points ( t k , y k ) (t_k,y_k) ( t k , y k ) is
p ( x ) = ∑ k = − n n y k τ k ( x ) . p(x) = \sum_{k=-n}^n y_k \tau_k(x). p ( x ) = k = − n ∑ n y k τ k ( x ) . The convergence of a trigonometric interpolant is spectral, i.e., exponential as a function of N N N in the max-norm.
9.5.2 Implementation ¶ Function 9.5.1 is an implementation of trigonometric interpolation based on (9.5.4) . The function accepts an N N N -vector of equally spaced nodes. Although we have not given the formulas above, the case of even N N N is included in the code.
Trigonometric interpolation1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
triginterp(t, y)
Construct the trigonometric interpolant for the points defined by
vectors `t` and `y`.
"""
function triginterp(t, y)
N = length(t)
τ(x) =
if x == 0
return 1.0
else
denom = isodd(N) ? N * sin(π * x / 2) : N * tan(π * x / 2)
return sin(N * π * x / 2) / denom
end
return function (x)
return sum(y[k] * τ(x - t[k]) for k in eachindex(y))
end
end
About the code
The construct on line 13 is known as a ternary operator . It is a shorthand for an if
–else
statement, giving two alternative results for the true/false cases. Line 19 uses eachindex(y)
, which generalizes 1:length(y)
to cases where a vector might have a more exotic form of indexing.
Trigonometric interpolation1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function p = triginterp(t, y)
% TRIGINTERP Trigonometric interpolation.
% Input:
% t equispaced interpolation nodes (vector, length N)
% y interpolation values (vector, length N)
% Output:
% p trigonometric interpolant (function)
N = length(t);
p = @value;
function f = value(x)
f = zeros(size(x));
for k = 1:N
f = f + y(k) * trigcardinal(x - t(k));
end
end % value function
function tau = trigcardinal(x)
if rem(N,2)==1 % odd
tau = sin(N * pi * x / 2) ./ (N * sin(pi * x / 2));
else % even
tau = sin(N * pi * x / 2) ./ (N * tan(pi * x / 2));
end
tau(isnan(tau)) = 1; % fix any divisions by zero (L'Hopital's Rule)
end % trigcardinal function
end
Trigonometric interpolation1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def triginterp(t, y):
"""
triginterp(t, y)
Return trigonometric interpolant for points defined by vectors t and y.
"""
N = len(t)
def trigcardinal(x):
if x == 0:
tau = 1.0
elif np.mod(N, 2) == 1: # odd
tau = np.sin(N * np.pi * x / 2) / (N * np.sin(np.pi * x / 2))
else: # even
tau = np.sin(N * np.pi * x / 2) / (N * np.tan(np.pi * x / 2))
return tau
def p(x):
return np.sum([y[k] * trigcardinal(x - t[k]) for k in range(N)])
return np.vectorize(p)
About the code
The construct on line 13 is known as a ternary operator . It is a shorthand for an if
–else
statement, giving two alternative results for the true/false cases. Line 19 uses eachindex(y)
, which generalizes 1:length(y)
to cases where a vector might have a more exotic form of indexing.
Example 9.5.1 (Trigonometric interpolation)
Example 9.5.1 We will get a cardinal function without using an explicit formula, just by passing data that is 1 at one node and 0 at the others.
Tip
The operator ÷
, typed as \div
then Tab , returns the quotient without remainder of two integers.
using Plots
N = 7
n = (N - 1) ÷ 2
t = 2 * (-n:n) / N
y = zeros(N)
y[n+1] = 1
p = FNC.triginterp(t, y);
plot(p, -1, 1)
scatter!(t, y, color=:black,
xaxis=(L"x"), yaxis=(L"\tau(x)"),
title="Trig cardinal function, N=$N")
Here is a 2-periodic function and one of its interpolants.
f(x) = exp( sinpi(x) - 2*cospi(x) )
y = f.(t)
p = FNC.triginterp(t, y)
plot(f, -1, 1, label="function",
xaxis=(L"x"), yaxis=(L"p(x)"),
title="Trig interpolation, N=$N", legend=:top)
scatter!(t, y, m=:o, color=:black, label="nodes")
plot!(p, -1, 1, label="interpolant")
The convergence of the interpolant is spectral. We let N N N go needlessly large here in order to demonstrate that unlike polynomials, trigonometric interpolation is stable on equally spaced nodes. Note that when N N N is even, the value of n n n is not an integer but works fine for defining the nodes.
SourceN = 2:2:60
err = zeros(size(N))
x = range(-1, 1, 2501) # for measuring error
for (k,N) in enumerate(N)
n = (N-1) / 2; t = 2*(-n:n) / N;
p = FNC.triginterp(t, f.(t))
err[k] = norm(f.(x) - p.(x), Inf)
end
plot(N, err, m=:o,
xaxis=(L"N"), yaxis=(:log10, "max error"),
title="Convergence of trig interpolation")
Example 9.5.1 We will get a cardinal function without using an explicit formula, just by passing data that is 1 at one node and 0 at the others.
N = 7; n = (N-1) / 2;
t = 2 * (-n:n)' / N;
y = zeros(N, 1); y(n+1) = 1;
clf, scatter(t, y, 'k'), hold on
p = triginterp(t, y);
fplot(p, [-1, 1])
xlabel('x'), ylabel('p(x)')
title('Trig cardinal function')
Unrecognized function or variable 'triginterp'.
Here is a 2-periodic function and one of its interpolants.
clf
f = @(x) exp( sin(pi*x) - 2 * cos(pi*x) );
fplot(f, [-1, 1], displayname="periodic function"), hold on
fplot(triginterp(t, f(t)), [-1, 1], displayname="trig interpolant")
y = f(t); scatter(t, f(t), 'k')
xlabel('x'), ylabel('f(x)')
title('Trig interpolation'); legend()
Unrecognized function or variable 'triginterp'.
The convergence of the interpolant is spectral. We let N N N go needlessly large here in order to demonstrate that unlike polynomials, trigonometric interpolation is stable on equally spaced nodes. Note that when N N N is even, the value of n n n is not an integer but works fine for defining the nodes.
SourceN = 2:2:60;
err = zeros(size(N));
x = linspace(-1, 1, 1601)'; % for measuring error
for k = 1:length(N)
n = (N(k) - 1) / 2;
t = 2 * (-n:n)' / N(k);
p = triginterp(t, f(t));
err(k) = norm(f(x) - p(x), Inf);
end
clf, semilogy(N, err, 'o-')
axis tight, title('Convergence of trig interpolation')
xlabel('N'), ylabel('max error')
Unrecognized function or variable 'triginterp'.
Example 9.5.1 We will get a cardinal function without using an explicit formula, just by passing data that is 1 at one node and 0 at the others.
Tip
The operator ÷
, typed as \div
then Tab , returns the quotient without remainder of two integers.
N = 7
n = int((N - 1) / 2)
t = 2 * arange(-n, n + 1) / N
y = zeros(N)
y[n] = 1
p = FNC.triginterp(t, y)
x = linspace(-1, 1, 600)
plot(x, p(x))
plot(t, y, "ko")
xlabel("x"), ylabel("tau(x)")
title("Trig cardinal function");
Here is a 2-periodic function and one of its interpolants.
f = lambda x: exp(sin(pi * x) - 2 * cos(pi * x))
plot(x, f(x), label="periodic function")
y = f(t)
p = FNC.triginterp(t, y)
plot(x, p(x), label="trig interpolant")
plot(t, y, "ko", label="nodes")
xlabel("$x$"), ylabel("$p(x)$")
legend(), title("Trig interpolation");
The convergence of the interpolant is spectral. We let N N N go needlessly large here in order to demonstrate that unlike polynomials, trigonometric interpolation is stable on equally spaced nodes. Note that when N N N is even, the value of n n n is not an integer but works fine for defining the nodes.
SourceN = arange(2, 62, 2)
err = zeros(N.size)
x = linspace(-1, 1, 1601) # for measuring error
for k in range(N.size):
n = (N[k] - 1) / 2
t = 2 * arange(-n, n + 1) / N[k]
p = FNC.triginterp(t, f(t))
err[k] = max(abs(f(x) - p(x)))
semilogy(N, err, "-o")
xlabel("N"), ylabel("max error")
title("Convergence of trig interpolation");
Although the cardinal form of the interpolant is useful and stable, there is a fundamental alternative. It begins with an equivalent complex form of the trigonometric interpolant (9.5.1) ,
p ( x ) = ∑ k = − n n c k e i k π x . p(x) = \sum_{k=-n}^n c_k e^{ik\pi x}. p ( x ) = k = − n ∑ n c k e ikπ x . The connection is made through Euler’s formula,
and the resultant identities
cos θ = e i θ + e − i θ 2 , sin θ = e i θ − e − i θ 2 i . \cos \theta = \frac{e^{i \theta}+e^{-i\theta}}{2}, \qquad \sin \theta = \frac{e^{i \theta}-e^{-i\theta}}{2i}. cos θ = 2 e i θ + e − i θ , sin θ = 2 i e i θ − e − i θ . Specifically, we have
c k = { a 0 2 , k = 0 , 1 2 ( a k + i b k ) , k > 0 , c − k ‾ , k < 0. c_k = \begin{cases} \frac{a_0}{2}, & k=0, \\[1mm]
\frac{1}{2}(a_k + i b_k), & k> 0, \\[1mm]
\overline{c_{-k}}, & k < 0.
\end{cases} c k = ⎩ ⎨ ⎧ 2 a 0 , 2 1 ( a k + i b k ) , c − k , k = 0 , k > 0 , k < 0. While working with an all-real formulation seems natural when the data are real, the complex-valued version leads to more elegant formulas and is standard.
The N = 2 n + 1 N=2n+1 N = 2 n + 1 coefficients c k c_k c k are determined by interpolation nodes at the N N N nodes within [ − 1 , 1 ] [-1,1] [ − 1 , 1 ] . By evaluating the complex exponential functions at these nodes, we get the N × N N\times N N × N linear system
F c = y , F = [ e i s π t r ] r = − n , … , n , s = − n , … , n , \mathbf{F}\mathbf{c} = \mathbf{y}, \qquad \mathbf{F} = \bigl[ e^{\,is\pi t_r} \bigr]_{\, r=-n,\ldots,n,\, s=-n,\ldots,n,} Fc = y , F = [ e i s π t r ] r = − n , … , n , s = − n , … , n , to be solved for the coefficients. Up to a scalar factor, the matrix F \mathbf{F} F is unitary, which implies that the system can be solved in O ( N 2 ) O(N^2) O ( N 2 ) operations simply by a matrix-vector multiplication.
However, one of the most important (though not entirely original) algorithmic observations of the 20th century was that the linear system can be solved in just O ( N log N ) O(N\log N) O ( N log N ) operations by an algorithm now known as the fast Fourier transform , or FFT .
The FFTW
package provides a function fft
to perform this transform, but its conventions are a little different from ours. Instead of nodes in ( − 1 , 1 ) (-1,1) ( − 1 , 1 ) , it expects the nodes to be defined in [ 0 , 2 ) [0,2) [ 0 , 2 ) , and it returns the trig polynomial coefficients in the order
[ c 0 , c 1 , ⋯ c n , c − n , ⋯ c − 1 ] . \begin{bmatrix}
c_0, & c_1, & \cdots & c_n, & c_{-n}, & \cdots & c_{-1}
\end{bmatrix}. [ c 0 , c 1 , ⋯ c n , c − n , ⋯ c − 1 ] . Example 9.5.2 This function has frequency content at 2 π 2\pi 2 π , − 2 π -2\pi − 2 π , and π.
f(x) = 3 * cospi(2x) - cispi(x) # cispi(x) := exp(1im * π * x)
f (generic function with 1 method)
To use fft
, we set up nodes in the interval [ 0 , 2 ) [0,2) [ 0 , 2 ) .
n = 4; N = 2n+1;
t = [ 2j / N for j in 0:N-1 ] # nodes in [0,2)
y = f.(t);
We perform Fourier analysis using fft
and then examine the resulting coefficients.
using FFTW
c = fft(y) / N
freq = [0:n; -n:-1]
@pt :header=["k", "coefficient"] [freq round.(c, sigdigits=5)]
Note that 1.5 e 2 i π x + 1.5 e − 2 i π x = 3 cos ( 2 π x ) 1.5 e^{2i\pi x}+1.5 e^{-2i\pi x} = 3 \cos(2\pi x) 1.5 e 2 iπ x + 1.5 e − 2 iπ x = 3 cos ( 2 π x ) , so this result is sensible.
Fourier’s greatest contribution to mathematics was to point out that every periodic function is just a combination of frequencies—infinitely many of them in general, but truncated for computational use. Here we look at the magnitudes of the coefficients for f ( x ) = exp ( sin ( π x ) ) f(x) = \exp( \sin(\pi x) ) f ( x ) = exp ( sin ( π x )) .
Sourcef(x) = exp( sin(pi*x) ) # content at all frequencies
n = 9; N = 2n+1;
t = [ 2j / N for j in 0:N-1 ] # nodes in [0,2)
c = fft(f.(t)) / N
freq = [0:n; -n:-1]
scatter(freq, abs.(c);
xaxis=(L"k", [-n, n]), yaxis=(L"|c_k|", :log10),
title="Fourier coefficients", legend=:none)
The Fourier coefficients of smooth functions decay exponentially in magnitude as a function of the frequency. This decay rate is determines the convergence of the interpolation error.
Example 9.5.2 This function has frequency content at 2 π 2\pi 2 π , − 2 π -2\pi − 2 π , and π.
f = @(x) 3 * cos(2*pi * x) - exp(1i*pi * x);
To use fft
, we set up nodes in the interval [ 0 , 2 ) [0,2) [ 0 , 2 ) .
n = 4;
N = 2*n + 1;
t = 2 * (0:N-1)' / N; % nodes in $[0,2)$
y = f(t);
We perform Fourier analysis using fft
and then examine the resulting coefficients.
c = fft(y) / N;
freq = [0:n, -n:-1]';
format short
table(freq, c, variableNames=["k", "coefficient"])
Note that 1.5 e 2 i π x + 1.5 e − 2 i π x = 3 cos ( 2 π x ) 1.5 e^{2i\pi x}+1.5 e^{-2i\pi x} = 3 \cos(2\pi x) 1.5 e 2 iπ x + 1.5 e − 2 iπ x = 3 cos ( 2 π x ) , so this result is sensible.
Fourier’s greatest contribution to mathematics was to point out that every periodic function is just a combination of frequencies—infinitely many of them in general, but truncated for computational use. Here we look at the magnitudes of the coefficients for f ( x ) = exp ( sin ( π x ) ) f(x) = \exp( \sin(\pi x) ) f ( x ) = exp ( sin ( π x )) .
Sourcef = @(x) exp( sin(pi*x) ); % content at all frequencies
n = 9; N = 2*n + 1;
t = 2 * (0:N-1)' / N; % nodes in $[0,2)$
y = f(t);
c = fft(y) / N;
freq = [0:n, -n:-1]';
clf
semilogy(freq, abs(c), 'o')
xlabel('k'), ylabel('|c_k|')
title('Fourier coefficients')
The Fourier coefficients of smooth functions decay exponentially in magnitude as a function of the frequency. This decay rate is determines the convergence of the interpolation error.
Example 9.5.2 This function has frequency content at 2 π 2\pi 2 π , − 2 π -2\pi − 2 π , and π.
f = lambda x: 3 * cos(2 * pi * x) - exp(1j * pi * x)
To use fft
, we set up nodes in the interval [ 0 , 2 ) [0,2) [ 0 , 2 ) .
n = 4
N = 2 * n + 1
t = 2 * arange(0, N) / N # nodes in [0,2)
y = f(t)
We perform Fourier analysis using fft
and then examine the resulting coefficients.
from scipy.fftpack import fft, ifft, fftshift
c = fft(y) / N
freq = hstack([arange(n+1), arange(-n,0)])
results = PrettyTable()
results.add_column("freq", freq)
results.add_column("coefficient", c)
results
Note that 1.5 e 2 i π x + 1.5 e − 2 i π x = 3 cos ( 2 π x ) 1.5 e^{2i\pi x}+1.5 e^{-2i\pi x} = 3 \cos(2\pi x) 1.5 e 2 iπ x + 1.5 e − 2 iπ x = 3 cos ( 2 π x ) , so this result is sensible.
Fourier’s greatest contribution to mathematics was to point out that every periodic function is just a combination of frequencies—infinitely many of them in general, but truncated for computational use. Here we look at the magnitudes of the coefficients for f ( x ) = exp ( sin ( π x ) ) f(x) = \exp( \sin(\pi x) ) f ( x ) = exp ( sin ( π x )) .
Sourcef = lambda x: exp(sin(pi * x)) # content at all frequencies
n = 9; N = 2*n + 1;
t = 2 * arange(0, N) / N # nodes in [0,2)
c = fft(f(t)) / N
semilogy(range(-n, n+1), abs(fftshift(c)), "o")
xlabel("$k$"), ylabel("$|c_k|$")
title("Fourier coefficients");
The Fourier coefficients of smooth functions decay exponentially in magnitude as a function of the frequency. This decay rate is determines the convergence of the interpolation error.
The theoretical and computational aspects of Fourier analysis are vast and far-reaching. We have given only the briefest of introductions.
9.5.4 Exercises ¶ ⌨ Each of the following functions is 2-periodic. Use Function 9.5.1 to make a 3-by-1 grid of plots of the function together with its trigonometric interpolants over [ − 1 , 1 ] [-1,1] [ − 1 , 1 ] for n = 3 n=3 n = 3 , 6, and 9. Then, for n = 2 , 3 , … , 30 n=2,3,\ldots,30 n = 2 , 3 , … , 30 , compute the max-norm error in the trig interpolant by sampling at 1000 or more points, and make a convergence plot on a semi-log scale.
(a) f ( x ) = e sin ( 2 π x ) f(x) = e^{\sin (2\pi x)}\qquad f ( x ) = e s i n ( 2 π x )
(b) f ( x ) = log [ 2 + sin ( 3 π x ) ] f(x) = \log [2+ \sin (3 \pi x ) ]\qquad f ( x ) = log [ 2 + sin ( 3 π x )]
(c) f ( x ) = cos 12 [ π ( x − 0.2 ) ] f(x) = \cos^{12}[\pi (x-0.2)] f ( x ) = cos 12 [ π ( x − 0.2 )]
(a) ✍ Show that the functions sin ( r π x ) \sin(r\pi x) sin ( r π x ) and sin ( s π x ) \sin(s\pi x) sin ( s π x ) are identical at all of the nodes given in (9.5.2) if r − s = m N r-s=mN r − s = m N for an integer m m m . This important fact is called aliasing , and it implies that only finitely many frequencies can be distinguished on a fixed node set.
(b) ⌨ Demonstrate part (a) with a graph for the case N = 11 N=11 N = 11 , s = 2 s=2 s = 2 , r = − 9 r=-9 r = − 9 . Specifically, plot the two functions on one graph, and plot points to show that they intersect at all of the interpolation nodes.
✍ Verify that the cardinal function given in Equation (9.5.3) is (a) 2-periodic, (b) satisfies τ ( t k ) = 0 \tau(t_k)=0 τ ( t k ) = 0 for k ≠ 0 k\neq 0 k = 0 at the nodes (9.5.2) , and (c) satisfies lim x → 0 τ ( x ) = 1 \lim_{x\to0}\tau(x)=1 lim x → 0 τ ( x ) = 1 .
⌨ Spectral convergence is predicated on having infinitely many continuous derivatives. At the other extreme is a function with a jump discontinuity. Trigonometric interpolation across a jump leads to a lack of convergence altogether, a fact famously known as the Gibbs phenomenon .
(a) Define f(x) = sign(x+eps())
. This function jumps from -1 to 1 at x = − ϵ mach x=-\epsilon_\text{mach} x = − ϵ mach . Plot the function over − 0.05 ≤ x ≤ 0.15 -0.05\le x \le 0.15 − 0.05 ≤ x ≤ 0.15 .
(b) Let n = 30 n=30 n = 30 and N = 2 n + 1 N=2n+1 N = 2 n + 1 . Using Function 9.5.1 , add a plot of the trigonometric interpolant to f f f to the graph from part (a).
(c) Repeat part (b) for n = 80 n=80 n = 80 and n = 180 n=180 n = 180 .
(d) You should see that the interpolants overshoot and oscillate near the step. The widths of the overshoots decrease with n n n but the heights approach a limiting value. By zooming in to the graph, find the height of the overshoot to two decimal places.
⌨ Let f ( x ) = x f(x)=x f ( x ) = x . Plot f f f and its trigonometric interpolants of length N = 2 n + 1 N=2n+1 N = 2 n + 1 for n = 6 , 20 , 50 n=6,20,50 n = 6 , 20 , 50 over − 1 ≤ x ≤ 1 -1\le x \le 1 − 1 ≤ x ≤ 1 . What feature of the function is causing large errors?