Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Big Idea

Differentiation is linear. On the finite-dimensional space Pn\mathbb{P}_n it is therefore a single matrix, and we can choose to write that matrix either in the coefficient basis (acting on Chebyshev coefficients) or in the value basis (acting on nodal values). Both representations differentiate the same polynomial. The coefficient-space matrix is banded and reads “shift Chebyshev indices down by one with weight 2k2k”. The value-space matrix DD is dense and reads “differentiate the global Lagrange interpolant”. Different operations are easier in different representations, and we move freely between them through the DCT.

Two Pictures of Differentiation

We have already met the local picture: forward differences give O(h)O(h) accuracy and centered differences give O(h2)O(h^2). Each derivative estimate uses 2–3 nearby values; the rest of the data is ignored.

The spectral picture is the opposite. The interpolant pnp_n already encodes all the data globally. Its derivative pnp_n' is just another polynomial in Pn1Pn\mathbb{P}_{n-1} \subset \mathbb{P}_n, which we can in turn represent by its values at the same Chebyshev nodes or by its Chebyshev coefficients. So differentiation is a linear map from Pn\mathbb{P}_n to itself, and the question is: what does its matrix look like in each of the two bases?

A naming convention before we start. Throughout this section and the next we use “coefficient space” and “value space” as shorthand for two specific bases of Pn\mathbb{P}_n:

Both are bases of the same (n+1)(n+1)-dimensional space Pn\mathbb{P}_n. The DCT from §2 is precisely the change-of-basis matrix between them. The “coefficient-space” operator D\mathcal{D} below represents differentiation in the Chebyshev basis; the “value-space differentiation matrix” DD represents the same map in the Lagrange basis.

Differentiation in the Coefficient Basis

In the Chebyshev (coefficient) basis the polynomial is

pn(x)  =  k=0nckTk(x).p_n(x) \;=\; \sum_{k=0}^n c_k\, T_k(x).

We want the coefficients ckc'_k of pnp_n' in the same basis:

pn(x)  =  k=0n1ckTk(x).p_n'(x) \;=\; \sum_{k=0}^{n-1} c'_k\, T_k(x).

The derivation begins with a single chain-rule calculation that, by itself, forces a new family of polynomials onto the stage.

Step 1: Differentiate TkT_k by the chain rule

Recall that Tk(x)=cos(kθ)T_k(x) = \cos(k\theta) where x=cosθx = \cos\theta, so dθdx=1sinθ\dfrac{d\theta}{dx} = -\dfrac{1}{\sin\theta}. Differentiating,

Tk(x)  =  ddxcos(kθ)  =  ksin(kθ)(1sinθ)  =  ksin(kθ)sinθ.T_k'(x) \;=\; \frac{d}{dx}\cos(k\theta) \;=\; -k\sin(k\theta)\cdot\Big(-\frac{1}{\sin\theta}\Big) \;=\; k\,\frac{\sin(k\theta)}{\sin\theta}.

The factor sin(kθ)/sinθ\sin(k\theta)/\sin\theta looks transcendental but is in fact a polynomial in x=cosθx = \cos\theta. The argument is short enough to spell out.

Start with the product-to-sum identity sin(A+B)sin(AB)=2cosAsinB\sin(A+B) - \sin(A-B) = 2\cos A \sin B. Setting A=θA = \theta, B=(k1)θB = (k-1)\theta and using sin(2k)θ=sin(k2)θ\sin(2-k)\theta = -\sin(k-2)\theta,

sin(kθ)  =  2cosθsin ⁣((k1)θ)    sin ⁣((k2)θ).\sin(k\theta) \;=\; 2\cos\theta \,\sin\!\big((k-1)\theta\big) \;-\; \sin\!\big((k-2)\theta\big).

Define uk(x):=sin ⁣((k+1)θ)/sinθu_k(x) := \sin\!\big((k+1)\theta\big)/\sin\theta. Dividing the identity above by sinθ\sin\theta and reindexing turns it into a recurrence on uku_k,

