Applied Mathematics I - Spline example

advertisement

Applied Mathematics I - Spline example

Let us put a cubic spline through the points (0 ; 0) , (1 ; 1 ) (2 ; 0 : 5) and (3 ; 0) .

1.5

1

0.5

±0.5

0.5

1 1.5

2 2.5

3 3.5

±0.5

We shall assume that the spline meets the x ¡ axis at 45 ± will be de…ned by three curves.

at both ends The spline f

1

( x ) = a

1 x 3 f

2

( x ) = a

2 x 3 f

3

( x ) = a

3 x 3

+ b

1 x 2

+ b

2 x 2

+ b

3 x 2

+ c

1 x + d

1

; 0 < x < 1 ;

+ c

2 x + d

2

; 1 < x < 2 ;

+ c

3 x + d

3

; 2 < x < 3 :

At the point (0 ; 0) we have these constraints: f

1

(0) = 0 ; f

1

0 (0) = 1 ;

At (1 ; 1) we get f

1

(1) = 1 ; f

2

(1) = 1 ; f

1

0

00 f

1

(1) = f

2

0

00

(1) ;

(1) = f

2

(1) :

Similarly at (2 ; : 5) and (3 ; 0) we get: f

2

(2) = 0 : 5 ; f

3

(2) = 0 : 5 ; f

2

0

00 f

2

(2) = f

3

0

00

(2) ;

(2) = f

3

(2) ; and f

3

(3) = 0 ; f

3

0 (3) = ¡ 1 ;

This yields the following 12 equations in 12 unknowns.

0 ¢ a

1

+ 0 ¢ b

1

+ 0 ¢ c

1

+ d

1

= 0

3 ¢ 0 ¢ a

1

+ 2 ¢ 0 ¢ b

1

+ c

1

= 1

1 ¢ a

1

+ 1 ¢ b

1

+ 1 ¢ c

1

+ d

1

= 1

1 ¢ a

2

+ 1 ¢ b

2

+ 1 ¢ c

2

+ d

2

= 1

3 ¢ 1 ¢ a

1

+ 2 ¢ 1 ¢ b

1

+ c

1

= 3 ¢ 1 ¢ a

2

+ 2 ¢ 1 ¢ b

2

+ c

2

6 ¢ 1 ¢ a

1

+ 2 ¢ 1 ¢ b

1

= 6 ¢ 1 ¢ a

2

+ 2 ¢ 1 ¢ b

2

8 ¢ a

1

+ 4 ¢ b

1

+ 2 ¢ c

1

+ d

1

= : 5

8 ¢ a

2

+ 4 ¢ b

2

+ 2 ¢ c

2

+ d

2

= : 5

3 ¢ 4 ¢ a

2

+ 2 ¢ 3 ¢ b

2

+ c

2

= 3 ¢ 4 ¢ a

3

+ 2 ¢ 2 ¢ b

3

+ c

3

27 ¢ a

3

+ 9 ¢ b

3

+ 3 ¢ c

3

+ d

3

= 0

3 ¢ 9 ¢ a

3

+ 2 ¢ 3 ¢ b

3

+ c

3

= ¡ 1

2

These equations have the form below where all the unmarked entries are zero.

2 3 2 3 2 3

6

4

6

6

6

6

6

6

6

6

6

6

6

6

6

6

0 0 0 1

0 0 1 0

1 1 1 1

1 1 1 1

3 2 1 0 ¡ 3 ¡ 2 ¡ 1 0

6 2 0 0 ¡ 6 ¡ 2 0 0

8 4 2 1

8 4 2 1

12 4 1 0 ¡ 12 ¡ 4 ¡ 1 0

12 2 0 0 ¡ 12 ¡ 2 0 0

27 9 3 1

27 6 1 0

7

5

7

7

7

7

7

7

7

7

7

7

7

7

7

7

6

4

6

6

6

6

6

6

6

6

6

6

6

6

6

6

7

5

7

7

7

7

7

7

7

7

7

7

7

7

7

7

=

6

4

6

6

6

6

6

6

6

6

6

6

6

6

6

6 b

3 c

3 d

3 c

2 d

2 a

3 d

1 a

2 b

2 a

1 b

1 c

1

7

5

7

7

7

7

7

7

7

7

7

7

7

7

7

7

0

0

¡ 1

: 5

: 5

0

1

0

0

0

1

1

Rearranging the equations might make a better structure for the matrix. For example another arrangement is:

2 3 2 3 2 3

6

4

6

6

6

6

6

6

6

6

6

6

6

6

6

6

0 0 0 1

0 0 1 0

1 1 1 1

1 1 1 1

8 4 2 1

8 4 2 1

27 9 3 1

27 6 1 0

3 2 1 0 ¡ 3 ¡ 2 ¡ 1 0

12 4 1 0 ¡ 12 ¡ 4 ¡ 1 0

6 2 0 0 ¡ 6 ¡ 2 0 0

12 2 0 0 ¡ 12 ¡ 2 0 0

7

5

7

7

7

7

7

7

7

7

7

7

7

7

7

7

6

4

6

6

6

6

6

6

6

6

6

6

6

6

6

6

7

5

7

7

7

7

7

7

7

7

7

7

7

7

7

7

=

6

4

6

6

6

6

6

6

6

6

6

6

6

6

6

6 a

1 b

1 c

1 d

1 a

2 b

2 c

2 d

2 a

3 b

3 c

3 d

3

7

5

7

7

7

7

7

7

7

7

7

7

7

7

7

7

1

: 5

: 5

0

¡ 1

0

0

1

1

0

0

0

The solution is :

3

2 d

2 a

3 b

3 c

3 d

3 a

1 b

1 c

1 d

1 a

2 b

2 c

2

6

6

6

6

6

6

6

6

6

6

6

6

6

6

3

7

7

7

7

7

7

7

7

7

7

7

7

7

7

=

6

6

6

6

6

6

6

6

6

6

6

6

6

6

2

¡ :: 73333

: 73333

1

0

: 70000

¡ 3 : 5666

5 : 3000

¡ 1 : 43333

¡ : 56667

4 : 03333

¡ 9 : 90000

8 : 70000

3

7

7

7

7

7

7

7

7

7

7

7

7

7

7

The graph of the spline is:

1.5

1

0.5

±0.5

±0.5

0.5

1 1.5

2 2.5

3 3.5

4

Download