- #1
SherlockOhms
- 310
- 0
Homework Statement
I'm trying to derive the coefficient matrix (a) of a parabolically terminated cubic spline. This is the matrix of coefficients ##a_i \rightarrow a_n## where n is the number of data points provided.
With this matrix you can find all the other coefficients (b and c) that define the spline using: $$b_i = \frac{y_i}{h_i} - a_i h_i$$ where ##y_i## is the corresponding value of the given set of y values and ##h_i## is defined as ##x_{i + 1} - x_i##.
The ##a## coefficients (n in total) satisfy the following n - 2 linear equations: $$h_1 a_i + 2(h_{i + 1} + h_i)a_{i + 1} + h_{i + 1}a_{i + 1} = \frac{y_{i + 2} - y_{i + 1}}{h_{i + 1}} - \frac{y_{i + 1} - y_i}{h_i}$$
So, you have n coefficients and n - 2 equations. Therefore, you need 2 extra equations to be able to solve the system.
For a natural cubic spline these end conditions are ##a_1## = 0 and ##a_n## = 0. So, you can then write the system in the form: ##Ma = d##. Where, ##M## is a tridiagonal matrix of ##h_i## along it's sub diagonal (n - 1 in length), ##h_{i + 1}## along it's super diagonal (n - 1 in length) and ## 2(h_{i + 1} + h_i)## along it's main diagonal (n in length). Thus an n x n matrix is produced. Then ##a## is the coefficient matrix of ##a_i \rightarrow a_n## (n x 1) and ##d## is the n x 1 vector filled with ## \frac{y_{i + 2} - y_{i + 1}}{h_{i + 1}} - \frac{y_{i + 1} - y_i}{h_i}##. Incorporating the extra conditions in, the first and last rows of matrix M will be 1 0 0 ... and ...0 0 0 1 respectively. As well as the first and last rows of the vector ##d## being 0. This ensures that ##a_1## and ##a_n## = 0.
So, my question is, when writing this linear system for a parabolically terminated cubic spline in matrix form, who's end conditions are ##-a_1 + a_2 = 0## and ##-a_{n-1} + a_n = 0##, how do the first and last rows of M and d change? I've outlined above how the matrices are set up for the given conditions ##a_1## = 0 and ##a_n## = 0, and I just wnat to know how they change with these new conditions.
Homework Equations
All above.
The Attempt at a Solution
All above.