uk(x)  =  2xuk1(x)    uk2(x),k2.u_k(x) \;=\; 2x\, u_{k-1}(x) \;-\; u_{k-2}(x), \qquad k \ge 2.

For the base cases,

u0(x)  =  sinθsinθ  =  1,u1(x)  =  sin2θsinθ  =  2sinθcosθsinθ  =  2x.u_0(x) \;=\; \frac{\sin\theta}{\sin\theta} \;=\; 1, \qquad u_1(x) \;=\; \frac{\sin 2\theta}{\sin\theta} \;=\; \frac{2\sin\theta\cos\theta}{\sin\theta} \;=\; 2x.

The recurrence with these starting values produces a polynomial at every step: if uk1u_{k-1} and uk2u_{k-2} are polynomials of degrees k1k-1 and k2k-2, then 2xuk1uk22x\,u_{k-1} - u_{k-2} is a polynomial of degree kk. By induction uku_k is a polynomial of degree kk. So sin(kθ)/sinθ=uk1(x)\sin(k\theta)/\sin\theta = u_{k-1}(x) is a polynomial of degree k1k-1 in xx. Cranking the recurrence by hand,

u0=1,u1=2x,u2=4x21,u3=8x34x,u4=16x412x2+1,u_0 = 1, \quad u_1 = 2x, \quad u_2 = 4x^2 - 1, \quad u_3 = 8x^3 - 4x, \quad u_4 = 16x^4 - 12x^2 + 1, \quad \ldots

Note that this is the same three-term recurrence as TkT_k, with the same first step u1=2x=2T1u_1 = 2x = 2 T_1 but a different zeroth value (u0=1=T0u_0 = 1 = T_0). So uku_k and TkT_k are siblings: same growth recurrence, different boundary conditions.

Step 2: That polynomial has a name

The polynomial uku_k that just dropped out of the chain rule is what is conventionally called the Chebyshev polynomial of the second kind, written UkU_k:

Uk(x)  =  sin((k+1)θ)sinθ,x=cosθ.U_k(x) \;=\; \frac{\sin\big((k+1)\theta\big)}{\sin\theta}, \qquad x = \cos\theta.

With this name the chain-rule output is

Tk(x)  =  kUk1(x).T_k'(x) \;=\; k\, U_{k-1}(x).

That is the first identity.

Step 3: Express TjT_j back in the UU basis

To finish the derivation we need to translate between the two bases. The product-to-sum formula for cos(jθ)sinθ\cos(j\theta)\sin\theta gives

2Tj(x)  =  Uj(x)Uj2(x)(j0,  U1=U2=0),2\, T_j(x) \;=\; U_j(x) - U_{j-2}(x) \qquad (j \ge 0,\; U_{-1} = U_{-2} = 0),

i.e., a TjT_j is the half-difference of two consecutive UU’s.

Now differentiate pn=kckTkp_n = \sum_k c_k T_k term by term with the first identity,

pn(x)  =  k=1nkckUk1(x).p_n'(x) \;=\; \sum_{k=1}^n k\, c_k\, U_{k-1}(x).

On the other hand, writing pn=jcjTjp_n' = \sum_j c'_j\, T_j and substituting the second identity in the form Tj=12(UjUj2)T_j = \tfrac{1}{2}(U_j - U_{j-2}),

pn(x)  =  jcjTj(x)  =  jcjcj+22Uj(x).p_n'(x) \;=\; \sum_j c'_j\, T_j(x) \;=\; \sum_j \frac{c'_j - c'_{j+2}}{2}\, U_j(x).

The polynomial pnp_n' has the same expansion in the UU basis under both forms, so the coefficients of each UjU_j must match. Reindex the first sum by k=m+1k = m + 1 so that Uk1=UmU_{k-1} = U_m contributes (m+1)cm+1(m+1)\, c_{m+1} to the coefficient of UmU_m. Matching,

