Consider an approximation of a periodic function sampled at N discrete points $x_0, x_1, ... , x_{N−1}$. We now suppose that the sequence is repeated on both sides of the interval as shown in the figure below for n = 7.

As we can see,$f_{N−1} = f_0$. We can no longer use natural splines with zero curvature at the ends if the interval. Instead, we must impose continuity of the first and second derivatives: $$f_0'(x_0) = f_{N-2}'(x_{N-1})$$, $$f_0''(x_0) = f_{N-2}''(x_{N-1})$$ The last equation can be used to eliminate the extra variable ($f_{N−2}''$), so only $n = N − 1$ equations are needed rather than N.
Our task is to derive a method and write a code to compute a set the interpolation polynomials known as periodic splines. There are two steps to complete. First, write the equations for the unknowns $f′′_i$. We will end up with a matrix that has a nonzero element in the upper right corner that looks like the attached image.
What I tried:
I started " ( h_i = x_{i+1} - x_i ).
Given the natural cubic spline equations for each interval ( [x_i, x_{i+1}] ):
[ f_i(x) = a_i(x - x_i)^3 + b_i(x - x_i)^2 + c_i(x - x_i) + d_i ]
Taking the second derivative of ( f_i(x) ), we get:
[ f''_i(x) = 6a_i(x - x_i) + 2b_i ]
Now, at the endpoints ( x_0 ) and ( x_{N-1} ), we have:
[ \begin{align*} f''_0(x_0) &= 2b_0 \\ f''_{N-2}(x_{N-1}) &= 6a_{N-2}(x_{N-1} - x_{N-2}) + 2b_{N-2} \end{align*} ]
From the continuity conditions, we have:
[ \begin{align*} 2b_0 &= 6a_{N-2}(x_{N-1} - x_{N-2}) + 2b_{N-2} \end{align*} ]
Rearranging terms and solving for ( b_{N-2} ), we get:
[ b_{N-2} = \frac{2b_0}{2} - 6a_{N-2}(x_{N-1} - x_{N-2}) ]
"
But don't understand how to get the matrix like that. Thanks for the help. I request help to proceed.

