How are piecewise cubic spline bases constructed? There are words from the The Elements of Statistical Learning on page 119:

It is not hard to show that the following basis represents a cubic spline with     knots at $\xi_1$ and $\xi_2$:



*

*$h_1(X)=1$ 

*$h_2(X)=X$

*$h_3(X)=X^2$

*$h_4(X)=X^3$

*$h_5(X)=(X-\xi_1)_+^3$

*$h_6(X)=(X-\xi_2)_+^3$


Then my question is that, according to the numeric analysis, piecewise cubic polynominals tries to fit the function in region $[\xi_1,\xi_2]$ with polynomials at order 3, so I think the basis should be


*

*$h_1(X)=f(\xi_1)$

*$h_2(X)=(X-\xi_1)$

*$h_3(X)=(X-\xi_1)^2$

*$h_4(X)=(X-\xi_1)^3$.


There are at most 4 basis, so where am I wrong?
 A: Look at a simpler problem: construct a basis for the space of piecewise constant functions whose values are allowed to break at the knots.  With two knots, that's three intervals.  One basis would consist of (a) the function that equals $1$ for all arguments less than or equal to $\xi_1$ and otherwise is $0$, (b) the function equal to $1$ for all arguments from $\xi_1$ through $\xi_2$ and otherwise is $0$, and (c) the function equal to $1$ for all arguments greater than $\xi_2$ but otherwise is $0$.  However, there's another way.  The idea is to let the basis elements encode the jumps that occur at the knots.  The first basis element therefore is a constant function, say $1$, regardless of the knots.   The second basis element encodes a jump at $\xi_1$.  It's convenient to take it to equal $0$ for values less than or equal to $\xi_1$ and to equal $1$ for larger values.  Let's call this function $H_{\xi_1}$.  The third basis element can be taken to be $H_{\xi_2}$.
For example, the piecewise constant function that jumps from $48$ to $-120$ and then to $240$ at knots $\xi_1 = 2$ and $\xi_2 = 4$ can be written as $48 -168H_2 + 360H_4$: in this form, it reveals itself explicitly as a jump of $-168$ at $\xi_1=2$ followed by a jump of $+360$ at $\xi_2=4$, after starting from a baseline value of $48$.

Here is a piecewise constant spline with two knots.  It is determined by its three levels or, equivalently, by a "baseline" level and two jumps.
It should be clear that although the space of constant functions has dimension $1$, the space of piecewise constant functions with $k\ge 0$ knots has dimension $k+1$: one for a "baseline" constant plus $k$ more dimensions, one for each possible jump.
Cubic splines are obtained by integrating piecewise constant functions three times.  This introduces three constants of integration.  We can absorb them into the integral of the constant function.  This gives a "baseline" cubic spanned by $1$, $x$, $x^2$, and $x^3$.  Modulo these constants of integration, the integral of $H_{\xi}$ is $\frac{1}{3!}(x-\xi)_+^3$: its third derivative jumps by $1$ at the value $\xi$ and otherwise is constant (equal to $0$ to the left of $\xi$ and $1$ to the right of $\xi$).  The basis named in the quotation merely rescales these functions by $3!$.

Here is a third integral of the preceding piecewise constant function.  Notice that no cubic polynomial possibly can behave this way (it cannot have two flat or nearly-flat sections).  Splines are inherently more flexible than polynomials of the same degree; they span a higher-dimensional space of functions.
It should now be obvious how to extend this formulation to any number of knots and to any degree of splines.  Understanding the procedure can be useful when you need non-standard splines for specific problems.  For instance, I recently had to develop circular quadratic splines for a regression that involved an angular independent variable (an orientation in the plane modulo $180$ degrees).