cmcm+22  =  (m+1)cm+1cm  =  cm+2+2(m+1)cm+1.\frac{c'_m - c'_{m+2}}{2} \;=\; (m+1)\, c_{m+1} \quad\Longleftrightarrow\quad c'_m \;=\; c'_{m+2} + 2(m+1)\, c_{m+1}.

Setting k=m+1k = m + 1 gives the backward two-term recurrence stated below.

Proposition 1 (Coefficient-space differentiation)

Given the Chebyshev coefficients c0,c1,,cnc_0, c_1, \ldots, c_n of pnp_n, the coefficients c0,c1,,cn1c'_0, c'_1, \ldots, c'_{n-1} of pnp_n' satisfy

cn=0,cn1=2ncn,ck1  =  ck+1+2kck(k=n1,n2,,1),c'_n = 0, \qquad c'_{n-1} = 2 n\, c_n, \qquad c'_{k-1} \;=\; c'_{k+1} + 2 k\, c_k \quad (k = n-1, n-2, \ldots, 1),

and c0c'_0 is halved if one uses the convention with a doubled c0c_0 entry. The recurrence is exact for pnPnp_n \in \mathbb{P}_n.

This is differentiation in the coefficient basis. In matrix terms, the operator is the strictly upper-triangular, banded matrix

D  =  (0103050040800006010),\mathcal{D} \;=\; \begin{pmatrix} 0 & 1 & 0 & 3 & 0 & 5 & \cdots \\ 0 & 0 & 4 & 0 & 8 & 0 & \cdots \\ 0 & 0 & 0 & 6 & 0 & 10 & \cdots \\ & & & & \ddots & & \end{pmatrix},

with non-trivial entries only on every other super-diagonal.

Source
<Figure size 550x500 with 1 Axes>

Applying D\mathcal{D} costs O(N)O(N) because of the bandedness. The two DCTs that go from values to coefficients and back each cost O(NlogN)O(N \log N), so the whole values \to derivative-values pipeline is O(NlogN)O(N \log N).

Differentiation in the Value Basis

In the Lagrange (value) basis the polynomial is

pn(x)=j=0nfjj(x),p_n(x) = \sum_{j=0}^n f_j\, \ell_j(x),

so

pn(x)=j=0nfjj(x).p_n'(x) = \sum_{j=0}^n f_j\, \ell_j'(x).

Evaluating pnp_n' at the same nodes xix_i gives

pn(xi)  =  j=0nj(xi)fj.p_n'(x_i) \;=\; \sum_{j=0}^n \ell_j'(x_i)\, f_j.

This is a matrix-vector product. Define the value-space differentiation matrix DR(n+1)×(n+1)D \in \mathbb{R}^{(n+1)\times(n+1)} by

Definition 1 (Value-space differentiation matrix)

Dij  =  j(xi),(Df)i  =  pn(xi).D_{ij} \;=\; \ell_j'(x_i), \qquad \big(D\,\mathbf{f}\big)_i \;=\; p_n'(x_i).

The entries of DD are determined entirely by the nodes, not by ff. Compute them once and you can differentiate any function sampled on those nodes by a single matrix-vector multiplication.

Closed-form entries from the barycentric formula

Recall from §1 that the barycentric form of the Lagrange basis is

j(x)  =  (x)λjxxj,(x)=k=0n(xxk),λj=1kj(xjxk).\ell_j(x) \;=\; \ell(x)\, \frac{\lambda_j}{x - x_j}, \qquad \ell(x) = \prod_{k=0}^n (x - x_k), \qquad \lambda_j = \frac{1}{\prod_{k \ne j}(x_j - x_k)}.

Differentiating j\ell_j by the product rule and evaluating at x=xix = x_i with iji \ne j, the term containing (xi)=0\ell(x_i) = 0 drops out and one obtains, after some algebra,

