Cubic B-Spline interpolation The equation for B-spline with control points $(P_0, P_1,\dots,P_n)$ is 
\begin{equation}
P(t)=\sum_{i=0}^n B_{i,k}(t)P_i
\end{equation}
If I have the following knots: $1,2,3,4$ and the following control points: $P_1=0$, $P_2=-1$, $P_3=1$ and $P_4=2$. Since I have uniform knots as it has been suggested I used the basis functions and I shift them $2$ units to the right. So after doing some calculations the shifted basis functions are:
$B_0(u-2)=(27-u^3-27u+9u^2)/6$
$B_1(u-2)=(3u^3-24u^2+60u-44)/6$  
$B_2(u-2)=(-3u^3+21u^2-45u+37)/6$  
$B_3(u-2)=(u^3-6u^2+12u-8)/6$  
Then I put everything into the equation of $P(t)$ like this:
$P(t)=0\times B_0(u-2)-1\times B_1(u-2)+1 \times B_2(u-2)+2 \times B_3(u-2)$
Then I substituted the knot point t=1 into $P(t)$, i.e. $P(1)$. The result of $P(1)\neq0$. I was expecting that I will end up with zero because the spline in the end it has to be function that goes through the control points so we can check that. In my case is doesn't go through the control point so I did something wrong. Does anyone figure out what I did wrong?
 A: In general, a b-spline curve will not pass through any of its control points.
There is an example at the bottom of this web page, which explains how repeating knot values will cause a b-spline curve to pass through one of its control points. This technique is typically used with the first and last knots, to force the spline to pass through the first and last control points.
When you repeat knots, this changes the form of the b-spline basis functions, so the ones you cited will not be correct near repeated knots.
To evaluate a cubic b-spline on the interval $[0,1]$, you need a knot sequence that has at least two knot values to the left of 0, and at least two knots to the right of 1. These 6 knots together are needed to define the basis functions that are non-zero on $[0,1]$. So, the knot vector you mentioned $(1,2,3,4, \ldots)$ certainly will not work.
If you want a b-spline curve that passes through a sequence of given points, then you need to use an "interpolating" b-spline. You compute one of these by solving a system of linear equations to get its control points, as explained by @LutzL and on this page.
A: Call the cubic B-spline centered at zero $β_3$. Then a linear combination of B-splines is
$$
f(t)=\sum_{i=1}^nc_i\,β_3(x-i)
$$
On any interval $x\in[i,i+1]$, the value of $f$ is given by the polynomial basis functions discussed in https://math.stackexchange.com/a/700183/115115 as
$$
f(t)=B_0(x-i)c_{i-i}+B_1(x-i)c_{i}+B_2(x-i)c_{i+1}+B_3(x-i)c_{i+2}.
$$

One could use $c_i=P_i$, but $β_3(-1)=\frac16=β_3(1)$ and $β_3(0)=\frac23$, this would result in an averaged value $f(i)=\frac16(P_{i-1}+4P_i+P_{i+1})$. Sometimes this is acceptable.
If you want to achieve true interpolation, $f(i)=P_i$, you would have to solve $\frac16(c_{i-1}+4c_i+c_{i+1})=P_i$, for instance using the Gauß-Seidel iterative method.
