# comp.graphics.algorithms

## Subject: b-spline problem

I'm trying to find a B-spline over [-2, 2]:

S(x) = {
S0 = a0 + b0 (x + 2) + c0 (x+2)^2 + d0 (x+2)^3 for x in [-2, -1]
S1 = a1 + b1 (x + 1) + c1 (x+1)^2 + d1 (x+1)^3 for x in (-1, 0]
S2 = a2 + b2 (x) + c2 (x)^2 + d2 (x)^3 for x in (0,
1]
S3 = a3 + b3 (x -1) + c3 (x-1)^2 + d3 (x-1)^3 for x in (1, 2]
}

based on the following constraints:

1. Five nodes, so four cubic polynomials, evenly spaced x0, x1, x2, x3, x4.
The B-spline need only pass through the points (x0 = -2, 0), (x2 = 0, 1),
(x4 = 2, 0). (3 equations)

2. Continuity at each node. (3 equations)
3. Continuity in derivative at each node. (3 equations)
4. Continuity in 2nd derivative at each node. (3 equations)
5. Boundary conditions: First and second derivatives are zero on both ends
(4 equations)

So I have 16 equations and 16 unknowns, so I should be able to solve for
this. However, writing the equations out and solving the system on a
computer, the resulting polynomials don't always satisfy my constraints.

Is something wrong with my representation? Thanks in advance.

Here is what I did:

// left boundary conditions
S0(-2) = 0 ==> a0 = 0
S0'(-2) = 0 ==> b0 = 0
S0''(-2) = 0 ==> c0 = 0

// continuity across x1 = -1
S0(-1) = S1(-1) ==> d0 = a1
S0'(-1) = S1'(-1) ==> 3d0 = b1
S0''(-1) = S1''(-1) ==> 6d0 = 2c1

// continuity across x2 = 0
S1(0) = S2(0) ==> a1 + b1 + c1 + d1 = a2
S1'(0) = S2'(0) ==> b1 + 2c1 + 3d1 = b2
S1''(0) = S2''(0) ==> 2c1 + 6d1 = 2c2

Also, S1(0) = S2(0) = 1

// continuity across x3 = 1
S2(1) = S3(1) ==> a2 + b2 + c2 + d2 = a3
S2'(1) = S3'(1) ==> b2 + 2c2 + 3d2 = b3
S2''(1) = S3''(1) ==> 2c2 + 6d2 = 2c3

// Right boundary conditions
S3(2) = 0 ==> a3 + b3 + c3 + d3 = 0
S3'(2) = 0 ==> b3 + 2c3 + 3d3 = 0
S3''(2) = 0 ==> 2c3 + 6d3 = 0