j(xi)  =  λjλi1xixj,ij.\ell_j'(x_i) \;=\; \frac{\lambda_j}{\lambda_i}\,\frac{1}{x_i - x_j}, \qquad i \ne j.

The diagonal entries follow from a separate trick: since the constant function 1 is its own interpolant, jj(x)1\sum_j \ell_j(x) \equiv 1, so differentiating gives jj(x)0\sum_j \ell_j'(x) \equiv 0. Evaluated at x=xix = x_i, this says the rows of DD sum to zero:

Dii  =  kiDik.D_{ii} \;=\; -\sum_{k \ne i} D_{ik}.

Proposition 2 (Entries of DD)

For any distinct nodes x0,,xnx_0, \ldots, x_n with barycentric weights λj\lambda_j,

Dij  =  {λj/λixixj,ij,kiDik,i=j.D_{ij} \;=\; \begin{cases} \dfrac{\lambda_j / \lambda_i}{x_i - x_j}, & i \ne j, \\[1ex] \displaystyle -\sum_{k \ne i} D_{ik}, & i = j. \end{cases}

For Chebyshev nodes xj=cos(jπ/n)x_j = \cos(j\pi/n) the barycentric weights are λj=(1)jδj\lambda_j = (-1)^j \delta_j with δ0=δn=12\delta_0 = \delta_n = \tfrac12 and δj=1\delta_j = 1 otherwise, so the formula evaluates without any extra work. The value-space matrix DD is dense: every output value pn(xi)p_n'(x_i) depends on every input value fjf_j. That is the price of using a global interpolant.

Source
<Figure size 1100x440 with 3 Axes>

The left panel is the structure of DD at N=16N = 16: every entry is nonzero, and the corner entries dominate (the (0,0)(0,0) and (N,N)(N,N) entries equal ±(2N2+1)/6\pm (2N^2 + 1)/6). Those large boundary entries are exactly what allows boundary conditions to influence the interior in spectral BVP solvers (§7).

The right panel is convergence on f(x)=esin5xf(x) = e^{\sin 5x}, an entire function. Centered differences drop algebraically as N2N^{-2}. Chebyshev differentiation drops geometrically: it reaches machine precision near N30N \approx 30 and stays there. By the regularity-decay dictionary, the differentiation error inherits the convergence rate of pnfp_n \to f, with at most a single power of NN lost in differentiation. Same dictionary also predicts that on a non-smooth ff both schemes drop to algebraic and the spectral edge disappears.

Compare to the coefficient-space matrix above: the value-space matrix has every entry nonzero, so applying DD costs O(N2)O(N^2), while the coefficient-space pipeline costs O(NlogN)O(N \log N). Both bases produce the same derivative to within rounding error.

Source
<Figure size 1100x440 with 2 Axes>
max |D f - C^(-1) D_coeff C f|  =  1.39e+01

Two basis choices, two completely different sparsity patterns, identical answer to within rounding error.

Choose the Basis That Makes the Operation Easy

The bigger point of this section is one we will keep returning to. Polynomial calculus offers us a choice of representation for every operation, and we are free to pick whichever is cheapest. Sampling a function and multiplying two polynomials pointwise are easy in the value basis. Reading off smoothness from coefficient decay, truncating to degree nn, and integrating against the Chebyshev weight (as we saw in §4) are easy in the coefficient basis. Translating between the two costs a single DCT, that is O(NlogN)O(N \log N), so we move freely between them.

The same tension will reappear in later sections. Finding polynomial roots via an eigenvalue problem (§6) produces a sparse, well-conditioned matrix in the Chebyshev basis and an ill-conditioned one in the monomial basis. Spectral BVP solvers (§7) turn on exactly the same choice: value-space collocation gives a dense system, while a coefficient-space (ultraspherical) representation gives a banded one. In both cases, picking the right basis is what turns an intractable problem into a practical one.