Repeating Cubic Spline Curve
A curve with $N$ cubic spline segments denoted $y_{i}(t)$, where $t=0\ldots1$ is a free parameter, is defined. At the same time, the end conditions must match the starting conditions in order for the curve to repeat with some periodicity.
Assume that each node is defined at a fixed distance $h$ apart from the previous one such that the i-th spline spans between the nodes $Y_{i-1}$ and $Y_{i}$. The $x(t)$ coordinate of each spline is given by the linear interpolation function ${\rm lerp}(A,B,t)=\left(1-t\right)A+t\,B$
$$\begin{aligned}x_{i}(t) & ={\rm lerp}(X_{i-1},X_{i},t)\\ y_{i}(t) & ={\rm spline}(Y_{i-1},Y_{i},\ddot{Y}_{i-1},\ddot{Y}_{i},t) \end{aligned} \tag{1}$$
here each node position is given by a fixed increment $X_{i}=X_{i-1}+h$, and all the node values $Y_{i}$ must be known to solve this problem.
Solving this problem means calculating all the node curvature values $\ddot{Y}_{i}$ based on the boundary conditions, and the following continuity condition $$\lim_{t\rightarrow1}\tfrac{1}{h}\tfrac{{\rm d}}{{\rm d}t}y_{i-1}(t)=\lim_{t\rightarrow0}\tfrac{1}{h}\tfrac{{\rm d}}{{\rm d}t}y_{i}(t) \tag{2}$$
The general definition for a spline is
$$\boxed{{\rm spline}(A,B,C,D,t)=\left(1-t\right)A+t\,B+\tfrac{h^{2}t\left(1-t\right)\left(t-2\right)}{6}C+\tfrac{h^{2}t\left(1+t\right)\left(t-1\right)}{6}D}$$ where $A$, $B$ are the node value coefficients and $C$, $D$ the node curvature conditions.
For reference, the slope a spline is $${\rm slope}(A,B,C,D,t)=\text{-}\tfrac{1}{h}A+\tfrac{1}{h}\,B+\tfrac{h^{2}\left(3t^{2}-6t+2\right)}{6}C+\tfrac{h^{2}\left(3t^{2}-1\right)}{6}D \tag{3}$$
Problem Setup
Specifically for $N=6$ the six continuity equations definte the following system of equations $$h\begin{bmatrix}\text{-}\tfrac{2}{3} & \text{-}\tfrac{1}{6} & & & & & \text{-}\tfrac{1}{6}\\ \text{-}\tfrac{1}{6} & \text{-}\tfrac{2}{3} & \text{-}\tfrac{1}{6}\\ & \text{-}\tfrac{1}{6} & \text{-}\tfrac{2}{3} & \text{-}\tfrac{1}{6}\\ & & \text{-}\tfrac{1}{6} & \text{-}\tfrac{2}{3} & \text{-}\tfrac{1}{6}\\ & & & \text{-}\tfrac{1}{6} & \text{-}\tfrac{2}{3} & \text{-}\tfrac{1}{6}\\ & & & & \text{-}\tfrac{1}{6} & \text{-}\tfrac{2}{3} & \text{-}\tfrac{1}{6}\\ \text{-}\tfrac{1}{6} & & & & & \text{-}\tfrac{1}{6} & \text{-}\tfrac{2}{3} \end{bmatrix}\begin{pmatrix}\ddot{Y}_{1}\\ \ddot{Y}_{2}\\ \ddot{Y}_{3}\\ \ddot{Y}_{4}\\ \ddot{Y}_{5}\\ \ddot{Y}_{6} \end{pmatrix}=\tfrac{1}{h}\begin{bmatrix}2 & \text{-}1\\ \text{-}1 & 2 & \text{-}1\\ & \text{-}1 & 2 & \text{-}1\\ & & \text{-}1 & 2 & \text{-}1\\ & & & \text{-}1 & 2 & \text{-}1\\ & & & & \text{-}1 & 2 \end{bmatrix}\begin{pmatrix}Y_{1}\\ Y_{2}\\ Y_{3}\\ Y_{4}\\ Y_{5}\\ Y_{6} \end{pmatrix} \tag{4}$$
with the direct solution
$$\begin{pmatrix}\ddot{Y}_{1}\\ \ddot{Y}_{2}\\ \ddot{Y}_{3}\\ \ddot{Y}_{4}\\ \ddot{Y}_{5}\\ \ddot{Y}_{6} \end{pmatrix}=\tfrac{1}{h^{2}}\begin{bmatrix}\text{-}4.4 & 2.8 & \mbox{-}0.8 & 0.4 & \mbox{-}0.8 & 2.8\\ 2.8 & \text{-}4.4 & 2.8 & \mbox{-}0.8 & 0.4 & \mbox{-}0.8\\ \mbox{-}0.8 & 2.8 & \text{-}4.4 & 2.8 & \mbox{-}0.8 & 0.4\\ 0.4 & \mbox{-}0.8 & 2.8 & \text{-}4.4 & 2.8 & \mbox{-}0.8\\ \mbox{-}0.8 & 0.4 & \mbox{-}0.8 & 2.8 & \text{-}4.4 & 2.8\\ 2.8 & \mbox{-}0.8 & 0.4 & \mbox{-}0.8 & 2.8 & \text{-}4.4 \end{bmatrix}\begin{pmatrix}Y_{1}\\ Y_{2}\\ Y_{3}\\ Y_{4}\\ Y_{5}\\ Y_{6} \end{pmatrix} \tag{5}$$
Once all the $\ddot{Y}_i$ coefficients are known, use equations (1) to draw the curve.