POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I...

83
POLYNOMIAL CURVE AND SURFACE FITTING APPROVED: Major Professor Minor Professor irector of the Department of Mathematics can of the Graduate School

Transcript of POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I...

Page 1: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

POLYNOMIAL CURVE AND SURFACE FITTING

APPROVED:

Major Professor ™

Minor Professor

irector of the Department of Mathematics

can of the Graduate School

Page 2: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

POLYNOMIAL CURVE AND SURFACE FITTING

THESIS

Presented to the Graduate CounciI of the

North Texas State University in Partial

Fulfillment of the Requirements

For the Degree of

MASTER OF SCIENCE

By

Ann Dowdy Capps, B. A.

Denton, Texas

January, 1968

Page 3: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

PREFACE

The main p rob lems of n u m e r i c a l a n a l y s i s i n v o l v e p e r f o r m i n g

a n a l y t i c a l o p e r a t i o n s , such as i n t e g r a t i o n , d i f f e r e n t i a t i o n , f i n d i n g

z e r o e s , i n t e r p o l a t i o n , and so f o r t h , of a f u n c t i o n when a l l t h e d a t a

a v a i l a b l e a r e some samples o f t h e f u n c t i o n . T h e r e f o r e , t h e pu rpose

o f t h i s paper i s t o i n v e s t i g a t e t h e f o l l o w i n g p rob lem: g i v e n a s e t

o f da ta p o i n t s ( x . , y . ) w h i c h a r e samples of some f u n c t i o n , d e t e n r i i n e

an a p p r o x i m a t i n g f u n c t i o n . F u r t h e r , ex tend t h e p rob lem t o t h a t of

d e t e r m i n i n g an a p p r o x i m a t i n g f u n c t i o n f o r a s u r f a c e g i v e n some samples

( x . , y . , z . . ) of t h e s u r f a c e .

• V 'J

The c l a s s of a p p r o x i m a t i n g f u n c t i o n s t o be I n v e s t i g a t e d is t h e

s e t g e n e r a t e d by l i n e a r c o m b i n a t i o n s o f 1, x , x 2 , . . . , x n ; t h a t i s ,

t h e s e t o f p o l y n o m i a l s . T h i s s e t is i m p o r t a n t f o r two reasons : 1) i f

P ( x ) i s an e l emen t o f t h e a p p r o x i m a t i n g s e t , t h e n P (x+k ) is an e lement

o f t h e s e t ; and 2) i f P ( x ) is an e lemen t o f t h e s e t t h e n P ( k x ) is a l s o

i n t h e s e t . In ( 1 ) , o n l y t h e c o e f f i c i e n t s o f P(x-i-k) d i f f e r f r o m P ( x ) ,

and (1 ) i m p l i e s t h a t t h e l o c a t i o n of t h e o r i g i n does n o t a f f e c t t h e

p rob lem of f i t t i n g a p o l y n o m i a l t o t h e d a t a . S ta temen t (2 ) i n d i c a t e s

t h a t s c a l e changes do n o t a f f e c t t h e p r o b l e m .

In C h a p t e r I , some methods a r e d e r i v e d f o r f i t t i n g an n"^' degree

p o l y n o m i a l t o (n+1) d a t a p o i n t s ( x . , y . ) . I n c l u d e d i n t h e s e e r e t h e

methods of Lagrange and Newton. In a d d i t i o n , t h e p r o c e d u r e of s o l v i n g

a sysTern o f n+1 l i n e a r e q u a t i o n s f o r t h e c o e f f i c i e n t s o f t h e p o l y n o m i a l

i i i

Page 4: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

IV

is d iscussed. Chapter I is concluded w i t h an i n v e s t i g a t i o n of curve

f i t t i n g by s p l i n e f u n c t i o n s . The d e f i n i t i o n f o r t h e se t of s p l i n e

f u n c t i o n s is g iven a long w i t h t h e proo fs of theorems which are necessary

f o r t h e u t i l i z a t i o n of t h e f u n c t i o n s .

In some cases where t h e data po in t s ( x . , y j ) a re known t o con ta i n

e r r o r f rom measurement, t h e method of l eas t squares curve f i t t i n g may be

u t i l i z e d . In Chapter I I , t h e method of l eas t squares f o r n ^ degree

po lynomia ls is de r i ved . In a d d i t i o n , procedures are cons idered where

r e s t r a i n t s a re placed on t he data p o i n t s such as we igh t i ng t h e da ta , o r

r e q u i r i n g t h a t t h e l eas t squares curve pass th rough s p e c i f i c p o i n t s .

F i n a I l y in Chapter I I I , t h e problem of f i t t i ng a su r face t o a se t

of data po in t s (x. , y . ,z . . ) is cons idered . The se t of cubic s p l i n e J ' J

f u n c t i o n s c f Chapter I is extended t o a se t of f u n c t i o n s of two v a r i -

ab les , and va r ious i heoreros o f t h e f i r s t chapter are extended in Chapter

I I I t o theorems concern ing b i c u b i c s p l i n e f u n c t i o n s . Chapter I I I is

concluded w i t h a mathematical procedure f o r computat ion of a b i c u b i c

spl i ne f u n c t i o n .

In each of t h e chap te r s , examples are inc luded f o r t h e t o p i c s

d iscussed. Since t h r e e of t h e t o p i c s i nvo l ve lengthy computa t ion , a

d i g i t a l computer was used as a means of c a l c u l a t i n g t h e examples. For

each of t hese , a computer program was w r i t t e n , and each has been

inc luded in t h e appendix s e c t i o n a long w i t h a d e s c r i p t i o n of how data

can be inpu t t o t h e program. The computat ion of a s p l i n e f u n c t i o n of

Chapter ! is shown in Appendix A. The procedures developed in Chapter

I I f o r l eas t squares curve f i t t i n g are programmed and are shown in

•Appendix B. F i n a l l y , the program f o r t h e mathematical procedure,

Page 5: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

descr ibed in Chapter I I I , t o determine a b i c u b i c s p l i n e f u n c t i o n

is i l l u s t r a t e d in Appendix C.

Page 6: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

TABLE OF CONTENTS

Chapter Page

I . METHODS OF POLYNOMIAL CURVE-FITTING 1

By Use of L inear Equations By t h e Formula of Lagrange By Newton's Formula Curve F i t t i n g by Sp i ine Funct ions

I I . METHOD OF LEAST SQUARES 24

Polynomials of Least Squares Least Squares Polynomial Approx imat ion w i t h

Restra i n ts

I I I . A METHOD OF SURFACE FITTING 37

B icub ic Sp l ine Funct ions Theorems t o Aid in Sp l ine Func t ion Computation Procedure f o r Computation of a Sp l ine Surface

APPENDIX A . . .

APPENDIX B 61

APPENDIX C

BIBLIOGRAPHY 77

v 1

Page 7: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

CHAPTER

METHODS OF POLYNOMIAL CURVE FITTING

By Use of L inear Equat ions

Given a se t of (n+1) data po in t s ( x . , y ) , where i = 0, 1 , . . . , n;

n a polynomial of degree n, P (x) = £ a .x 1 may be f i t t e d th rouch

n i =0 1

these p o i n t s . This polynomial may be determined by s imply s u b s t i t u t i n g

eacn p o i n t ( x . , y . ) i n t o t o o b t a i n n+1 l i n e a r equal ions in t h e n+1 unknowns, a 0 , a1, . . . , a n From Cramer's Rule of s o l v i n g l i n e a r

equat ions (3 , p. 83 ) , i f t h e determinant

?.

(1 -1 ) |V| =

xo xo*

X1 X1 • • • x

0 n

l

1 xn x R2 . . . x n

is not ze ro , a s o l u t i o n f o r aQ , an e x i s t s .

I h e o r e n M J ^ I f x j 4 Xj f o r i 4 j , t hen t h e va lue of t h e d e t e r -

minant (1 -1) is not zero .

F i r s t i t must be shown t h a t | v | i n (1-1) is t h e product of

a l l d i f f e r e n c e s Xj - x - f o r which i > j ; id e s t ,

C - 2 ) | V | = n (x j —x:). 0<j< i <n

For ri = 1, j V | = xx - x Q , which obv ious l y s a t i s f i e s ( 1 - 2 ) . Assume

equa t ion (1-2) is t r u e f o r n = k; t h a t i s ,

Page 8: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

( 1 - 3 )

Then fo r n = k+1

II (x. - x . ), 0 < j c i <_k 1 ^

|V| x f

X K + 1 • x0

k+1 • X1

X X2

' k+1 k + 1 " " k+1

The f o l l o w i n g is t r u e f o r determinants: i f t h e ma t r i x B is obta ined

from A by m u l t i p l y i n g a column of A by a constant and adding each

element of t h i s column t o another column of A then |B[ = |A[ (3, p. 75)

Thus,

( 1 - 4 ) |V| -

x0 0

x l ^ x i - x o )

x k+1 k+1 <x'

k+1 k+1 k+1 "X n )

where (1-4) is obtained by adding ( - x 0 ) t imes the (k+1) s

I

vk+2) column. Cont inu ing in t h i s manner,

1 0 0 . . . o

1 ( x i - x 0 ) X ^ X j - X q ) . . . x f ( x i - x 0 )

column t o the

1 " W ^ X M I X K + I X 0 '

This example may be expanded by co fac to rs t o y i e l d

( x r x 0 ) X ^ X J - X Q )

x k + i x k + T x » '

| v | (Xp-Xn) X p(X o —X n)

x i ( x r x o ' x2(x2~Xg)

( X k + l X ( ) ) X ' k+ i V f - ' x k + i x k+1

x n )

Page 9: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

Another "theorem of determinants s ta tes i f a ma t r i x B is obta ined from

A by m u l t i p l y i n g a row of A by a constant c , t h e n | B | = C |A | . There-

f o r e ,

(1-5) ( x i - x o ) ( x 2 - x o ) - - - ( xk + T x o )

Xi xf k

x i

1 x 2 A 2

1 xk+1 xk+1 • k

' • xk+1

( x 1 - x 0 ) ( x 2 - x 0 ) . . . ( x k + T x 0 ) | V ' | .

Now from t h e assumption in ( 1 - 3 ) , s ince the determinant [V»| in (1-5)

has (k+1) terms,

I V ' | = [ ( X 2 - X 1 ) ( X 3 - X L ) . . ( x k + T x 1 ) ] . [ ( x 3 - x 2 ) ( x 4 - x 2 ) . . ( x k + T x 2 )] . . [ ( x k + T x k ) ]

F i n a l l y from equat ions (1-5) and the d e f i n i t i o n of [ V ' | , f o r each

p o s i t i v e in teger n, equat ion (1-3) is t r u e ; t hus ,

( 1 ~ 6 ) | v | = n ( x . - x . ) . 0<j < i <n

By hypothes is , x. ^ x . f o r i ^ j . There fo re , each f a c t o r in (1-6)

is nonzero and |V[ 4 0. V is known as t h e Vandermonde m a t r i x .

Example 1: Consider t he f o l l o w i n g po in ts ( 0 , . 9 9 9 ) , ( 30 , .5000 ) ,

(60 , .8660) , (90 ,1 .000) . A cubic may be f i t t e d t o these po in t s by

determin ing the unknowns aQ , a^, a 2 , a 3 in t he general cub ic .

y ~ a0 + a l x + 92 x 2 4 a jX^.

The four r e s u l t i n g l i n e a r equat ions are

a 0 = 0.000

a0 + 30aj + 900a2 + 27000a3 = 0.500

a0 + 50ej 3600a- + 216000a3 = 0.866

a0 4 90a } + 8100a2 + 729000a3 --- 1.000

Page 10: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

= - 6859-101 ; a1 = - . 6 0 0 0 * 1 0 " 6

| VJ = [ ( 3 0 - 0 ) (60-0) (90 -0 ) ] . [ (60 -30) (90-30) ] - [ (90-60)1

= C162* 1 0 3 ) ( 1 8 - 1 0 2 ) ( 3 - 1 0 ) - 8748-106 .

By Cramer's Rule

1 0 0 0

1 .500 900 27000

1 .866 3600 216000

1 1.000 8100 729000

S i m i l a r l y , s o l v i n g f o r a 2 and a 3 y i e l d s

y = 0 + .1781 -10" 1 x - .1999-10~4x2 - .6000• 10~Gx3.

As a check, cons ider t h e p o i n t (30, .5000) .

y = 0+ ( . 1781 • 10-1 ) ( . 3 - 1 0 2 ) + (~. 1999- 10_ l f) ( . 9 * 103)-f ( - . 6 - 1 0 ~ 5 ) ( . 2 7 ' 105)

= ( .5343 > + ( - . 1799•1Q- 1 ) + ( - .1620•10~ 1 ) = .5000.

By t h e Formula of Lagrange

Other methods e x i s t f o r f i t t i n g an n"^ degree polynomial th rough

a s e t of (n+1) p o i n t s . One such method is t h a t of Lagrange.

Given (n+1) va lues of a f u n c t i o n ( x Q , y 0 ) , (x1,yL),...,(xn,y ) a

f u n c t i o n pass ing th rough these p o i n t s , of t h e form

P n ( x ) = A 0 ( x - x ! ) ( x - x 2 ) ( x ~ x 3 ) . . . ( x - x n )

(1 -7 ) + A X ( x - x 0 ) ( x - x 2 ) ( x - x 3 ) . . . ( x - x R )

+ A n ( x ~ x 0 ) ( x - x x ) ( x - x 2 ) . . . ( x - x j ) ,

may be determined. C l e a r l y each te rm of (1 -7 ) is a polynomial of

degree n; t hus P n ( x ) is a polynomial of degree n. The constants AQ,

A ^ . . . , An may be determined by r e q u i r i n g t h a t each of t h e (n+1)

po in t s s a t i s f y ( 1 - 7 ) .

Page 11: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

L e t t i n g ( x Q , y 0 ) be a s o l u t i o n of P n ( x ) , yQ = A „ ( x - x ) ( x - x )

( x 0~ xn

) -> a n d

J/JL A0 - ( x 0 - x 1 ) ( x 0 - x 2 ) . . . ( x 0 - x )

S i m i l a r l y , l e t t i n g each of ( x ^ y ^ , ( x 2 , y 2 ) , . . . , ( xn > Y n ) be a s o l u t i o n

f o r ( 1 - 7 ) ,

_Yi_ A i = ( x

1 - x o > < x1 - x

2) - - - ( x r x

n) >

A2 = Cx2-x0 ) ( x g - X j ) . . . ( x 2 - x ) ,

An = ' V V ' V V - ' W l 1 '

Then f rom these equa t ions f o r AQ, A 1 , A , t h e fo rmula f o r Lagrange

is ^ 3 ) (x **xp ) . . , (X—Xp ) • yQ (X~-Xfl ) (x—x > ) . »« (x~ Xp ) * yi

pn

( x ) = T x 0 - x 7 H ^ - x 2 T ~ T ( ^ ~ > ^ ) + • ( T - x o ) ( x i ^TTTTTG^) (1 -8 )

(x-xp ) (x—Xi ) . . . (x-Xn-1 ) t yn

+ ( x n - x 0 ) ( ^ - x 1 ) . r . ( ^ - ^ l _ 1 ) .

ExampIe 2 . Lagrange's Method y i e l d s t h e f o l l o w i n g equa t i on f o r

( 0 , . 0 0 0 0 ) , ( 3 0 , . 5 0 0 0 ) , ( 6 0 , . 8 6 6 0 ) , ( 9 0 , 1 . 0 0 0 ) .

( x - 3 0 ) ( x - 6 0 ) ( x ~ 9 0 ) « 0 ( x - 0 ) ( x - 6 0 ) ( x - 9 0 ) . .5000 P 3 ( x ) = ( 0 - 3 0 ) ( 0 - 6 0 ) ( 0 - 9 0 ) + ( 3 0 - 0 ) ( 3 0 - 6 0 ) ( 3 0 - 9 0 )

( x - 0 ) ( x - 3 0 ) ( x - 9 0 ) - .8660 ( x - 0 ) ( x - 3 0 ) ( x - 6 0 ) . 1.000 + (60 -0 ) (60 -307 (60 -90 ) + ( 9 0 - 0 ) ( 9 0 - 3 0 ) ( 9 0 - 6 0 )

.5000 .8660 = 54000 [x (x -60) ( x -90 ) ] - 54000 [ (x) (x-30) (x-60)]

1 + 162000 [ (x ) ( x -30) ( x -60 ) ] .

As a check,

.5000 .5000'54000 P3 C30) - 54000 [30(30-60) (30-90) ] = " 54000 " " = .5000.

The of her t h ree po i n ts check in a s i m i l a r way.

Page 12: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

By Newton's Formula

New+on's Formula is s t i l l ano ther way of w r i t i n g a p o l y n o m i a l .

I t i s use fu l i n t h a t t h e number o f p o i n t s can be increased w i t h o u t

r e p e a t i n g a l l c o m p u t a t i o n . Let ( x Q , y 0 ) , (x , y ) , . . . , ( * n > y n ) be

n+1 p o i n t s t h rough which t h e n+h degree po lynomia l Pn(><) is passed.

P (x ) can be expressed as

(1 -9 ) P ( x ) - y + ( x - x )P , ( x ) , n 'o o n-1

where P _-| (x ) i s a po lynomia l o f degree n - 1 . I t is obv ious f rom (1 -9 )

t h a t F3n(XQ) ~ yQ • Thus t h e prob lem reduces t o d e t e r m i n i n g t h e p o l y -

nomial P n _ i ( x ) . Now f rom ( 1 - 9 ) ,

Pn_! f x ) - Poi2S2zttL ( x - x 0 )

Thus t h e f o l l o w i n g must be t r u e f o r i = 1, 2, . . . , n:

^n 1 ^X i ^ ~ Pn x i )~Pn ^xn ) ~ Yi ~Yn > x i ~ x o x i ' x o

which means t h a t Pn__| (x ) passes t h rough t h e p o i n t s o f t h e fo rm

^ x j ' Vi~Vn ^• The v a l u e s y ; - y n a r e c a l l e d " d i v i d e d d i f f e r e n c e s " x, -xQ x. -xQ

and w i l l be denoted by [ x . , x Q ] .

S i m i l a r l y ,

(1 -10) pn - 1 ( x ) = [ x i ' x

0] + < X " V P n - 2 ( x ) '

where Pp_2 ^ x ) * s 3 po lynomia l of degree n - 2 .

Then P . (x ) = [x , x ] and f o r i = 2, 3 , . . . , n, P (x) is f rom n—• l l u n -2

( 1 - 1 0 )

f h - 1 ( x ) - [ x 1 , x 0 ] Pn_2 (x) = x - x x

Page 13: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

and

Pn-1 (x; ) - [ x , , x n ] [xT , x n ] - [ x i , x n ]

( t - m P „ . 2 ( > < i , = V x i = V * i

t h e l a s t te rm in (1-11) is the d i v i d e d d i f f e r e n c e of t h e d i v i ded

d i f f e r e n c e and is denoted by [ x . , , x ] .

By express ing each succeeding polynomial in terms of a polynomial

whose degree is less by one, t h e f o l l o w i n g general express ion is

de r i ved :

d - 1 2 ) P . ( x ) = [ x - , x ,_ 1 , . . , x ] + ( x - x ; ) P ( x ) , J J J 1 0 J n - ( j + 1)

where 1 <_ j <_ n-1 and i - j , j + 1 , . . . , n.

By s u b s t i t u t i n g each of these equat ions i n t o ( 1 - 9 ) , Newton's

fo rmula is

(1-13) y ( x ) = y 0 + ( x - x 0 ) [ [ x 1 , x 0 ] + ( x - x 1 ) { [ x 2 , x 1 , x 0 ] + ( x - x 2 ) { . . . } } ] .

A t a b l e may be cons t ruc ted t o c a l c u l a t e t h e d i v i d e d d i f f e r e n c e s :

X V 0 0 r [ V x o ]

X I Y1 t X 2 ' X l ' X 0 ]

[ X 2 ' X 0 ] [ X 3 ' X 2 ' X ] ' X 0 ]

X2 , [ X 3 ' X l f x 0 ]

X y [ ^ • X » ,

3 3 • * •

• * •

ExampIe : By us ing t h e data of Example 1, determine a cub ic poly-

nomial passing th rough the data by Newton's Method.

0 .0000 .01067

30 .5000 .00012 .01444 .00000

60 .8660 .00000 . 0 1 1 1 1

90 1.0000

Page 14: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

8

Thus,

y ( x ) = 0 + ( x - 0 ) { , 0 1 6 6 7 + ( x - 3 0 ) [ . 0 0 0 0 0 + ( x - 6 0 ) ( . 0 0 0 0 ) ] } .

Check: y(30) - 301.01667] = .5001.

From t h e d e r i v a t i o n o f t h e fo rmu la , t h e po in t s f o r t h e t a b l e do

not n e c e s s a r i l y need t o be in numerical o r d e r . Thus a p o i n t may be

added a t the bottom of t h e t a b l e and t h e next h igher o rder degree p o l y -

nomial may be computed f rom the a l t e r e d t a b l e .

ExampIe 4; Given t he po in t s ( 2 , 8 ) , ( 0 , 0 ) , (3 ,27) t h e f o l l o w i n g

t a b l e is c o n s t r u c t e d .

2 8 4

0 0 5 19

3 27

Thus t h e approx imat ing polynomial is

y ( x ) = 8 + ( x - 2 ) [ 4 + ( x - 0 ) 5 ] = 3x 2 - 6x .

Now (1 ,1 ) may be added t o t h e t a b l e and [Xg,Xg] , [ x 3 , x 1 , x 0 ] , and

[ x 3 , x 2 , X p x „ ] c a l c u l a t e d . Then t h e va lues f o r de te rmin ing a cubic

appear i n t he tab Ie:

2 8

0 0

3 27

1 1

4

19

7

There fo re ,

y ( x ) = 8+ (x -2 ) {4+x [5+(x -3)1 ] }

- 8+(x--2) (x2h 2x+4)

= v 3

Page 15: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

Theorem 1 .2 . Given n+1 sample p o i n t s , t h e c o r r e s p o n d i n g n"^ degree

po l ynom ia l pass ing t h r o u g h t h e p o i n t s i s u n i q u e l y de te rm ined .

P r o o f : Assume t h e po l ynomia l y ( x ) is o b t a i n e d by one method of

a p p r o x i m a t i o n f o r t h e n+1 sample p o i n t s ^ x Q J Y Q ^ • • •> (x ,y ) ,

and t h e po l ynomia l zCx) i s o b t a i n e d by u s i n g t h e same p o i n t s in a n o t h e r

method. The d i f f e r e n c e y ( x ) - z C x ) is a f most a po l ynomia l o f degree n.

y ( x . ) - z ( x . ) = 0 f o r i = 0 , 1, 2 , . . . , n, s i n c e ( x . , y . ) i s a s o l u t i o n

f o r both y ( x ) and z ( x ) . Thus y ( x ) - z ( x ) is a po l ynomia l hav ing t h e

f o l l o w i n g s o l u t i o n s : ( x 0 , O ) s ( x ^ O ) , . . . , (x , 0 ) . T h e r e f o r e y ( x ) - z ( x )

is t h e po l ynom ia l 0 . x ° , o r y ( x ) - z ( x ) = 0 . Thus y ( x ) = z ( x ) .

Curve F i t t i n g by S p l i n e F u n c t i o n s

The f o r e g o i n g methods i n d i c a t e ways o f f i t t i n g an n"l*h degree p o l y -

nomia l t o n+1 data p o i n t s . As n inc reases t h e number n o f l i n e a r

e q u a t i o n s which must be s o l v e d i n v o l v e c o e f f i c i e n t s o f l a rge magn i tude ;

x n . Thus a usual method i s t o f i t t h e data by means o f a s e t o f

p o l y n o m i a l s o f degree men such t h a t each s e t o f (m+1) c o n s e c u t i v e

p o i n t s i s f i t w i t h t h e c o r r e s p o n d i n g m"^ degree p o l y n o m i a l ; t h e (m+1)£^

p o i n t of t h e p r e c e d i n g po lynomia l becomes t h e f i r s t p o i n t o f t h e nex t

p o l y n o m i a l . Except f o r t h e common p o i n t , t h e c o n s e c u t i v e p o l y n o m i a l s

a r e independent o f each o t h e r , and t h e y u s u a l l y i n t r o d u c e d i s c o n t i n -

u i t i e s i n t h e f i r s t d e r i v a t i v e a t t h e j u n c t i o n p o i n t s . S p l i n e f u n c t i o n s

a r e d e f i n e d so t h a t t h e s e d i s c o n t i n u i t i e s do no t o c c u r .

Def f n i t ion : Given a s e t o f p o i n t s ( x . , y . ) , i = 0 , 1, 2 , . . . , n

where x Q < x 1 < . , . < x , a r e a l f u n c t i o n d e f i n e d f o r a l l r e a l x in an i n t e r -

v a l [ x , x n ] i s c a l l e d a s p l i n e f u n c t i o n of d a y e e k f o r t h e poj n t s and

denoted by P(x) i f t h e f o l l o w i n g p r o p e r t i e s a re t r u e :

Page 16: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

10

1) For each ( x . , y . ) , P ( x . ) = v . ; t ' i i i

2) P(x) is of c l ass Ck~1j P(x) has k-1 cont inuous d e r i -

v a t i v e s ;

3) P(x) is equal on each i n t e r v a l [ x . ^ , x . ] t o a polynomial of

degree k or less .

Def i n i t ion: Each x . in (1) above w i l l be c a l l e d a j o i n t .

Sp l i ne f u n c t i o n s of degree one r e s u l t i n f i t t i n g s t r a i g h t l i n e

segments between each p a i r of j o i n t s [ x . , x . ^ 1 3 > ' = 0 , U 2, n - 1 ,

wh i l e s p l i n e f u n c t i o n s of degree two have cont inuous f i r s t d e r i v a t i v e s .

Sp l i ne f u n c t i o n s of odd degree k, where k = 2m-1, are a l so impor tant

f o r t h e f o l l o w i n g reason: Of a I I t h e f u n c t i o n s Q(x) e C ^ " ' , such t h a t

Q(x. ) = y . , f o r i = 0, 1, 2 , . . . , n, t h e s p l i n e f u n c t i o n P ( x ) e C k-1 } • • . j I t f IMC- 3 p i I I I O l U l l ^ l i W M i \ / \ J t , ^

minimizes t h e i n t e g r a l

xn

J [ Q ' T x ) ] ~ d x .

This s ta tement is proven f o r cub ic s p l i n e f u n c t i o n s in Theorem 1.3.

Cubic s p l i n e f u n c t i o n s are examined in d e t a i l s ince they g i ve approx-

imate ly t he shape of a t h i n beam or " s p l i n e " which is fo rced t o go

th rough t h e p o i n t s ( X j , y . ) . This r e s u l t can be seen by c o n s i d e r i n g

t h e i n t e g r a I / [ Q " ( x ) ] 2 d x as an approx imat ion t o t h e s t r a i n energy o f a

t h i n beam, which is /Q" 2 / ( 1+Q'2 ) 5 / ' 2 d x . Thus t h e approx imat ion is a

good one i f t h e data po in t s represent a smooth near ly h o r i z o n t a l cu rve .

F u r t h e r , i f t h e cub ic s p l i n e approx imat ion i s t o c l o s e l y resemble

passing a s p l i n e th rough t h e g iven p o i n t s , then c o n d i t i o n s must be

s p e c i f i e d a t t he end p o i n t s . Namely, t h e s lopes sQ and sR s h a l l be

•given a t xQ and x n . Th is resembles the s p l i n e being clamped a t t he two

end p o i n t s .

Page 17: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

11

Theorem 1.3 Given ( x - , y . ) , i = 0, 1, 2, n where x ( )<x1<. . . <x n ,

l e t P(x) be a s p i i n e f u n c t i o n of degree t h ree such t h a t P(x - ) - y j a t each

j o i n l x . . Let Q(x) be a f unc t i on having cont inuous f i r s t and second

d e r i v a t i v e s on O o > xR ] such t h a t Q(x . ) ~ P ( x . ) , Q ' ( x 0 ) = P ' ( X Q ) , and

Q ' ( x n ) - P ' ( x n ) . Then

rx n ^n / [Q" ( x ) ] 2 dx >_ J [ P " ( x ) ] 2 i

x0

Proof : Let 3(x) = Q(x) - P ( x ) .

(1-14) J [ Q " ( x ) ] dx > J r P " ( x ) l 2 d x . x0 " x0

f [ Q v ( x ) ] 2dx - f [ n p u ( x ) ] 2 dx

= ^ { [ Q " ( x ) ] 2 -2 [Q" (x ) ] [P , ! ( x ) ] f [ p» (x ) ]2 }dx x o xo

x 0 i^n / n + 2J [Q" ( x ) ] [ P1' ( x ) ] dx - 2 J [ P " ( x ) ] 2 d x

xo xo

= / [ & " ( * > ] 2 a * + 2 J [P" (x)] f p" (x)] dx *0 x 0

^ n 1 /»x i +1

= / f e " ( x ) ] 2dx + 2>„ / B" (x) • P" (x) dx x 0 i -0 x .

i n t e g r a t i n g each term of t he summation term by pa r t s y i e l d s

2dx - p [ P u U ) ] 2dx x Q x Q -Xp n -1

J [ e , f ( x ) ] 2dx + 2 ^ [ 0 ' ( x )P" (x ) - B ' ( x . ) P " ( x . ) ] x 0 i =0 i + 1 1 + 1

n-1 r x i + 1

-2 j ? J P " l ( x ) 8 ' ( x ) d x . i=0 xf

The f i r s t summation term s i m p l i i i e s t o 2 [ g1 (x ) P" ( x p ) - p' (:< 0 )P" (x 0 ) 3 ,

because £ ' l X j i _ i ) - 8 ' ( x j ) - 0 a t each of t he i n t e r i o r j o i n t s . The second

summation term in tegra tes simply s ince P I M ( x ) is a cons tan t . Thus

Page 18: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

12

[ Q " ( x ) ] 2 d x - 2 d x = J ' ^ " ( x ) ] 2 d x + 2 [ e ' ( x n ) P » i x n ) - e « ( x 0 ) P « ( x 0 ) ]

n^,1

- 2 L P " ' ( i + h i n t e r v a l ) [ g (x ) - g ( x . ) ] . 1=0 1 + 1 1

In t h e second t e r m 0 ' ( x n ) = B - ( X ( ) ) = 0 s i n c e P ' ( x Q ) - Q ' ( x 0 ) and

P' ( x n ) - <?f C x n ) . The summat ion t e r m is 0 s i n c e S ( x ) = Q ( x ) - P ( x ) and

Q ( x . ) - p ( x . ) f o r 0 <_ i <_ n . F i n a l i y ,

£ ' [ Q n ( x ) ] 2 d x - £ r [ P " ( x ) ] 2 d x - ^ [ 3 " ( x ) ] 2d x > 0 ,

f [Qn ( x ) ] 2 d x J [ P " ( x ) ] 2 d x .

J h s o n ^ J ^ ^ The re i s e x a c t l y one c u b i c p o l y n o m i a l R ( x ) = £ a Cx-a) m

m=0

which assumes g iven va lues R(x> and R ' ( x ) a t end p o i n t s on an i n t e r v a l

[ a , b ] where a f b. T h i s p o l y n o n i a I i s

f , itrx . f 3 C R ( b ) - R ( a ) ) - R ' ( b ) - 2 R ' (a ) 1 ( 1 - 1 5 ) R(x ) - R (a )+R ' ( a M x - a H L ( b - a ) 2 ~ (b-cTF J * ( x - a ) 2

f — , R' C b) +R' (a ) 1 +*- ( b - a ) 3" T b - a ) 2 J ' ( x - a ) 3 .

P r o o f ^ Since R(x )= | ( x _ a , m a n d R 1 ( x ) = | ^ T h e

m-0 m - ]

s y s t e m o f l i n e a r e q u a t i o n s r e s u l t i n g f r om t h e f o u r g i v e n c o n d i t i o n s may

be w r i t t e n as m a t r i c e s R = Q. A, i . e .

a 0 R(a)

1

o o o

R('b) 1 (b--a) ( b - a ) 2 " ( b - a ) 3

R» (a ) 0 1 0 c

R ! ( b ) c 1 2 ( b - a ) 3 ( b - a I 2

X

0

U 1

a 2

a 3

The dererrr. i narvl of 1h<= c o p f f i r i o n - r ~i»+r-;v n • t o " r r k ' i e R r i r i x 0 is equa l t o t h e v a l u e

Page 19: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

13

|Qj ( b - a ) 2 (b-a)3

2 ( b - a ) 3 ( b - a £

( b - a ) (b~a)2 (b -a )3

1 0 0

1 2 ( b - a ) 3 ( b - a f

- - 3 ( b - a P + 2 ( b - a ) 4 = - ( b - a ) 4 .

Thus |Q| / 0 s i n c e a / b, and t h e system o f l i n e a r e q u a t i o n s has a

un ique s o l u t i o n ; Le_. , t h e r e i s one c u b i c which is d e f i n e d by t h o p o i n t s

( a , R ( a ) ) , ( b , R ( b ) ) , and t h e d e r i v a t i v e a t each o f a and b. By t h o

a p p l i c a t i o n o f Cramer 's R u l e , A may be de te rm ined t o produce t h e

r e s u l t s in ( 1 - 1 5 ) .

iM i£LL tL9 ILL Given an i n t e r v a I [ xQ .x n ] w i t h j o i n t s x ^ x ^ . . .<x n ,

P (x ) w i l l be c a l l e d a p i e c e w i s e c u b i c po l ynom ia l over [ x x 1 i f o ' n

P ( X ) = R i - i ( x ) o n + h e i n t e r v a l where R._1 ( x ) is a c u b i c

p o l y n o m i a I .

C o r o l l a r y 1 .5 . I f y . and s l opes s. a r e g i v e n a t each j o i n t

x . , i - 0 , 1, n , ("here e x i s t s e x a c t l y one p i e c e w i s e c u b i c p o l y -

nomia l P(x)eC~ which s a t i s f i e s P ( x . ) = y . and P ' ( X j ) - s . .

From Theorem 1.4 t h e r e e x i s t s one po l ynomia l R (x ) J'~1

p a s s i n g t h r o u g h y ^ and y^ and hav ing t h e s l o p e a t each o f x . 1 and

Xj such t h a t = Sj_, and R - . = s . f o r j = , / 2 >

Thus P(x ) is d e f i n e d on t h e i n t e r v a l [ x , x ] as 0 n

( 1 - 1 6 ) P (x ) - R. . ( x ) f o r [ x , , , x . ] . ^ J J

Le t x 0 , x l } x 2 be such t h a t Ax o x i xQ -f 0 arid

Ax 2 - x 2 X l / 0 , b u t n o t n e c e s s a r i l y X q / X j , . L e + v ( x ) a n d w ( x ) b Q

c u b i c p o l y n o m i a l s such t h a t v < X j ) = w f X ] L ) = Y l , and v ' ( x j )

Then v " ^ ) - w " ^ ) i f and o n l y i f

w ' ( X j ) -• S 1

Page 20: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

1 4

( i ""*** i / ^ ^ ^ "1 p ^

A x 1 v ' ( x 0 ) + 2 ( A x 1 4 A x 0 ) s 1 , ' - A x 0 w , ( x 2 ) = 31ax^ Lw(x? ) - y j + A ^ L Y l - v ( x Q ) J j ,

Assure v (Xj ) - w"'^x^). Let each of v ( x ) and w(x) be

de f ined in t h e form of R(x) in Theorem 1 .4 .

F~2(R(b)-R(a)) R ' ( b ) + R ' ( a ) l R " ( x ) = 6L (b -a )3 " + ' (b -a )2T J < x - a )

j"3(R(b)-R(a) ? R' (b) +2R' (a) ] + 2L (b -a )2 - ( b - a ) ~ ~ j .

F u r l h e r , l e t a - x^ , and b ~ x^ such t h a t

r 3 ( v ( x n ? -v(x , ) ) v ' f x p H P s , i V ' C x , ) ^ < - « „ ) ; • -

P i V ' X0 ) -y-i ) 1 = -AX0 L - i x 0 " - v» (x0 ) -2s r J .

S i m i l a r l y , l e t t i n g a = x^ and b - x9 ,

2 [" 3(w(x? ) - y i ) -j w " ( x 1 ) - AXj L AXj ' ~ w ' ( x 2 ) - 2 S l J .

l i then f o l l o w s t h a t (1-J7) is t r u e . Re t rac ing t h i s proof p ro -

v ides t h e proof of t h e converse; t h a t is g iven equat ion ( 1 - 1 7 ) , then

v " ( x 1 ) = w"(Xj ) .

' f A is a rea l (nxn) m a f r i x such t h a t

( , " 1 8 > l a i i l > % k l 1 = 1,2 k= 1, kf- i

then A is nons ingu la r .

Assume |A| = 0; i . e . , A is s i n g u l a r . Then t h e system of

equat ions

' a i l X > + a i 2 * 2 + • • • + a i nx

n = 0

a 2 1 X l + a22X2 + + a2 „ * „ = 0

a n l x l 1 a n 2 x 2 + + an i l

x „ = 0

Page 21: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

15

has a n o n - t r i v i a l s o l u t i o n (X j , x 2 , . . . ,x ) . Let rn be t h e index such

t h a t |xm | = m a x { [ x j | , | x 2 [ , . . . , | x | } . Then t h e m~^ equat ion may be

wr i t t e n

i=n ammxm ~ " £ a m i x i

i = 1, i f m i =n

| | ^ a rn i x i f '> = 1, i M

lamml•f ml = lEamixil i EIami I"IxiI - EIam1 I"Ixmh

IsmmI — ^1am i ! »

which is a c o n t r a d i c t i o n t o t he hypothes is in (1 -18 ) . Thus j A j f 0,

or A is nons i rigu I a r .

Core I I a ry 1 »8. Le*f P(x) be a p iecewise cub ic polynomial of c lass

C1 w i t h j o i n t s x 0 , x1, . . . , x n . For g iven y? = P ( x . ) , i - 0 , 1, . . . , n

and s0 = P ' ( X q ) , sn = P ' ( x n ) , t h e r e e x i s t s e x a c t l y one se t of values

S j ~ ^ ~ n - ^ ' s u c h t h a t P(x)eC 2 .

P roo f : Since P t x k C 1 , t h e r e does e x i s t a se t of values s. = P ' ( x - ) , J J

j ~ K 2 , n - 1 . Let R j_ j (x) and R . ( x ) be cub ic po Iynomia I (s ) such

t h a t R j_ j (x) = P(x) on t h e i n t e r v a l [ x j _ . | , X j ] and Rj<x) = P(x) on t he

i n t e r v a l [ x j , X j + j ] , j = 1, 2, . . . , n - 1 . Since P(x) is a cub ic po lyno-

mial on each open i n t e r v a l ( x j . . i , X j ) , P " (x ) e x i s t s f o r each p o i n t in the

i n t e r v a l . Assume t h a t (x j ) = R"j ( x - ) a t each j o i n t x1 , x2 , . . . ,

*n-1 •

From Theorem 1 .6 , R , f j _ ^ ( x j ) = R J - ' x j ) i f and on ly i f

( 1 _ ] 9 )A X j R j - 1 ( X j - 1 ) f 2 ( A x j + A x j - t }* R j ( x j > + A x j - 1 R j ( x j + 1 }

f A X ) - 1 AXr ] " ' ^ A X j ( R j ( X j + 1 ) _ Y j 5 + A X j - 1 ( y j " " R j - 1 ( X j ~1

Page 22: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

16

where Ax.«=? x . - x . , . Let s . ~ P ' ( x . ) , 1hen equa t ion (1 -19) may be vJ J J J

w r i t t e n as

f Ay. t 1 A x . s . ! + 2(Ax.+Ax. , ) s . + Ax. 1 s . , 1 = 3LAx. - 'Ax". + Ax? Ax. J .

J J -1 J J -1 J J -1 J+1 J - 1 J J J-1

The c o e f f i c i e n t m a t r i x Q of t h e unknowns ( s x , s 2 , . . . , s ^) is

2(Ax l-fAx^ ) A>^ 0 0 . . . 0 0

Ax> 2(AX2+AX1) AXj 0 . . . 0 0

0 AXg 2 (AXg HA x, ) A>c, . . . 0 0

0 0 0 0 . . . 2(AxR+2^ xn_3 ^ A x n~3

0 0 0 0 . . . Ax 1 2 (Ax +.Ax 0 ) n - l n - l n-l..

Since 2 | A X - + A X . i j >_ |Ax . | + | A X . , | , by Lemma 1.7 | q[ > 0 . Thus t h e U s j \ J u

system of equa t ions de r i ved f rom (1-19) is l i n e a r l y independent and

s ; , j = 1, 2, . . . , n - 1 , may be determined u n i q u e l y . Let 3 . , j : : 1, 2, J J

n - 1 , where s . = R ' ( x . ) , be t h e se t such t h a t (1-19) is t r u e . Then J J

f rom Theorem 1.6 R " . _ ^ ( x . ) = R " . ( x . ) . Thus P(x )eC 2 . j j j j

N o t a t i o n : Let S ( x ; x Q , x 1 , . , . , x n ) , where x 0 < x 1 < . . . < x n , denote t h e

se t of a I I cub i c s p l i n e f u n c t i o n s P(x) on t h e i n t e r v a l [ x 0 , x n ] a n d w i t h

j o i n ts XQ , x^ , . . . , x^ ,

Theorem 1 .9 . For each s e t { y 0 , y 1 } . . . , y n , s Q , s } of va lues t h e r e

e x i s t s one P(x) e S ( x ; x Q , x 1 , . . . , x ^ ) such t h a t

p ( x ; ) = y { , i = 0 , 1 , 2 , . . . , n ; P ' ( x 0 ) = s 0 ;

P roo f : From Coro! Iary 1 .8 , g i ven y j = P ( x - ) , s 0 = P ' ( x Q ) ,

sn = P' (Xj.t) t h e r e e x i s t s one s e t Sj , j = 1, 2, n -1 such t h a t

P(x) e C 2 . F u r t h e r f rom C o r o l l a r y 1 .5 , t h e r e e x i s t s one p iecewise

po lynomia l of c l a s s C1 such t h a t

Page 23: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

17

P(x. )--=y. and P' (x, )=s, .

Thus f o r g iven (Xj>Yj ~ so > an (^ = ^ c r e e x i £ " t ' s o n e

P(x) e S ( x ; x Q , x i , . . ) .

C o r o l l a r y 1.5 and Theorem 1.4 may be used in a computat ional

• scheme f o r t h e e v a l u a t i o n of P(x) f o r g iven ( x j , y j ) , s Q , and s n .

Each S | , i = 1, 2, . n - 1 , is computed f rom equat ion (1 -17 ) . Then

s ince P(x) equals a cub ic polynomial R j _ i ( x ) in each i n t e r v a l

[ x , _ 1 , x , ] and each of ( X j _ j , y j _ j ) , ( x - , y . ) , sj_-j and Sj is known,

equa t ion (1-15) may be u t i l i z e d t o compute each R j _ j ( x ) , 1 = 1 , 2 ,

. . n .

Example 5: Given t h e data p o i n t s ( 0 , - 2 . ) , ( 1 , 3 . ) , ( 2 , 2 . ) , ( 3 , - 1 . )

arid (4, .5) w i t h s .5 and s = . 5 , determine t he r e s u l t i n g cub ic

s p l i ne f u n c t i o n .

F i r s t equat ion (1-17) is used t o determine Sj , s^

s o l u t i o n m a t r i x of t h e f o l l o w i n g must be determined:

; t h a t is, t h e

—1

O

o «

S1 11 .5

1. 4. 1. X C

"2 r -12 .0

0 . 1. 4. -S3- - 5 . 0

.This y i e l d s s = 2 .875 , s2 = - 3 . 6 3 3 , s3 = - . 3 4 2 . F i n a l l y , by equa t ion

(1 -15 ) , t h e s p l i n e f u n c t i o n is

P(x) - -2 .000 4 0.50Gx + 11 . 1 2 5 X 2 6.625x , where 0<x<1;

P(x) = 3 . 0 0 0 + 2 . 8 7 5 ( x - 1 ) - 5 . 1 1 7 ( x - 1 ) 2 + 1 . 2 4 2 ( x - 1 ) 3 , where 1<x<2;

P(x) !.000 - 3.633(x--2) - i . 3 9 2 ( x - 2 ) 2 + 2 . 0 2 5 ( x - 2 ) 3 , where 2<x<3;

P(x) - -1 .000 - 0.542(x~3) + 4 .683(x -3 ) - 2.842{x-~3) , where 3<x<4,

Page 24: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

18

A computer program f o r t h i s scheme is shown in Appendix A; g iven t h e

i n i t i a l p o i n t s and end s lopes the program computes t h e r e s u l t i n g P (x ) .

Theorem 1.10. The se t S { x ; x o > x , . . . , x n > of s p l i n e f unc t i ons w i t h

j o i n t s x , x^ , x^ is a v e c t o r space over t h e f i e l d o f rea l numbers.

Proo f : Let each of P ( x ; x Q , x 1 , . . . , x ) , Q ( x ; x 0 , X j , . . . , x ) and

3 R (x ; x , x , . . . , x ) be elements o f S. F u r t h e r , l e t P. = E p. . x^

o 1 n ' i - 1 j t o i - ^ j

denote P on t he i n t e r v a l [ x . e a c ^ ° f £. a n d b_ be rea l

numbers. Let "+" i n d i c a t e t h e normal a d d i t i o n of f u n c t i o n s , namely

s p l i ne f u n c t i o n s .

i . ) (P+Q) + R = p + (Q+R), s ince in each i n t e r v a l [ x . t h e

s p l i n e f u n c t i o n is a cub ic po lynomia l , and t h e a s s o c i a t i v e p rope r t y

holds f o r cub ic po l ynomia l s .

i i . ) By t h e same reasoning as in ( i ) , (F-fQ) = (Q+P).

i I i . ) T h e se t S has a zero Z. where Z = 0 on each i n t e r v a l t x . , , x . ] , i - 1 ' i '

and P + Z = P.

i v . ) Each element of S has an inverse s ince

P + ( -P) = Z;

i . e . , P. + ( - P . ) = £ p . , .x^ -! 5 f ( - p . . . )x^ - 0 = Z

' - 1 ' - 1 j=0 > J j = 0 ! " 1 ' J

f o r each i n t e r v a l [x . ^ x j ] -

v . ) In each i n t e r v a l [ x . ^ > X - L

3 . 3 a (P. .+Q. .) = a ( ^ D . . .xJ + X q . . . x J )

• - 1 ' - 1 j=o' ' ~ 1 ' J j =0 , _ 1 ' J

J -J- ^ Y. rt ^ - a l o . , ,xJ + a £ q . .

aP . . -i- aQ . ,. i - 1 i - 1

Page 25: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

19

T h e r e f o r e , a(P+Q) - aP + aQ.

v i )

3 (a+b)P. . = ( a + ' b ) Z p . , .x^

' - 1 j = 0 1~ 1 * J

3 . 3 . = a l p , ] ;XJ + b Z P ; 1

j = o ! l , J j = 0 1 ' ' J

aP. . + bP. , i - 1 i - l

I h e r e f o r e ,

(a+b)P = aP + bP.

* v i i ) a (bP. , ) = a Z b p . 1 ,xJ* = abP j _ 0 i - ' > J

a (bP) = (ab) P.

v i i i ) The re i s u n i t y e lement 1 i n t h e s e t o f r ea l numbers such t h a t

1 »P = P.

The above e i g h t c o n d i t i o n s g i v e t h e d e f i n i t i o n o f a v e c t o r space ove r

a f i e l d ( 3 ) . Thus t h e s e t S { x ; x 0 , x 1 , . . . , x n } i s a v e c t o r space ove r

t h e f i e l d of r ea l numbers.

Theorem 1 .11 . The s e t o f <(>. ( x ) e S{ x ; x 0 , x 1 , . . . , xn } , i = 0 , 1 . . . . ,

n+2, d e f i n e d by f o l l o w i n g t h e c o n d i t i o n s , i s a b a s i s f o r t h e v e c t o r

space } j

f 0 \ f ] <t>, ( x . ) = <5. j = \ 1 i = j , <J)' . (x 0 )=<J>'.(X )=0 f o r i , j = 0 , 1 , . . . , n ;

J ' J J J n ( 1 - 2 0 ) <J>n+1 (Xj ) = $ n + 2 ( x | > = ° . f o r i = 0 , 1 , . . . , n ;

< t ' n+1 ( x 0 ) = < f ' n+2 ( x n ) = ^ ' n + l ^ i * = $ 'n+2 (x0 ) = ° *

F u r t h e r , t h e space 5 has d imens ion ( n + 3 ) .

P r o o f : The s e t o f (n+3) v e c t o r s ,

(1-21) (1,0,...,0 ), (0,1,0,...,0 ), . . . , (0,0,...,0,1 > n+3 n+3 n+3

Page 26: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

20

forms a bas i s f o r t h e v e c t o r space of d imension (n+3) over t h e f i e l d

of r ea l numbers ( 3 ) . From Theorem 1.9 , t h e r e is a o n e - t o - o n e cor respon-

dence between each v e c t o r Cy0 ^ , . . . , S q , s n ) and each element P(x)

i n S{x;xQ ,Xj , . . . , x n } , F u r t h e r , each element f . ( x ) i n (1 -20) maps t o

t h e i"*1"1 v e c t o r i n t h e s e t o f u n i t v e c t o r s i n (1 -21) Let (v v s Y Q > Y >

Yn> sov s r , ^ rnaP P(x) e S. Then

( y 0 » y i ^ • • - , y n , s 0 , s n ) - y 0d ,o , . . . ,o ) + . . . +yp(o,o,.,.,o,i,o,o)

+ s Q ( 0 , . . . , 0 , 1 , 0 ) + s ( o , o , . . . , o , 1 ) ;

and

P<x) = Vo ( i ) o(x> + y i ' i ' i ( x ) + . . . + y n ( ! ) n ( x ) + s 0 < ( , n + 1 ( x ) + S n < f ) n + 2 ( x ) .

t h a t i s , t h e s e t o f ^ ( x ) , k = 0 , 1 n +2 spans t h e space S.

F u r t h e r , t h e s e t <f>k(x) is l i n e a r l y independent s i n c e t h e v e c t o r

( 0 , 0 , . . . , 0 ) maps t o t h e ze ro s p l i n e f u n c t i o n Z (x ) e S, and

2 ( x ) = 0'<j>o(x)+0 •<{>i(x)+ . . . +0*<f.n+^x).

I h u s , t h e s e t o f f u n c t i o n s $ R ( x ) d e f i n e d in (1 -20) forms a bas i s f o r

vec ( o r space S { x , x 0 , x 2 , . . . , } . Since <f>k(x) spans t h e space and

i s l i n e a r l y independent , t h e d imension of s e t S is (n+3) .

— m p l e 6 : R e P r e s e n t t h e s p l i n e f u n c t i o n in Example 5 by a l i n e a r

comb ina t i on o f bas i s e lements .

The bas is e lements <f>, (x ) of t h e v e c t o r space S { x ; 0 , 1 , 2 , 3 , 4 } have

been computed us ing t h e computer program i n Appendix A. These elements

a re :

4>0(x) 1.000 - 2 . 2 5 0 x 2 +1.250X3 on t h e i n t e r v a l [ 0 , 1 ]

- 0 . 7 5 0 ( x - 1 ) + 1 .300 (x -1 )2--0.550Cx— 1)3 2]

+ 0 . 2 0 0 ( x - 2 ) - 0 . 3 5 0 ( x ~ 2 ) 2 + 0 . 1 5 0 ( x - 2 ) 3 [ 2 3 ]

-C .050 ( x -3 )-l-Q. 1 0 0 ( x - 3 ) 2 - 0 . 0 5 0 ( x - 3 ) 3 [ 3 4 ] -

Page 27: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

• 2<x)

•3Cx)

$ (x) = +3.000x2

= 1.000 -2.200(x-

-0 .800tx-2)+1.400(x-

0.200(x-3) -0 .400(x-

-0.750x?

+0.750(x-1)+1.500(x-

1.000 -2.250 (x-

-0 .750(x -3)+1 . 500(x-

0.000

-0.800(x-

0.800(x-2)+1.600 (x-

1.000-0.200(x-3)-2.600(x-

0.000

+0.200(x-

-0 .200(x-2) -0 .400(x-

0.800(x-3 > + 1.400(x-

I.OOOx -1.750x 2

-0.250(x-1)+0.433(x-

0.067(x-2)-0.117(x-

-0.017(x-3)+0,033(X'

0.000

-0.067(x-

0.067 ( x - 2 ) - 0 . 133(x-

-0.267 (x-3 ) -0 .467(x-

On each in te rva l [ x . _ | , x . ] , P(x)

-2.000x3 on the In te rva l

1 ) 2 +1 .200 (x - l ) 3

+ 5 ( x } =

Vx)

2)2-0.600(x-2

3)2+0.200(x-3

+0% 750 x3

1)2-1.250(x~1

2)2+1.250(x-2

3 ) 2 -0 .750(x -3

•1)2+0.800(X-1

•2)2-1.400 (x-2

•3)2+1.800(x-3

-1) 2 -0 .200(x-1

-2)2+0.600(x-2

-3)2-1.200(x~3

+0.750x3

-1 )2_o.183CX-1

•2)2+0.050(x-2

-3)2-0.017(x-3

-1)2+0.067(x-1

-2)2-0.200,(X-2

on the i n tervaI

on the in te rva l

on the i n te rva l

on the i n tervaI

on the i n tervaI

•3) +0.733(x-3

in Example 5 may be represented

21

0,1]

1,2]

2.3]

3 . 4 ] ;

1]

1,2]

2.3]

3 . 4 ] ;

0,13

,2]

2.3]

3.4] ;

0, 1]

,2)

2.3]

3 . 4 ] ;

0,1]

1,2]

2.3 ]

3 . 4 ] ;

0,1]

1,2]

2 ,3 ]

[ 3 , 4 ] .

by

Page 28: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

22

P(x) = ~2'<f>0 (x)+3*<j>i (x)+2*<J>2 (x) — 1 • 413 (x)+0„5*<ftf (xH0.5*<|!g(x)+0.5'<f>^x).

Thus P(x) on t h e i n t e r v a l [ 0 , 1 ] is

P(x) - -2 .000+0 .500x-11 .125x 2 -6 .625x 3 .

S i m i l a r l y P(x) may be computed on each of t h e o the r t h r e e i n t e r v a l s .

Page 29: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

CHAPTER BIBLIOGRAPHY

1. B i r k h o f f , G a r r e t t and de Boor, C a r l , "P iecewise Polynomial Surface F i t t i rig, " Proceed i ngs, Genera I Motors Research Labora to r i es Syrnpos ium: Approx imat ion of Func t ions , e d i t e d by H. L. Garabedian, E l s e v i e r , Amsterdam, E l sev i e r P u b l i s h i n g Company, 1965.

2. N ie l sen , Kaj L . , Methods of Numerical A n a l y s i s , New York , The MacmiI Ian Company, 1956.

3 . Per l i s , Sam, Theory of Ma t r i ces , Reading, Massachusetts, Addison-Wesley P u b l i s h i n g Company, 1958.

23

Page 30: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

CHAPTER I I

METHOD Or LEAST SQUARES

Polynomials of Least Squares

There are cases when i t is no t d e s i r a b l e t o compute an a p p r o x i -

mat ion by f i t t i n g a polynomial e x a c t l y th rough n+1 data p o i n t s . Of ten

t h e data p o i n t s are ob ta ined by some method which is not exac t . This

is t r u e when t h e data is taken by some phys ica l measurement'. Thus

i t may be necessary t o determine an approx imat ing f u n c t i o n 1 hat w i l l

come as c lose as poss i b l e t o t h e po in t s and s t i l l r e t a i n y p r e d e t e r -

mined c h a r a c t e r i s t i c . Th is w i l l show t h e general na ture of t h e data

but w i l l no t n e c e s s a r i l y pass e x a c t l y th rough the g iven p o i n t s .

The method o f l eas t squares is one techn ique t h a t is used in

curve f i t t i n g t o determine a f u n c t i o n t o represent data t h a t c o n t a i n

e r r o r . The p r i n c i p l e of l eas t squares s t a tes t h a t t h e best represen-

t a t i o n of t h e data is t h a t which makes t h e sum of t h e squares of "the

residua.Is a minimum, where t h e res idua l Rj is de f ined as

Rj = y . - f ( x . ) , f o r i = 0 , 1 , 2 , . . . , n ;

and f is t he approx imat ing f u n c t i o n .

Th is p r i n c i p l e in one dimension is e q u i v a l e n t t o t h e assumption

"that t h e a r i t h m e t i c mean is t h e best es t ima te of a se t of measurements,

Suppose t h a t some q u a n t i t y is measured n+1 t imes .

x . — x+ | j i - 0 , 1 , 2 , . . . , n,

24

Page 31: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

25

where e. is t h e e r r o r of t h e measurement and x is t h e t r u e va tue . i

The p r i n c i p l e of l eas t squares f o r one dirrension imp l ies t h a t t h e best

es t ima te x of x is t h a t number which minimizes t h e sum o f t he squares

o f t h e d e v i a t i o n s of t h e data from t h e i r es t ima te . Thus t h e f u n c t i o n

f (x) = S ( x . - x ) 2

i =0

must be minimi zed.

Theorem 2 . 1 . The p r i n c i p l e of l eas t squares f o r one dimension

impl ies t h a t t h e average

1 n x = n+1 Z x .

1=0 '

i s t h e best es t ima te ; i .e . , x = x .

n Proof : Since f ( x ) - £ ( x . - x ) , f rom t h e Calcu lus

i=0

df n dx = - 2 £ ( x . - x ) - 0

i=0

fU £U = E x . - Z x = o

1=0- i =0 n

= E x . - (n+1)x = 0 . 1=0

„ J L f r x = n+1 L x . = x .

i=0 ' a

Thus x g is a c r i t i c a l p o i n t f o r f ( x ) . Now

d 2 f df n dx = - 2 dx X ( x . ~ x)

1=0 1

= 2n+2>0.

There fore x = x is a minimum f o r f ( x ) , and t h e method of l eas t squares

imp l ies t h e average is t h e best es t ima te .

Page 32: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

26

Examp Ie 1: The l e a s t square e s t i m a t e o f t h e numbers 2, 3,2,1, 2 , 3

may be found both ways.

x - (2+3+2+142+3)/6 = 13/6. 0

f ( x ) - ( 2 - x ) 2 + ( 3 - x ) 2 + (2~x) 2 + ( 1 - x ) 2 + ( 2 - X ) 2 + ( 3 - x ) 2

= 3 ( 2 - x ) 2 + 2 ( 3 - x ) 2 + ( 1 - x ) 2 .

df

cfx = - 6 ( 2 - x ) - 4 ( 3 - x ) - 2 (1 - x )

0 = -12 + 6x - 12 + 4x - 2 + 2x

26 = 12x

x = 13/6 , and x = x .

The p r i n c i p l e o f l e a s t squares is o f t e n used t o f i t a po lynomia l

of degree m th rough n+1 p o i n t s ( X j , y . ) , where m < n+1, and t h e n+1

data p o i n t s a re known t o c o n t a i n e r r o r . Th i s method s t a t e s t h a t a good

e s t i m a t e of t h e data p o i n t s is t h e po lynomia l which min imizes t h e sum

n+ 1 ( 2 " n Sm = Z [ y r P m ( x j ) ] 2 ,

i = 1

where Pm = amxm + am_^xm~ 1+ . . . +aQ . Thus,

n +*1 n+1 £ [ y , - ( a m x ' » + a m _ 1 x » ' - ' + . . . + a 0 ) ] = TR.2 = f ( a m , V , a , ) .

For t h e po lynomia l o f degree m, t h e prob lem w i l l be t o de termine t h e

c o o r d i n a t e s of a s i n g l e p o i n t ( a ^ ' , a [ n ^ 1 , . . . ,a ' ) i n an m+1 d imens iona l

Euc l idean space which min im ize f . A necessary c o n d i t i o n t h a t f ( a .a m m - T

. . . , a ) has a minimum is t h a t t h e r e e x i s t s a va lue (a ' a ' . . . , a ' ) o m m-1 ' ' 0

such t h a t t h e p a r t i a l d e r i v a t i v e s

Page 33: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

27

9f 9am = 0 a t a, m m

( 2 - 2 ) 3f 9am_r = 0 a t am_ m-1 ~ m-1 '

9f

9 a 0 = 0 a t a0 = aQ» .

S e t t i n g t h e p a r t i a l d e r i v a t i v e of f t o zero y i e l d s

9f r 9Ri 3R2 8 Rn+1 (2 -3 ) Saj = 2LRiaaJ.

i + 1 1 + R29aj + . . . + Rn+^ 9aj J = 0 , j = 0 , 1 , . . . , m.

F u r t h e r ,

9R 9 Ri ?JiL 30

. . . , 9a = 1, i = 1 , 2 , . . . ,n+1. (2-4) 9am - 9am_1

Thus f rom t h e equat ions in (2 -3) and ( 2 - 4 ) , t h e f o l l o w i n g rrt+1 equat ions

a re obta i ned:

(2 -5)

0 1

a n I x? 0 i

+ ajEx- + a2£x 2 + . , .. + arrr

+ a Ex . 2

1 1 + a Ex

2 3 + • . . . + a ;

m

4" a Ex 3

1 1 + a Ex

2 4 + . , * . + a :

m £>^+2;

Ex. y. 1 1

E x.2y. 1 1

a Ex.m + a Ex . m + 1 + a Ex . m + 2 + . . . + a E X . 2 m - E x.my. 0 1 I ' 2 1 m 1 1 '1

The summation s igns in (2 -5) range from i, = 1 t o i = n+1 . This system

of equat ions is c a l l e d t h e se t of normal equat ions and i t s s o l u t i o n

y i e l d s a mini mum f o r f (am,am_^ , . . . ,aQ ) .

Theorem 2 . 2 . Prove t ha f i f x . / x . f o r i ^ j , then a unique s o l u t i o n , j

e x i s t s f o r t h e system of equat ions in ( 2 - 5 ) .

P roo f : The (m+1) x (m+1) c o e f f i c i e n t m a t r i x C may be w r i t t e n as

t he product of mat r i ces D and t h e t ranspose D' of D as shown in

equat ion ( 2 - 6 ) . D is an (n+1) x m m a t r i x .

Page 34: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

28

(2-6) C =

n + 1 Ex. Ex 2 v m

. . Ex,

Ex . i

Ex. 2 | Ex 3 m+1

. . Ex.

w EXj 3 E x r , rrtf-2

. . E x j

v"m _ m+1 m+2 iXj Exj Zxj . . EX:

*2r

1 1 1 . . . 1

X 1 X 2 X 3

X,- X0 X;

V i

^ + 1 x

1 X,

1 X .

1 X =

X 2 2

. . X,

• • Xq

X • m Xn+l

= D' • D.

m., m_, rn m . . . x n + | 1 \ i +1 "n+1

Rows 1 through m+1 in D correspond t o the mat r i x V of Theorem 1.1.

From Theorem 1.1, the Vandermonde determinant | v j 4 0, s ince x, 4 x j ,

•for i 4 j . Fur ther , m+1 is the largest integer such t h a t D has an

(m+1) x (rn+1) submatrix w i th determinant not zero. From matr ix theory

(2, p. 58), the rank of D is m+1 and the rank of D' is m+1. F i n a l l y ,

C = D*D' has rank m+1 and is an (m+1) x (m+1) ma t r i x ; thus C is non-

s ingu la r and the system of equations in (2-6) has a unique s o l u t i o n

(2, p. 60) .

Example 2: F i t a least squares polynomial of degree 2 t o the data

po in ts ( x , y ) shown in Table I .

Table I

Xj .. Yi Ri -2 .0 18.1 8.66-10"^

0.0 3.9 -4.29-10-2 1.0 3.0 8.14.10-2 3.0 12.9 -7.79-10-2 4.0 24. 1 3.85-10-2

Page 35: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

29

The computer program in Appendix B was used t o per form t h e c a l c u -

l a t i o n of t h i s problem. The f o l l o w i n g terms were computed f o r t h e

normal equa t ions :

Ex = 6 .0 ; Ex2 = 30 .0 ; Ex3 = 84.0 ; l x k = 354.0;

Ey =62.0; Exy =101.9; Ex2y=577.1.

The s o l u t i o n of t h e normal equat ions of (2-5) p rov ided t h e c o e f f i c i e n t s

f o r t h e leas t squares q u a d r a t i c equa t ion ,

P(x) = 2.018x2 - 2 .042x + 3 .943.

The r e s i d u a l , R. = y. - P ( x j ) , was computed a t each p o i n t ( X | , y j ) and

is shown in column 3 of Table I .

Least Squares Polynomial Approx imat ion w i t h R e s t r a i n t s

Weighted Residuals

For some data i t may be des i red t o g i ve more weight t o some of t he

obse rva t i ons than t o o the rs in f i t t i n g a polynomial t o t h e p o i n t s ; thus

t h e sum of t h e squares o f t h e res idua l s of (x { , y j ) may be weighted by

w. , where Wj i- 0 . Then equat ion (2-1) becomes

n+1 <2-7) Sm - Z - , | y , - V l * l + + V 1 2

1 = 1

n+1 Z w j R j - f (am ,am_i , . . . , a ) .

i = 1

F u r t h e r , t h e p a r t i a l d e r i v a t i v e s 8jr_ , j = 0 , 1, . . . , m are 3 a j

i L _ J E l k 3Rn+i 1 (2-8) 33j = ' 2 L w 1 R 1 3 a j + w ^ a a j + + wn+1 3a j J;

and

3R; 8 Rj 8R; (2-9) 3a m = 3a m_, = ... ; 3a = w,.

Page 36: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

30

Us ing (2 -8 ) and (2 -9 ) and e q u a t i n g t h e p a r t i a l d e r i v a t i v e s t o ze ro

y i e l d s

3f 8a0 - 2 ( W l R : + W2R2 + . . . + w n + 1 R n + 1 ) = 0;

(2 -10) 3f 9a1 = 2 (w 1 x 1 R 1 + W2X2R2 + . . . + w n + 1 x n + 1 F^+ 1 > - 0;

3f 3Q

m 2 ( " 1 ^ R 1 + « 2 ^ R 2 + • • • + » n + 1 >£+, V , ) = 0.

Making t h e s u b s t i t u l i o n s f o r Rj produces t h e s e t o f normal equa t ions

f o r we ighted r e s i d u a l l e a s t squares .

I w . a 0 + S ( w . x . ) a 1 + . . . + £ (w. xrP )am = Z ( w , y . )

(2 -11) £ < " i X i ' a 0 + E < W i X i > a i + + K w , ^ j ' + 1 )am = E C w j ^ y , )

E ( w 1 x T ) a 0 + E ( " ix 7 + , ) a , + • • • + £ ( w , x ' . 2 m ) a - ) .

i i u i i i i i rn i i 7 \ The summation s i g n ranges f rom i = 1 t o i = n+i i n each t e r m of (2 -11)

Theorem : 2 . 3 . I f X. 1 * x j

for ? ¥ j , then a unique s o l u t i o n e x i s t s

for t h e system of l i n e a r equa t i on s i n ( 2 - 1 1 ) .

P r o o f : Denot ing t h e c o e f f i c i e n t m a t r l v I n (2 -11) by F, i t may be

w r i t t e n as t h e p roduc t o f two 1 matrices D f and E; t h a t i s ,

1 1 1 . . . 1 w 1

w X 1 1

w x 2

1 1

x x 1 2 X3 • ' * Xn4-1

w 2

w X 2 2

2 W 2 X 2

m , w x

2 2 (2 -12) F = 2 2

X X 1 2

x 2 . . 3 • tf+1 X W

3 W X 3 3

W X 2

3 3 m

w x 3 3

' m m m *m m wn+1 xrH-L

x X _ 1 2

x . . 3 *

_ Wn-H wn+1xn+1 2 wn+1xn+1 • • *

m wn+1 xrH-L

= D ' *E .

The m a t r i x D< was d e f i n e d In Theorem (2 -2 ) and i t was shown t h a t t h e

rank of D' was ( m f l ) . By m u l t i p l y i n g each row i o f E by 1, t h e m a t r i x

w.

Page 37: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

31

E is equivalent to matrix D of Theorem 2.2. From matrix theory, two

equivalent matrices have the same rank (2, pp. 60-61). Since from

Theorem 2.2 the rank of D is (m+1), it follows that (m+1) is the rank

of E. Finally, F is the product of two matrices D' and E, each of which

has rank m+1. Again from matrix theory (2, p. 60), the rank of F is

m+1, and since F is an (m+1) x (m+1) matrix, F is nonsingular. Thus a

unique solution exists for the system of equations in (2-11).

Example 3: Fit a cubic polynomial to the data points (xj»yj) shown

in Table II. Assign the weight w., which appears in column 3, to each

data point (x.,y.)

Table II

Xi Yi w; Ri Ki

0.0 . 127462. 1.0 —.4143•10~2 -.8388-10~2

0.2 .133271 1 .0 -. 1681-10""2 -. 5335•10~2

0.4 .139413 1 .0 -.3802.10"^ -.3099-10~2

0.6 . 145905 1 .0 .9253-10~3 -.1546-10"2

0.8 .152753 1.0 .1337•10~2 -.5543*10 3

1.0 .159964 10.0 .1326-10"2 0 1.2 .167528 1 .0 . 1005-10~2 .2229• 1 0~3

1.4 .175459 1.0 .5102-10~3 .2449•10-3

1.6 .183731 1 .0 -.6282* 10-lf . 1562-10~3

1.8 .192319 1 .0 -.6165.10~3 .4810.10~4

2.0 - .201186 10.0 -.1066-10"2 0 2.2 .210262 1.0 -.1358-10~2 .5819-1O-^ 2.4 .219482 1 .0 -.1437-10"2 .2740•10~3

2.6 .228741 1.0 -. 1285 -10 — 2 .6587.10"3

2.8 .237937 1.0 -.8820-10"3 . 1227 - TO"2

3.0 .246848 10.0 -.3274*10~3 .1872 -10~2

3.2 .255362 1 .0 .3887•10~3 . 2600•10~2

3.4 .263251 1 .0 . 1160-10"2 .3298-10-2

3.6 .270285 1.0 .1880•10~2 .3852«10"2

3.8 .276221 1 .0 . 2427 • 10~2 .4136 * 10 ~ 2

4.0 .280822 1 .0 .2686.10~2 .4029•10-2

4.2 .283815 1 .0 .2506•10~2 .3375•10"2

4.4 .285005 1.0 .1815-10-2 .2095•10"2

4.6 .284214 1 .0 .5563•10~3 . 1267-10-3

4.8 .281286 1.0 -. 1303 • 1 0~ 2 -.2569•10~2

5.0 .276144 1 .0 -.3719'10"2 -.5953 • 10~2

Page 38: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

32

The computer program in Appendix B was used again in t h e s o l u t i o n of

t h i s example. The terms making up t h e c o e f f i c i e n t m a t r i x f o r t h e normal

equat ions were computed:

Zw = .53000 '10 2 , Ewx = .11900Q-103 , Ewx2 - .347000-10 3 ,

Iwx3 = .116900' Id 1 , Zvtxh = .432783-10^, Ewx5 - . 171194- 105 ,

£wxe = .710744'105 ,£wy - .111506-102 , Ewxy = .280006-102 ,

Ewx2y - .869789-102 , Ewx3y = .304675-103 .

The s o l u t i o n o f t h e normal equat ions y i e l d e d t h e c o e f f i c i e n t s f o r t h e

requ i red cub ic po lynomia l ,

P(x) = ( - . 254534-10~ 2 ) x 3 + ( . 159268-10" 1 ) x 2 + ( .136511•10 _ 1 ) x + .131605.

The data in t h e f o u r t h column in Table I I show t h e res idua l va lue Rj

f o r each data p o i n t ( x . , y . ) .

Other Restra i n ts

Given n+1 data po in t s ( x . , y . ) w i t h weights w . , suppose i t is re-

qu i red t o min imize t h e sum

n+1 (2-13) Sm = I w | [ y , - VmCxr ) 3 2 ,

where Vm(x) is a polynomial of degree m w i t h k r e s t r a i n t s on V (x) a t

x = u . ; wh ere j = 1, 2, . . . , J . The rest ra i nts shaI I be def i ned as Kj

f o l l o w s :

(2-14) v m < r ) ( u ? ) = b r i ' r = 0 , 1 , 2 , . . . , R . , , O 1 J O

where a l l t h e b . are s p e c i f i e d f o r u . . That i s , t h e curve V (x) r J J rn

s h a l l pass t h rough -u . and s h a l l have R. s p e c i f i e d d e r i v a t i v e s where J J

Rj 0. Fu r the r i f any u. = x. } then Xj may be el iminated from t h e n+1

data p o i n t s , s i nce t h i s p o i n t w i l l have no e f f e c t on m in im iz i ng Sm in

Page 39: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

33

(2 -13 ) . This is t r u e because t h e res idue ! y . - vm ^ u j ^ = Yj ~ b

0 j ' s a

cons tan t .

An example of a se t of r e s t r a i n i n g c o n d i t i o n s is t o r equ i r e t h a t

t h e curve V (x ) pass th rough t h e po in t s ( 0 , 0 ) and ( a , b ) , and have s lope

of 0 a t t h e o r i g i n ; then t h e b r - are de f ined as

boi = Vm(0) = 0

b02 = vm

( a ) = b

b u = v ; t o ) = o.

K l o p f e n s t e i n (1) de f ines a t r a n s f o r m a t i o n of t h e p o i n t s ( X j , y . )

such t h a t t he t rans fo rmed problem is o f s tandard l eas t squares t ype

w i t h o u t r e s t r a i n t s . Let W^_^(x) be t h e polynomial of degree ( k -1 ) which

s a t i s f i e s t h e k r e s t r a i n i n g c o n d i t i o n s . Then

(2-15) Vm (x) = W R i (x) + n k ( x ) V m _ k ( x ) ,

where,

J i _j_p. (2-16) n k ( x ) = n ( x - u . ) J .

j = i J

Although t h e ex i s tence of a unique Wk_-| (x) w i l l not be proven

g e n e r a l l y , Theorem 1.2 prov ides a proof where t h e k r e s t r a i n i n g con-

d i t i o n s r equ i r e (x) t o pass th rough k g iven p o i n t s . F u r t h e r ,

Theorem 1.4 , shows t h a t t he re is a unique cub ic polynomial which passes

th rough two g iven po in t s w i t h s lopes g iven a t each of these p o i n t s . The

f a c t t h a t Vm(k) in equat ion (2-15) s a t i s f i e s t h e k_cond i t i ons is ev i den t

s ince t h e second te'rm is zero a t each o f t h e r e s t r a i n i n g p o i n t s .

From ( 2 - 1 3 ) , i t f o l iows t h a t

n+1 (2-17) ^ = - [Wk_fX|> + n k ( x , ) V ,(X|>]}2

j=1

Page 40: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

34

is a l g e b r a i c a l l y e q u i v a l e n t t o

n+1 (2-18) S = £ * , { [ 7 . - W ( x . ) ] - J I k ( x . )V (x , ) } 2

m j = i 1 1 k-1 ' K 1 m-k 1

n U ] 2 f y j - Z ^ k - l ^ i i \ 2

= L w j n k ( x t ) \ n k ( x ; ) - v (x . )j . j = l m-k 1

Thus, w i t h t h e t r a n s f o r m a t i o n

y! = n. (x . ) , w.' = w.nf (x. ) , i k i i i k i '

t h e equat ion in (2-17) reduces t o

n+1

( 2 - ' 9 ) Sm = . ^ w i ' ( y i ' - V m - h ) ) 2 -

Equat ion (2-19) shows t h a t t h e problem is now a s tandard l eas t squares

equat ion of degree (m-k ) .

In p r a c t i c e , K l o p f e n s t e i n ' s t r a n s f o r m a t i o n prov ides a general method

f o r f i t t i n g a l eas t square polynomial w i t h r e s t r a i n t s . However, severa l

c o n d i t i o n s must be cons idered in i t s use. F i r s t , t h e number o f data

p o i n t s n+1 > m, t h e degree of t h e leas t squares po l ynomia l . Second,

t h e number of r e s t r a i n t s k should s a t i s f y the r e l a t i o n k < m. F i n a l l y ,

in t h e f i r s t paragraph i t was s t a t e d t h a t an x. data p o i n t should be

e l i m i n a t e d i f x . = u . . I f a f t e r these d e l e t i o n s , t h e number of data

poinhs remain ing is less than o r equal t o m-k, then t h e method f a i l s .

Example 4: F i t a l eas t squares polynomial of degree 3 t o t h e

data p o i n t s in Table I I . Assign a weight of 1 to each data p o i n t and

r e q u i r e t h a t t h e polynomial pass through t h e po in t s (1 .0 , .159964) and

(2.0,.201186).

The computer program in Appendix B was u t i l i z e d a l a s t t ime t o

Page 41: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

35

per form t h e c a l c u l a t i o n of t h i s example. In summary, t h e polynomial

Wj(x) passing through t h e two requ i red p o i n t s was determined:

Wj (x ) = C.4122-10" 1 )x + .1187.

The remain ing data p o i n t s were t rans fo rmed by K l o p f e n s t e i n ' s method, and

t h e l eas t squares l i n e through these p o i n t s was computed:

V j ( x ) - - ( . 242338 -10~ 2 ) x + .855398.

F i n a l l y , t h e requ i red polynomial V3(x) was determined:

V 3 ( x ) - Wi(x) + ( x - 1 ) ( x - 2 ) V i ( x )

- - ( . 2 4 2 3 - 1 0 " 2 ) x 3 + (.8580* 10~2)x2 - .9016x + . 1 8 2 9 M 0 " 1 .

The res idua l va lue Kj = y j - V3(X j ) f o r each data p o i n t ( x j , y j ) is

shown in the l a s t column of Table I I .

Page 42: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

CHAPTER BIBLIOGRAPHY

1. K l o p f e n s t e i n , K. L . , "Cond i t i ona l Least Squares Polynomial Approx i -ma t i on , " Mathematics of Computat ion, XV I I I (October, 1964), 659-662.

2. P e r l i s , Sam, Theory of Ma t r i ces , Reading, Massachusetts, Addison-Wesley P u b l i s h i n g Company, 1958.

36

Page 43: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

CHAPTER I I I

A METHOD OF SURFACE FITTING

B icub ic Sp l i ne Funct ion

In Chapter I , curve f i t t i n g by s p l i n e f u n c t i o n s was discussed

f o r f u n c t i o n s of one v a r i a b l e . This method may be extended t o f u n c t i o n s

of two v a r i a b l e s , where a b i c u b i c s p l i n e f u n c t i o n is f i t t e d t o a se t of

p o i n t s ( x . , y . , z . . ) t o y i e l d a smooth sur face over t h e reg ion c o n t a i n i n g J o

t h e data po i n t s .

Def i ni t i o n : A b i c u b i c polynomial s h a l l be de f ined as a rea l

f u n c t i on

3 C ( x , y ) - £ ^ n x n y m ,

m, n=0'

where a is a rea l number. mn

Def i n i t i o n : Given a se t of p o i n t s (x. , y . , z . . ) , i = 0 , 1, . . . , n, ^ J ^ J

j = 0, 1, . . m , in a r ec tangu la r g r i d ; a rea l f u n c t i o n de f ined f o r a l l

rea I ( x , y ) on a reg ion R, XQ X _< x^ and yQ y _< y^ , is ca I led a

b i c u b i c s p l i n e f u n c t i o n f o r t h e po in t s and denoted by P (x , y ) i f t h e

f o l l o w i n g p r o p e r t i e s are t r u e :

1) For each Cx. ,y . ,z . . ) , P(y. .y. ) - z. • • J 1J i J i J

2) P (x , y ) has cont inuous f i r s t and second d e r i v a t i v e s ; i . e . ,

FCx^y) is of c l ass C 2;

3) P ( x , y ) is equal on each rec tang le Rj . , x. ^ < x x. , y. ^ < y _< y. t o a b i cub i c po I ynomia ! .

37

Page 44: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

38

D e f i n i t i o n : Each ( x . . v . ) i = 0 1 n. ; - n 1 — — — i ' y j ^» ' u> '» • ••» n ; J - u, 1, . . m w i I I

be ca I i a id po j n t .

g e f i n i + i ° n : G , V e n a r e 9 ' o n R, x0 <_ x <_ V yo < y ym w l t h g r i d

po in ts ( X j j y j ) i 0, 1, n; j = 0, 1, . n ; P ( X j y ) w i l l be ca l l ed

a P.j.ecewise b icub ic po lynomia I over R_ i f

P<x,y) - Cj_i ( x ,y )

rectangle K j j x ,_ , <. x <_ X | ; y . _ , s y <. y J ; where C, . , < x , y ) , s

a b icubic polynomial .

In Theorem 1.11 a set of sp l i ne funct ions in one va r iab le $ k ( x ) ,

k = 0, 1, n+2 was shown t o be a basis f o r the (n+3) dimensional

vec tor space S(x; x Q , X j , . . . ^ ) where the set S was def ined as the set

of a l l cubic sp l i ne funct ions on the i n te rva l [ x Q , x n ] w i th j o i n t s xQ ,

V x n . S i m i l a r l y , l e t 0 | ( y ) , I - 0, 1, . . . , m+2, denote the set

of basis elements f o r the (m+3) dimensional space S(y- y v v ) ' '

yo ' y i ' * ' ' > "m Now l e t T denote the set of a l l funct ions of the form

m-K? n+2 ( 3 _ 1 ) P(x ,y) = L S k | * k ( x ) 0 . ( y ) ,

1-0 k=0

where is a real number.

Lemma 3 . K The set T is a vector space over the f i e l d of real

numbers.

m+2 n+2 Proc lL Let each of P ( x , y ) = £ Z <xk[ * k ( x j e , ( y ) , QCx.y)

m+2 n+2 I £ c

I =0 k=0

z z Y k | * k ( x > 0 | <y) and R(x,y) = E E ? k [ $ k ( x ) 0 , ( y ) be elements of T. Let each

of a and b be real numbers and l e t «+» denote the normal add i t i on of

funct ions,.

Page 45: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

39

i ) T is a s s o c i a t i v e w i t h respect t o a d d i t i o n .

(P+Q) + R

= [ZZa k |4. k (x )e 1 (y) + EEYkl<!»k(x)e i ( y ) ] + E Z C k | ^ ( x ) 0 | (y)

= EEa(<1(j)1(x)0j (y) + [EEyk j <}>k (x )0 j (y) + EE^k] <j>k (x)e ( ( y ) ]

= P + (Q+R).

i i ) S i m i l a r l y , P+Q = Q+P.

i i i ) The se t T has a ze ro , namely Z = EEO^(X)0 (y) such t h a t

P+Z = P.

i v ) Each element of T has an inverse s ince

P + <-P) = Z;

SSo tkI ^ x^ 01 ^ + 2 ^ ~ a k l t y j = z -

v) The d i s t r i b u t i v e law ho lds :

a(P+Q) - alESo f (x)0 (y) + EZy d. <x)6 ( y ) ] Kl K I KI K [

= a E E ak | ^ k

( x ) 0 | (y> + a E r Y k i V x ) 0 i ( y )

= aP + aQ.

v i ) (a+b) P = (a+b)EEt*k| <(>k(x)0 (y) - aP + bP.

v i i ) a (bP) = a[bEEak |<f)k(x)0 | ( y ) ] = (ab)EEak j <}>k (x)6 ( (y) = (ab)P.

v i i i ) There is a u n i t y element 1 such t h a t 1«P = P.

Thus, t h e se t T is a vec to r space over t he f i e l d o f rea l numbers.

Theorem 3 . 2 . Let t h e r e be g iven a se t o f g r i d poi nts ( x . , y .,z. .), ^ <J J

i = 1, . . . , n; j = 0, 1, . . . , m over a reg ion R, x < x < x . v < v 0 — — n ' 'o — y

~ Ym" A l s ° ' e + + h e r e b e 9 ' v e n +he p a r t i a l d e r i v a t i v e w i t h respect t o x

a t each (x0 ,y^ . ) and ( x ^ y ) ; t h e p a r t i a l d e r i v a t i v e w i t h respect t o y

a t each ( x ^ y ^ ) and ( x . , y m ) ; t he p a r t i a l d e r i v a t i v e w i t h respect t o x

and y a t each corner s r i d p o i n t ( x „ , y 0 ) , <x n , y 0 > , ( x , , , ^ ) , <x n ,ym>.

Then the re e x i s t s a unique P(x ,y )eT which s a t i s f i e s these c o n d i t i o n s .

Page 46: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

40

Proo f : From t h e hypo thes is , t h e f o l l o w i n g is g i ven :

z . j - P (x . , y .) i - 0 , 1 , . . . , n; j - 0 , 1 , . . . , rnj

U i i = P v ( x i ' y i ) i = 0 ' n ' J = 0 • • -»m ; (3 -2) 'J x 1 J

v i j = Py

( x { ' Vj } j = 0 , ^ ;

w . . = P ( x . , y . ) i - 0 , n ; j=0 ,m. i j xy i j

Recal l f rom Theorem 1.11 t h e d e f i n i t i o n of t h e basis elements of

< M x ) , k = 0, 1, . . . , n+2, f o r S (x ; x ,x , . . . , x ) . ^ u i n

ro i / - k (3 -3) <l>k(x j) = 6 . r = \ 1 i=k ; ^ ( x q ) = ^ ( x n ) = 0 I , k=0,1 n;

( 3 - 4 ) * n + 1 ( x i 5 - c f 'n+2 ( x i5 = 0

( 3 ~ 5 ) ' W V = • i + 2( x n ) = 1 ' ^n+1 ( x

n5 = W V = ° -

The 9 | ( y ) are s i m i l a r l y de f i ned . From ( 3 - 1 ) ,

m+2 n+2

z u = p < x i ' y j ' = | 0 J ^ k ' V V V -

m+2

z i j V V + B i i V x i ) + " - + W , i W x i " e i ( V j ) '

and m+2

(3 -6 ) = Z eM

0 | ( y . ) , i = 0 , 1 , . . . , n; j =0, 1, . . . m; 1=0 1 J

s ince f rom ( 3 - 3 ) , <^ (x . ) = 0 f o r I i- k and 1 f o r j = k. The same is

t r u e f o r 0 j ( y . ) ; t h e r e f o r e ,

z i j = P j j> i r r°> • > • • • >n; j = 0 , I , . . . , m .

n+2 m+2 u i j = P x < x i ' V j ' = | o | I ^ i ^ < X | ' 9 | < y J ) i =0 ,n ; j = 0 , 1 m.

n t ? f 1 i J * =0 ( 3 - 8 ) U i J = J o V ; < x , l »

I h i s is t r u e from ( 3 - 3 ) , ( 3 - 4 ) , and t h e cor responding equat ions f o r

<S|!yj>.

Page 47: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

41

rn+2 n+2 V i i = P v < X i , Y i ) ^ ^ k<x i } 9 ! ( y i 5 f = 0 ' 1 » * " » n ; J"°>m. 'J y i J ( = 0 k=.0 k i k i I j

„ m+2 31 ,m-M / J=0 v . j . = | l 6 | | e ; ( y j ) e i i m + 2 t j = m .

.Equat ion (3 -9 ) f o l l o w s f rom ( 3 - 3 ) , ' (3 -4 ) , and ( 3 - 5 ) .

m+2 n+2 w i j = p x y ( > : i , y j ' = | 0 J j y k ' v i ' v i = o - ^ j = ° ' m -

For i=0,

, , m i 2 3n+1,m+1 r i =0 , j=0 ( 3 ~ 1 0 ) w j j =

( ^ )3

n + 1 , I 0 ! ( Y j ) = 3n+2,m+2 { i=0, j=m.

For i - n ,

Thus t h e r e e x i s t s a unique set of 6 . . , i = 0, 1, n+2; j - 0 ,

1, rn+2, f o r t he g iven c o n d i t i o n s . The se t of 0. . is de f ined by ^ J

equat ions (3 -7) Ih rough (3—11). F i n a l l y , t h e unique se t B. . de f ines a ^ J

unique P(x ,y )eT s a t i s f y i n g t h e g iven c o n d i t i o n s in ( 3 - 2 ) .

Coro1 I a ry 3 . 3 . The s e t T is t h e se t of a l l b i c u b i c spl ine f u n c t i o n s

over t h e reg ion R w i t h g r i d po in t s ( x . , y . ) , i = 0 , 1, n; j = 0 , 1, ^ *J

. . . , m.

P roo f : Let Q(x ,y ) be a b i c u b i c s p l i n e f u n c t i o n over t he reg ion R

w i t h g r i d p o i n t s ( x . , y . ) . There e x i s t values of Q(x ,y ) f o r each con-

d i t i o n in ( 3 - 2 ) . The re fo re , f rom Theorem 3 . 2 , Q(x ,y )eT.

Let P ( x , y ) e T ; j _ . e . ,

m+2 n+2 P (x , y ) = £ ^ 3 [ < | ^ | < ( x ) 0 | ( y ) .

1-0 k=0

<j>k(x) and 0 ( ( y ) each have j o i n t s x Q , x l 5 . . . , xn and y 0 , Y l , y^

r e s p e c t i v e l y . Fu r the r they are each p iecewise cub ic and of c lass C^.

Page 48: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

42

Thus, any I i near combi nat ion of 4> k ( x ) a n d 0 j ( y ) is of c iass C2 and is

p iecewise b i c u b i c over t h e reg ion R. The re fo re , P (x , y ) is a b i c u b i c

s p l i ne f u n c t i o n .

Coroi I ary 5 . 4 . The se t of b i c u b i c s p l i n e f u n c t i o n s V = {<f> ^ (x) *

0 . ( y ) , k = 0, 1, . . . , n+2; I - 0 , 1, m+2; w i t h j o i n t s x. f o r <jv (x) I K

and w i t h j o i nts y^ f o r 0 j ( y ) } is a bas is f o r t h e b i cub i c s p l i n e f unc t i ons

over R w i t h g r i d po in t s ( x . , y . ) .

P roo f : From C o r o l l a r y 3 .3 , i f Q(x ,y ) is a b i c u b i c s p l i n e f u n c t i o n

over R, t hen Q(x ,y ) can be represented as a l i n e a r combinat ion of t h e

<f>k(x) • 0 | ( y ) .

F u r t h e r , t h e se t V is l i n e a r l y independent; because i f t h e b i cub i c

s p l i n e f u n c t i o n Q(x ,y ) = 0 over R, then

m+2 n+2 m+2 n+2 = 1 I e k i , M x ) e i < y ) = £ To-«j> ( X ) e . ( y ) .

1=0 k=0 |=o k-0 1

Theorems t o Aid i n Sp l i ne Funct ion Computation

The above theorem and c o r o l l a r i e s show t h a t t he re is a unique

b i c u b i c s p l i n e f u n c t i o n over R of t h e form

m+2 n+2 P<x,y) = I £ P k , < M x ) 0 . ( y ) ,

1=0 k=0

which s a t i s f i e s t h e c o n d i t i o n s g iven in ( 3 - 2 ) . The procedures developed

in Chapter I may be used t o compute the <f>k(x), k = 0, 1, . . . , n+2 and '

0 | ( y ) , I = 0 , 1, . . . , m+2 and thus determine P (x , y ) f o r t h e g iven con-

d i t i o n s . However, i t is p o s s i b l e by use of t h e f o l l o w i n g two theorems

t o u t i l i z e a more d i r e c t means of computing 1he b i cub i c s p l i n e f u n c t i o n

f o r t h e c o n d i t i o n s g iven in ( 3 - 2 ) . This is done by ex tend ing Theorems

l . 4 and 1.6 t o theorems i n v o l v i n g two v a r i a b l e s .

Page 49: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

43

By d e f i n i t i o n , t h e b i c u b i c s p l i n e f u n c t i o n P (x , y ) equals a b i c u b i c

polynomial i n R j j ; x j _ i <_ x <_ Xj ; y j _ i <_ y <_ y j . This b i c u b i c polynomial

may be w r i t t e n in t h e form

<3-12) c <x,y) = | £ ^ J < x - x > k < y -y ) ' ,

'J I =0k-0 J

where t h e s u p e r s c r i p t s on i n d i c a t e t h e p a r t i c u l a r R. . in R.

The f o l l o w i n g Theorem 3 .5 determines a b i c u b i c s p l i n e f u n c t i o n f o r

t h e spec ia l case where n = m = 1. Al though one method f o r t h i s d e t e r -

m ina t ion was shown in Theorem 3 . 2 , a d i f f e r e n t method w i l l be presented

s ince i t is use fu l in t h e computat ion of o the r s p l i n e f u n c t i o n s .

Theorem 3 . 5 . There is e x a c t l y one polynomial c . . ( x , y ) which ^ J

assumes g iven values f o r e . . ( x , y ) , _9_ c. . ( x , y ) , _9c. . ( x , y ) , and J 9x J 3 y J

JL c j j ( x , y ) a t each of t h e f ou r corners o f t h e rec tang le R . . . 8x9y

Proo f : Let each of t h e f o l l o w i n g be g iven a t rn = i - 1 , i ; n = j - 1 , j :

zmn = c i j ( V V ' u = 3 c. .

r ~z i i \ 7i— (3.-13) 3x

mn — " i j ^ ' ^ n ^ '

vmn = - i c | j ( V Y n > : 9y J

wm n

=

8 x9y

S u b s t i t u t i n g each o f t h e f o u r ( xm > y n > z

r f l n ) i n t o equat ion (3-12) and t h e

o the rs ( V V V i ^ and ( x m , y n , w m n ) i n f o t h e a p p r o p r i a t e

d e r i v a t i v e y i e l d s s i x t e e n l i n e a r equat ions in s i x t e e n unknowns a k | ,

where k , I = 0, 1, 2, 3. I h i s system may bo expressed in m a t r i x n o t a t i o n

Page 50: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

44

(3-14)

1 0 0 0

0 1 0 0

1 Ax • Ax2 Ax3

0 1 2Ax 3AX2

a0 0 a01 a02 ^

a10 a l l a l 2 ^3

a 2 0 a 2 1 a 2 2

_a30 a31 a32 ^

1 0 1 0

0 1 Ay 1

0 0 Ay2 2Ay

0 0 Ay3 3A'/

e . . i j

_

where Ax X -X ; Ay = y.-y, ; and 1 i - 1 j j - 1

mn

z v mn mn

u w mn rnn

Equation (3-14) may be r e w r i t t e n in t he form

(3-15) X* A* Y = B.

Each of t he matr ices X and Y is nons ingu lar and has an inverse; t h a t i s ,

1 0 0 0

(3-16) X < • - 1 =

0 1 0 0

-3 3 - l Ax2 Ax A>? Ax

_2 -2 _1_ Ax3" AX2 AX3" AX2

and Y"1^

0 -3 Ay3

0 1 - 2 1 Ay Ay2

0 0 3 - 2 Ay2 Ay3

0 0 -1 1 Ay Ay^

The next equat ions f o l l o w from (3-15) and t h e p rope r t i es of matr ices in

t he s o l u t i o n of l i n e a r systems.

X" 1«X« A« Y - X-^B

l -A-Y-Y" 1 = X~]*B»r1

(3-17) A = X ^ B - r 1 .

There fo re , from equat ion (3 -17 ) , t he re does e x i s t a unique ma t r i x A

Page 51: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

45

d e s c r i b i n g a unique se t ; k, 1 = 0 , . . . , 3; and i t f o l l o w s t h e r e is

one polynomiaI . of t h e form of (3-12) s a t i s f y i n g t h e c o n d i t i o n s in

( 3 -13 ) .

Theorem 3 .6 . I f t h e values in (3 -2 ) are g i ven , t hen , f o r P (x , y )

of t h e form ( 3 - 1 ) , t h e values

u i j " P x ( x i ' y j ) J = 0 , 1 , . . . , m ) ,

(3-18) v . j = py

( x i ' Y j 5 ( i = 0 , 1 , . . . , n ; j = 1 , 2 , . . . , m - 1 ) ,

wi j ^ px y ( x j , y j > ( i - 1 , 2 , . . , n -1 , f o r j - 0 , m ) ( i = 0 , 1 , . . , n; j = 1 , 2 , . . , m-1) ,

are un ique ly determined by t h e f o l l o w i n g 2n + m + 5 l i n e a r systems of

a l l t oge the r 3mn + n + m - 5 equa t ions :

f o r j = 0, 1, . . . , m,

(3-19) Ax ._ 1 u i + I ) j + 2 ( A X . _ 1 + A x i ) u . j + A x i u j _ 1 > j =

ferJ- . A * i 1 31 Ax. ( z i + 1 ) J - z i j } + 4 x i _ 1 ( z . . - z . . 1 j j ) J )

i —1,2,...,n—1•

f o r j=0 ,m,

(3-20) AX; i W ; , , ;+2(AX; < +Ax- )w : ;+AX. W- , . = i - l i + l , j i - i i IJ i i - l , j

fA x ; i Ax; 1 3 1 4 k , < v , + 1 j J - v | J ) « X | . l ( v I J - v | . 1 > J ) J ,

i — 1 , 2 , . . . , n— 1

f o r i = 0 , 1 , . . . , n ,

(3-21) A y j _ t v i ) j + l+2(Ay j ._1+Ay j . J V j j + A y j V j ^ . , , =

3[ Ay. ( z i ^ j+1 ~Z i j ) + ^ y j - 1 Czi j ~ z i , J - 1 ' J j

j—1,2 , . . . ,m—1j

f o r i = 0 , 1 , . . . , n ,

Page 52: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

46

(3 -22) Ay. .w. . , +2 (Ay . . -fAy. )w. .H-Ay. w. . . = yJ"1 i , J + 1 XJ-1 XJ 'J yJ i , J - 1

r A y j - i A x u i 31 Ay. (u. . , -u . . )-tAy. , (u. . - u . . , )| , L yJ I f J + 1 IJ \ H 'J I , J " 1 J '

J - 1 , 2 , . • . , m - 1

P r o o f : The v a l u e s in (3 -2 ) a re g i ven ; t hese are i l l u s t r a t e d in

F i g u r e 1, where a r e g i o n R is shown w i t h (n+1)x(m+1) g r i d p o i n t s a long

w i t h t h e g i ven va lues a t each g r i d p o i n t .

z u z z . . . z u j=m * * * * J v w v v v w

j = m - 1

j = 1

J=0

z u z z z u * * * *

z u z z z u * * * *

z u z z z u * * * *

V w V V V w

o ii 1=1

CM

II i=n

F i g u r e 1

A long each g r i d I i n e y = y . , j = 0 , 1, . . . , m,

P ( x , y ) - p j . ( x ) e S ( x ; x 0 , x 1 , . . . , x n ) and P x ( x , y .) = P j ( x ) -

By C o r o l l a r y 1.8 of Chapter I , t h e numbers p ' j ( X j ) = P ( x r , y j ) = U t j , J vj U

i = 1, 2, . . . , n - 1 , a re u n i q u e l y de termined i f p j ( x j ) , 1 = 0 , 1, . . . ,

n, and p l ( x 0 ) , P j ( xn ) a r e known. Since P j ( x j ) = Z j j and p j ( x Q ) = u 0 j ,

^ j ^ X n ' ~ U n j a r e 9 ' v e n ^ o r J = • • * > m> '"I" f o l l o w s f rom C o r o l l a r y

1.8 t h a t u . ., ( i = 1 , 2 , . . . , n - 1 ; j = 0 , 1 , . . . - , m ) is u n i q u e l y determined

by t h e m+1 s e t s o f n -1 equa t ions in ( 3 - 1 9 ) .

A long each g r i d l i n e x = x . , i - 0, 1, . . . , n,

P(x»y) = s , ( y ) e S ( y ; y 0 , y i , . . . , y m ) , and P y ( x j , y ) -- s» j (y ) .

Page 53: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

47

By s i m i l a r reasoning as in t he preceding paragraph, t he equat ions in

(3-21) determine v . . ( i - 0 , 1 , . . . , n ; J - 1 , 2 , . . . , m ~ 1 ) un ique ly , given

the va lues of ( 3 - 2 ) . F igure 2 i nd i ca les the parameters which have now

been determined.

j=m z u *

V w

z u * V v*U •

z u * V w

j=m— 1 z u * V

z u * V

z u * V

z u * V

J=1 z u V*

z u V*

#

z u V*

J=o z u v*w

z u V * v* U •

z u * V w

1=0 i - 1 1=2 i =n

F igure 2

Along each g r i d I i ne y = y . , j = 0, m, vi

P y l x . V j ) = I * k C x > t E B k | e | < y j ) ] = q j ( x )£S Cx;x0 , Xj x n ) ;

an<^ ^ x y ' x ' ' ~ ^x^ * ^ ' n c e 1 j ' x j ' = w j j » ' ~ n> a 'id q j ( X j ) = v . . , ^ J ^ j

i - 0, 1, . . . , n, are given f o r j = 0, m; equat ion (3-20) is of the form

of C o r o l l a r y 1.8 and t h e r e f o r e un ique ly determines W j j , ( i = 1,2,... n-1-

j = m), g iven the values in ( 3 - 2 ) .

F i n a l l y , f o r each i = 0, 1, . . . , n; P x ( x , , y ) = ze, ( y ) t z e k l ^ ( x f ) ]

= r f ( y ) e S ( y ; y o , y i , . . . , y m ) a n d P x y ( X | , y ) - r ( ( y > .

For each i = 0, 1, r | < y j ) = P x ( x „ y j ) . j = 0, 1, m, , s

e i t h e r g iven or i t can be un ique ly determined from (3 -19 ) ; arid r ' ( y - ) , ^ J

j - 0, m is e i t h e r g iven or can be determined from (3 -20 ) . Co ro l l a r y

1.8 is used a las t t ime t o conclude t h a t w- - ( i — 0 1 n- i - 1 ? IJ V l J - i j Z ,

Page 54: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

48

. . . , r n - l ) , is un ique ly determined by equat ion (3 -22 ) , w i t h (3-19) and

( 3 - 2 0 ) , g iven ( 3 - 2 ) .

The re fo re , t h e g iven values in (3 -2) and equat ions (3-19) th rough

(3-22) determine un ique ly t h e Z j j , u - j , v - j and w j j a t each g r i d p o i n t ,

F i gu re 3 i l l u s t r a t e s t he conc lus ions of t h e theorem.

J=m z u z u z u z u

X * X * V w V w V w V w

z u z u z u z u * X V w V w V w V w

z u z u z u . . . z u J* ~ 1 SL

1 V W V W V W v w

z u z u z u . . . z u v*w V*W V*W V*W

i=0 i=1 i=2 . . . . i=n

F i gu re 3

Procedure f o r Computation of a Sp l i ne Surface

Given the equat ions in ( 3 - 2 ) , t h e systems of l i n e a r equat ions in

(3-19) th rough (3-22) may be u t i l i z e d t o determine t h e u , V j j » a n c '

w, . in ( 3 - 1 8 ) . Each of t h e systems of equat ions i n (3-19) th rough

(3-22) can be expressed as a m a t r i x equa t ion where t h e c o e f f i c i e n t

m a t r i x is t r i d i a g o n a l and of t h e form shown in C o r o l l a r y 1.8 of

Chapter I .

A method w i l l now be descr ibed f o r t h e s o l u t i o n of a system of

l i n e a r equat ions whose c o e f f i c i e n t m a t r i x is t r i d i a g o n a l . The Crout

Reduct ion Method of s o l v i n g n_ l i n e a r equat ions is we l l known in numer-

i c a l a n a l y s i s (2, pp. 429-434) . Crout computes a der i ved m a t r i x

Page 55: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

49

^ = I I a j j I I f r o m +he coef f ic i en t m a t r i x A = | | a. . [ | and a der ived ^ J

m a t r i x C1 = | | c | | f r o m t h e cons tan ts C = | J c , | | . These are then

employed in t he c a l c u l a t i o n of t h e s o l u t i o n se t x. . The elements of

t h e de r i ved mat r ices and t h e s o l u t i o n se t are computed as f o l l o w s :

'J 'J k=1 ik k j ' ( 3 ~ 2 3 ) i>J ;

( 3 ~ 2 4 ) a ! • = f a - • • Z a . 1 a ' "J L i J ^ i k kj-1 i i '

i < j ;

i - i ( 3 ~ 2 5 ) C« = f c . - y a> c ' T / a t •

1 ^ 1 [£'1 1 k k ' '

(3-26) x! - ci - i 'ikv k= i + 1

where _i_ and j_ range f rom 1 t o n. In ( 3 - 2 3 ) , t h e summation is zero when

j = 1. S i m i l a r l y t h e summation te rm of t h e o the r t h r e e equat ions is

ze ro when t h e upper l i m i t of t h e summation te rm is less than t he lower

l i m i t . The order of computat ion in C r o u t ' s Method is t o compute each

element in t h e f i r s t column of t h e de r i ved m a t r i x A' by ( 3 - 2 3 ) ; then t o

compute elements 2 ih rough n of t h e f i r s t row by (3—24). Next compute

t h e remain ing n - 1 elements of column 2 by (3-23) f o l l owed by t h e n -2

elements of row 2 by ( 3 - 2 4 ) . The procedure cont inues u n t i l a l l elements

of A' have been c a l c u l a t e d .

Since t h e elements on each row _i_ of a t r i d i a g o n a l m a t r i x are zero

except t h e elements a . ^ . ; and a. f + 1 ; t h e equat ions in (3-23)

th rough (3-26) have zero terms. There fo re , t h e equat ions reduce t o t he

f o I lowing:

Page 56: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

50

(3-2.7) a.'. = a. . , f o r i > j ; 'J "J

(3-28) ^ = a x i ' a,' j = a i j - a i ' - , , j - a i ' , j - , f o r

(3-29) a.'. = a. . / a . ' . , f o r i < j ; I J I J I I

(3-30) c- = a / a ^ ; c y < c , " a , f , _ , •=,'_, >/=/ , , f o r i > l ;

( 3 - 3 , ) xn = c^ ; x. = c . ' - a . ' _ . + 1 . x H | f o r K n .

F u r t h e r , each c f and a.! te rm in (3-31) has an a.*, denominator in I ( y I "T* I j j

i t s e v a l u a t i o n in (3-30) and (3-29) r e s p e c t i v e l y . The re fo re , l e t

(3-32) d, = c , ; 0( = C j ~ s | J , - j ' dj ^ , ' ' o r i =2 ,3 , t h e n ,

< 3 - 3 3 ) x n = d n / a ^ n ; x, = " r a i > i + 1 - x i + 1 ) / a ; . , f o r i = n - l , n - 2 t .

Thus, by t h e use of (3-28) and (3 -32 ) , t h e s o l u t i o n of a system of

l i n e a r equat ions whose c o e f f i c i e n t m a t r i x is t r i d i a g o n a l is g iven by

( 3 - 3 3 ) .

The above method may be used t o so lve t h e systems of I i n e a r

equat ions (3-19) th rough (3-22) in Theorem 3 . 6 , which a id in computing

1 he s p I i ne f u net ion. Si nee on ly two d i s t i net coef f i c i en t matr i ces

appear in t h e systems of equat ions in (3-19) th rough ( 3 - 2 2 ) , equat ions

of t h e form of (3-28) need t o be computed on l y t w i c e . Equations (3-32)

and (3-33) are computed f o r the s o l u t i o n s of each of t h e 2m+n+5

systems. Th is computat ion y i e l d s t h e z . . , u. . , v . . , and w. . a t each ^ J ^ J J ^ J

of t h e g r i d po in t s ( x . , y . ) of t h e su r f ace , • ^ J

F i n a l l y , t h e s i x teen coef f i c i ent s of eac h b i cu b i c poIy nom i a I

C | j ^ X ' Y ^ ° n ^ r ' c ' s c l u a r e R j j a r e computed by equat ion ( 3 - 1 7 ) . Once

t h e c o e f f i c i e n t s a ^ of (3-12) are computed f o r each R. . , t h e e v a l u a t i o n J

o f t h e s p l i n e f u n c t i o n a t a p o i n t ( x ' , y » ) reduces t o f i n d i n g t h e ( i , j )

such t h a t ( x f , y ' ) e R . j and e v a l u a t i n g t h e cor respond ing b i c u b i c f u n c t i o n

Page 57: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

51

a i (x* , y ' ) ; j jd e s t ,

c . j ( x ' , y ' ) = z».

- x a r " p l e 1 : F , t a b i c u M c s P l i n e f u n c t i o n t o t he data p o i n t s shown

I - F igu re 4 . Let x „ - 4000; 4x. = . ,000; y 0 . 6000; and 4 y . .

y j ~ y j - 1 1 0 0 0 ' w h e r e i and j each range f rom 1 t o 3 .

* * * z 1452 1368 1274 u - . 023 V - . 1 2 7 - . 1 1 8 - 185 " 1 q/I w - 259*10 ~5 ~ - . 194

^ I U - . 3 5 6 - 1 0 " 5

*

1199 -.088

* * *

z 1564 1515 1 4 4 4 u -.012 v

*

1368 - . 075

z 1647 1618 u - . 0 1 1 v

* * * * *

157-5 1530 - .048

* * * 1680 1650

*

z ^731 1718 U ~ - 0 2 0

v - . 0 6 2 - . 051 _ 054 ~ n t H w .900*10~5 ' - . 065

121 • 10""^

F igure 4

A program which appears In Appendix C was used f o r the computat ion

t h i s example. A t o t a l of n ine b i cub i c equat ions of t h e form

'3 3

E Eakl

(x-x - j ' C y - y . . ) k 1=0 k=0 k l 1 - 1 J -1

were determined.

c o e f f i c i e n t s a k j o f each is shown in m a t r i x form a long w i th

t h e reg ion R | J over which t he b i cub i c equat ion p e r t a i n s .

Page 58: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

52

R 11

R 12

R 13

R 21

[4000<x<5000; 6000<y<7000]

Power of Y 0 X 0 1.731-103

1 2 3 Power of Y 0 X 0 1.731-103 -6.200 •10" .2 -4 .146 ' 10" •5 1.946* 10" 8

1 -2.000*10-2 9.000 •10" -6 2.773* 10" 9 . -2.773* 10" 12

2 2.421 • 10-5 9.004 • io- -9 -1.183- 10" 10 6.031- 10" 14

3 -1.721-10-8 -7.004 •10" -12 6.562- 10" 14 3.464- 10" 17

[ 5000<x<6000; 6000<y<7000]

Power of Y 0 X 0 1.718-103

1 2 3 Power of Y 0 X 0 1.718-103 -5.100 -10" -2 -9.135- 10"" 5 4.235* 10" 8

1 -2.321-10-2 5.996 •10" -6 -3.694- 10" 8 1.391* 10" 11

2 -2 .741-10" 5 -1.201 •10" •8 7.857- 10" 11 -4.363* 10" 14

3 1.262 *10"8 3.013 •10" -12 -3.077- 10" 14 1.686- 10" 17

[6000<x<7000; 6000iyl7000 ]

Power of Y 0 X 0 1.680-103

1 2 3 Power of Y 0 X 0 1.680-103 -5.400 •10" •2 QO

O

00 I 10" 5 2.948* 10" 8

1 -4.018 ' 1 0 ~2 -8.983 •10-•6 2.790* 10"" 8 -2 .279 ' 10" 11

2 1.044-10"5 -2.970 •10-•9 -1.374* 10" 11 6.937* 10" 1 5

3 -2 .686MO" 1 0 9.523 •10-•13 -8.666* 10" 1 5 6.358- 10" 18

[4000<x<_5000; 7000<y<8000]

Power of Y 0 X 0 1 .647 *10 3

1 2 3 Power of Y 0 X 0 1 .647 *10 3 -8.654 •10" 2 1.691 - 10" 5 -1.337- 10" 8

1 -1 .100 -10" 2 6.227 •10" 6 -5.546- 10" 9 -1.681 ' 10" 12

2 -2.476-10 ~5 -4.663 •10" 8 6.265* 10" 11 -4.588- 10" 14

3 6.761*1 0 ~9 2.029 -10" 11 -3.832 * 10" 14 2.889* 10" 1 7

Page 59: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

53

R : [5000<X<6000; 7000<y<8000]

R2 3

31

Power of Y X 0 1.618 -103 -1 .067 * 1 0" 1 3 .570 -10 " 5 -3 .205-•10-.8

1 - 4 . 0 2 4 * 1 0 " 2 -2 .615 •10" 5 4.789-10™3 -6 .782- 10--1?

2 -4 .477•10~ 6 1.425' -10" 8 - 5 . 2 3 1 - 1 0 " 1 1 4.078- 10" -14

3 1.716*10~ 9 -7 .963 ' • 10~12 1 .980 ' 10_ l i f -1 .440- 10' -17

[6000<x<7000; 7000<y<8000]

Power of Y X 0

0 1 2 3 Power of Y X 0 1.575*103 -1 .265* i o " 1 7 .965-10 - 6 -1 .245- 10" -8

1 -4 .405-10~ 2 -2 .154* 10" 5 - 4 . 0 4 6 - 1 0 " 8 3.158* 10" •] 1

2 6.704-10~7 -9 .640* 10~9 7.071•10~ 1 2 -2 .416* 10" •15

3 -1 .625- 10""9 2.693* 10" 1 2 1 .040.10-1L f • -8 .694* 10" •18

[4000<x<5000; 8000<y<9000]

Power of Y X 0

0 1 2 3 Power of Y X 0 1.564-103 -9 .283* 10"2 -2 .320 .10~ 5

4.032- 10" 9

1 -1 .200-10~ 2 -9 .908* 10~6 - 1 . 0 5 9 . 1 0 " 8 9.498- 10" 12

2 -5 .462-10~ 5 -5 .896* 1 o~8 - 7 . 4 9 9 . 1 0 " 1 1 9.088- 10" 14

3 1.761*10~8 3.031* 1 0 " 1 1 4.834.10" l l + --5.957* 10" 17

R 3 2 : [5000<X<6000; 8000<y<9000]

Power o f Y o 1 2 X 0 1.515" 10 -1.314* 10"1 - 6 . 0 4 4 . 10~5 4.484 *10~8

1 -6.838* 10"2 -3 .692* 10~5 -1 .556- 10~8 1 .256 • i o - 1 1

2 - 1 .767* 10"6 3.195- 10~8 . 7 .002. 10" 1 1 -9 .782

J* •—1 1 O

3 -8 .491* i o " 1 0 -1 .157- 10" 1 1 -2 .340- 10"1'4 3.774 *10" 1 7

Page 60: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

54

R 3 3 : [6000<X<7000; 8000<y<9000]

Power of Y 0 1 2 3 X

0 1.444-103 -1.479*10~1 -2.938*10~5 7.310*10~9

1 -7.447*10~2 -7 .715*10" 6 5 .429*10"8 - 4 . 9 8 9 * 1 0 - 1 1

2 -4.315* 10"5 - 2 . 7 4 7 ' I C f 9 -1 .780* 10~13 2.539* 10" l l f

3 2.780* 10"9 -2.577*10" 1 2 -1.568* 1 0 " l l t 1 .001*10" 1 9

In a d d i t i o n the f o l l o w i n g po in t s on the sur face were computed:

(4500, 6500, 1685); (5500, 7500, 1542); (6500, 8500, 1327).

Page 61: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

CHAPTER BIBLIOGRAPHY-

1. De Boor, C a r l , "B i cub i c Sp l ine I n t e r p o l a t i o n , " Journal of Mathematics Phys i c s , XLI (September, 1962), 212-218.

2 . H i ldebrand, F. B . , I n t r o d u c t i o n t o Numerical A n a l y s i s , New York, McGraw-Hil l Book Company, 1956.

55

Page 62: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

APPENDIX A

PROGRAM TO COMPUTE SPLINE FUNCTIONS

Method of Computation

The program, SPLINE, is w r i t t e n in t h e Fo r t ran language f o r a

CDC 6600 computer. I t u t i l i z e s c e r t a i n theorems which were proven in

Chapter I . The system of l i n e a r equat ions in (1-17) of C o r o l l a r y 1.8

is cons t ruc ted f rom t h e inpu t data : (x . , y . ) , i = 1, 2, . . . , n; s ^ t h e

d e r i v a t i v e a t x : and s , t h e d e r i v a t i v e a t x . The s o l u t i o n of t h e i n n

system of equat ions is determined by use of C r o u t ' s Method f o r s o l v i n g

l i n e a r equa t ions ; t h i s computat ion prov ides t h e s lopes s. a t each of

t h e i n t e r i o r p o i n t s i = 2, 3, . . . , n - 1 . F i n a l l y , equat ion (1-15) of

Theorem (1 -4 ) is u t i l i z e d t o determine t h e cub ic polynomial on each

i n t e r v a l (x. , , x . ) , where i = 2, 3, . . . . n. i - 1 i ' ' '

Each i n t e r v a l (x. , , x . ) and t h e c o e f f i c i e n t s of t h e r e l a t e d cub ic i - l i

po lynomia l are p r i n t e d on an ou tpu t l i s t i n g .

P repara t i on of Input Data

Data is input f o r t h e computer v i a punched cards . A d e s c r i p t i o n

f o r cod ing these cards f o l l o w s . I t inc ludes the parameter, i n c a p i t a l

l e t t e r s , t o be coded; t h e card columns in which t h e parameter is t o

appear; and t h e F o r t r a n fo rmat . In a d d i t i o n a d e f i n i t i o n of t h e para-

meter is g i ven .

Card Type J_

N_ Columns 1-10 Format 110 The number of data po in t s t o be read.

56

Page 63: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

57

S1 Columns 11-20 Format F10.0 The d e r i v a t i v e a t t h e f i r s t p o i n t .

S n Columns 21-30 Format F10.0 The d e r i v a t i v e a t t h e f i n a l data p o i n t .

Card Type I I

X ( I ) , Y d ) , I=1,N Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 Data p o i n t s . Each x.. and y j is coded in p a i r s w i t h f ou r p a i r s per card . These are coded on successive cards u n t i l a l l of t h e N dafa p o i n t s have been coded. Fu r t he r t h e X ( I ) ' s must be in numerical o r d e r .

Tra i l e r Card Columns 1-10 Format 110 A -999 is coded in columns 7 th rough 10 t o t e rm ina te t h e program.

A l l parameters should be coded r i g h t j u s t i f i e d in t h e columns i n -

d i c a t e d . Any of t h e parameters S | , s , X ( l ) , o r Y(1) may inc lude a

decimal p o i n t i f necessary t o represent i t a c c u r a t e l y .

The program can compute any number of s p l i n e f u n c t i o n s in a g iven

computer j o b ; t h i s is done by coding Card types I and I I f o r each de-

s i r e d spl ine f u n c t i o n . Fo l l ow ing t h e data f o r t h e l a s t spl ine f u n c t i o n

a t r a i l e r card must be coded.

Page 64: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

58

L I S ' i l N o OF FGKTRA'M PROGRAM

P R O G R A M S P U l f v t ( i N P U T , C U I F U r , I A P F 2 0 ) .

O l M f i i M S ! 0 ^ A ( 5 U » b O ) •> C ( 5 0 ) » X ( 5 0 ) > V ( 5 0 ) , t )E|_T X ( 5 0 ) » S ( S O )

5 REAO .10 » n » S ( 1 ) • S ( " i ) » ( X ( l ) , Y ( I ) i l = I , M>

1 0 F O R M A T ( I ]. 0 » 7 F 1 0 . 0 » / • ( 8 F 1 0 . 0 ) )

I T ( r O 2 0 0 1 2 0 0 > 1 5

1 5 0 0 2 0 I » 2 , N

2 o » E L r x ( I - I I = X ( D - U I - I I

DO 2 5 1 - 1 , 2 5 0 0

2 5 M i ) = 0

N K 2 = W - 2

1)0 1 0 0 I = 1 » N M 2

C ( I ) = 3 . * (OF L T X ( I ) (Y ( 1 + 2 ) - Y ( I + 1 ) } / b E L T X ( I + 1 ) +

i O E ' L T X ( I + ) ) » ( Y ( I + 1 ) " Y ( I ) ) / D t l T X ( J ) )

A ( i , i > - 2 , * ( d f l t x ( t + i ) H ) t v r x ( n )

I f ( I » E C ? « 1 ) 5 5 • t>5

5 5 C ( I ) ~ C ( U - S f 1 ) * O E L T X ( 1 + 1 )

6 0 TO 1 0 0

b 5 A ( I , 1 - 1 J 1 X ( 1 + 1 )

I F { I , ! : _0. tvt- '2) 7 5 » 8 0

7 5 C < I } = C ( t ) - S ( N ) # n £ L T X ( 1 )

o o r o l o o

f 'O A ( I i I + 1 ) - D E L TX ( I )

1 0 0 COtV T I t ' t J E

PR I XT 1 0 1

101 F C m - ' A r (JHJ » « I M r i AL HA I'R 1 CES#) DC J 2 0 I " l , r . > M 2

P H t N ' T 1 1 5 i ( A ( l » j ) i J = 1 » N M 2 ) » C ( I )

3 J 5 FCpr-'Aj (10F 12, A) l'*0 c o n t i n u e

C A L L C R O t ' T ( A , c , s ( 2 ) , N M 2 )

P R I N T 1 3 0 , ( S ( 1 ) s I - - 1 i N )

1 3 0 F O ^ N ' A T ( i H O i * S C L U T l H N ^ A T R I X * / ( 1 0 F 1 2 . 4 ) )

P R I N T 1 4 0 N i V i = N « 1

DC 1 7 5 I - 1 1 M M 1

O t * L T Y " Y ( I + l ) - Y ( I >

r 3 = ( 3 . 1 ' 0 E L T Y / D E L T X - S ( l + l ) ~ 2 . 1 : - S ( l ) ) / 0 E L T X { i )

T ' i - ( " 2 « ^ u c l - T Y / OF L ' f X { I ) + s ( I + 1 ) + s ( I ) ) / O E L T X ( I ) # « 2

P R I N T 1 7 0 , X { J ) j Y ( 1 ) » Y ( { ) ) S ( 1 ) ) T 3 > 1 4 , ' X ( I )

1 / 0 F O R M A T U HO » ft {<*» F b " « 0 » <*,<!•) F S . O * •&)•& i 5 X » 4 F 1 0 , 3 » 5 X »

1 H F! F r. T - X - & j F 1 0 * 3 )

1 / 5 C O N T I N U E "

1 4 0 F C R V A T < 1 H 0 » « S P L I N E F U N C T I ON , S (X ) . # / # CM I N T E R V A L ( A , B ) «

1 » * » S ( x ) --F { r ) ~ ^ • 3 6 \ 1 I T + ! ' T $ 2 + , WHERE f ~X - *A •

2 « / , 5 x , # ( A , B ) '•> J ?,')A 1 » 1 0 A >451 L t t » 1 OX ; # i 'H* t 1 OX , )

P R I N T 1H-.J» 5 ( 1 ) » 5 ( M 5 » ( X ( I ) , Y ( I ) » I = 1 * N ) 1 bO FCRiVA I { I H 0 1 / 1 * i \ ' R U f # * / ( 2 F 1 0 , 2 ) )

(30 f C 5

Page 65: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

59

200 CONTINUE END SLffjfJC'JT IN£ CRCUr (ft»C»X»N,LlMl ) Oll^ENS 1OM A(U1M1»LIM1 >»C(1)»X(1) IH s ^ DO 560 1 = 1 i Ih IF{ A{ I » t ) ) 5 6 0 * 5 0 0 , 5 6 0

500 DO 51 'J K = I»M IF {A <K » 1 ) ) S ? 5 » 5 l O > b 2 S

510 CCM1nU£ PHI NT 518

51H FCR^aT ( 1H1 i#£>f<CK-2£fcO UIAGCNmL El EMFNT IfcPuT TG»» 1# CRCUT#)

C/U.L EXIT 5£5 00 540 J ~ 1s N

5 - A ( I t J ) A ( T » J ) = A ( K i J )

5^0 A(K * J ) = S s - c c I > C ( I ) - C (K) C ( K ) = S

560 CONTINUE DO 120 J=1 .N DC l i b 1=1»N I F ( J ~ 1 ) 1 1 5 » 1 1 5 » 4 5

45 S = 0 I F { t - J ) 0 0 » 7 5 » ? 5

60 L U ' s I - l DI v = A {I »1) GO TO bS

' 5 LIM=J-1 0 1 V - 1 •

65 IF ( l . I h - 1 ) 95»86»06 bb DC 90 K=ltLIM 90 S = S*A ( I , K) -"-A (K »J) 95 A {I » j ) ~ (A (I , J ) ~5) /1>I V

U 5 CONTINUE i<io c o n t i

00 200 1 = 1 «N S = 0 IF { I - I ) l a s » 1 8 5 1165

165 L l M = I " l • DC 180 K = 1»LIM

IbO S=S+A<I»K)*C(K) \t>b C ( ) ; ) » ( C ( J ) ~ S ) / ^ ( I > 1 ) 200 c o n t i n u e

X (M) -C (N) IF ( \ - i ) ^ ^ 5 j Z ' 8 b » ^ 3 S

235 J~N- ,1 Z<*0 S"-0

L T M = J +• 1

Page 66: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

60

UC 26'"- I=L1N»N S = S + M J » ) ) # X ( I I X ( J ) = C ( J ) - S J J ~ 1 I F ( J ) c'tib »<?fs5 s £V)

? b 5 RETURN e n d

Page 67: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

APPENDIX B

PROGRAM TO COMPUTE A LEAST SQUARES POLYNOMIAL

Method of Computation

The program KLOPLS can compute an n+h degree l eas t squares p o l y -

nomial f rom data po in t s ( x j , y j ) by t h e method der i ved in Chapter I I .

F u r t h e r , a weight may be assigned t o each data p o i n t and r e s t r a i n t s

may be placed on t h e leas t squares curve as descr ibed in equal ion (2-14)

of Chapter I I . I f r e s t r a i n t s are g iven , t h e ou tpu t of t h e program con-

s i s t s of t h e c o e f f i c i e n t s of po lynomia ls W and V in equat ion ( 2 - 1 5 ) .

I f no r e s t r a i n t s are s p e c i f i e d , t h e c o e f f i c i e n t s of t h e s tandard leas t

squares polynomial a re l i s t e d . In a d d i t i o n , t h e res idua l a t x ' f o r a

p o i n t ( x ' , y ' ) may be computed and o u t p u t .

KLOPLS is w r i t t e n in t h e Fo r t ran computer language f o r a CDC 6600.

I t s length f o r c o m p i l a t i o n arid execu t ion is 60,000 o c t a l l o c a t i o n s .

P repara t ion of Input Data

Contro l Card 1

I TOT Columns 1-5 Format 15 To ta l number of r e s t r a i n t s t o be p laced on t h e l eas t squares p o l y -nomia l . 0 <_ ITOT <_ m, where m is t h e degree o f t h e des i red leas t squares po lynomia l . F u r t h e r , t h e sum of t h e KK values on t h e res -t r a i n t cards should be equal t o ITOT.

Res t ra j nt Card(s) •

Th is t ype of card is coded i f ITOT > 0 . I t s p e c i f i e s t h e r e s t r a i n t s o f equa t ion ( 2 - 1 4 ) .

61

Page 68: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

62

KK . Columns 1-5 To ta l number of r e s t r a i n t s a t a p a r t i c u l a r XX.

Columns 6-15

Format I 5

Format F10.0 XX The X coo rd ina te va lue a t which the KK r e s t r a i n t s app ly .

(YY(L) ,L=1, KK) Columns 1 6 - 2 5 , 2 6 - 3 5 , . . . , 6 6 - 7 5 Format 6F10.0 YY(1) - t he va lue of t he curve a t XX.

YY(2) - t h e va lue of t h e f i r s t d e r i v a t i v e of t h e curve a t XX.

YY(KK)- t h e va lue of t h e (KK-1)S^ d e r i v a t i v e of t h e curve a t XX.

Con t ro l Card 2

Columns 1-5 LSD The degree of t h e leas t squares po l ynomia l .

IWS Columns 6-10

Format 15

Format 15 Swi tch i n d i c a t i n g whether t h e data p o i n t s w i l l have v a r y i n g we igh ts . IWS = 1 means a l l data p o i n t s w i l l have equal we igh t . IWS 4 1 means t h e t h e weight f o r each data p o i n t w i l l be read from each data p o i n t ca rd .

IRES Columns 11-15 Format 15 Switch i n d i c a t i n g whether r e s i d u a l s are t o be c a l c u l a t e d . IRES = 1 means no r e s i d u a l s w i l l be c a l c u l a t e d . IRES = 2 means data cards c o n t a i n i n g ( x ? , y ! ) w i l l be read and t h e r e s i d u a l w i l l be c a l c u l a t e d f o r ( x ' , y ' ) .

Data Poi n t Cards

One data p o i n t card is coded f o r each inpu t p o i n t .

X Columns 4-13 The absc issa f o r t h e inpu t data p o i n t .

X Columns 14-23 The o r d i n a t e f o r t h e input data p o i n t .

W Columns 24-33 The weight assigned t o (X ,Y) . W is coded on ly i f IWS i- 1 on Cont ro l Card 2,

Data Po in t T r a i l e r Card

Format F10.0

Format F10.0

Format F10.0

Fo l l ow ing t h e l a s t data p o i n t ca rd , a t r a i l e r card is coded which con ta i ns 999 in columns 1 th rough 3.

Residual Cards

These cards are coded i f IRES = 2. on Cont ro l Card 2 .

Page 69: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

63

X' Columns 4-13 Format F10.0 The abscissa f o r t h e p o i n t where t h e res idua l is t o be c a l c u l a t e d

Y1 Columns 14-23 Format F10.0 T h e ' o r d i n a t e f o r t h e p o i n t where t he res idua l is t o be c a l c u l a t e d

Residual T r a i l e r Card

F o l l o w i n g t h e l a s t res idua l card , a t r a i l e r card is coded which con ta i ns 999 i n columns 1 th rough 3 .

End of Job Card

F o l l o w i n g t h e l a s t se t of data f o r a j o b , a card is coded which con ta i ns -99 in columns 1 th rough 3.

AM parameters should be coded r i g h t j u s t i f i e d in t h e columns

s p e c i f i e d . The parameters XX, YY(L), X, Y, W, X ' , and Y' may inc lude

a decimal p o i n t is necessary f o r t h e i r r e p r e s e n t a t i o n .

The program can compute any number of l eas t square curves in a

computer j o b . The End of Job Card is coded a f t e r t h e l a s t data t o

t e r m i n a t e t h e computer run.

Page 70: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

64

LI ST IMG OF FOK fh'A> J P K O G H A M -

PHG';^A1-i K L C P L S ( I N P U T , O U T P U T )

D I M E N S I O N A ( 2 0 * 2 0 ) » C < 2 0 ) , B < 2 0 ) , X ( ? 0 ) , Y ( 2 0 ) > K ( 2 0 ) t

1 XL (1OUO j , YL (1UOO) t tili (<-J0) j VjL ( i 0 0 0 )

1 ISU-v = 0

P K ) N T 2

2 F C H ^ A T ( iHl s AST S M U a H E S POLYNOMIAL, C U P V F F I T T I N G * )

IX- 1

PfcAl) 5 » I T 0 r

5 F O R M A T ( [5,7F 1 0 . 0 )

if ( i r o n s c o , u o » i 2

12 IF{I 1 0 T - I ) 15, 11,lb

U K d A O 5 ) K K » X ( i ; » Y ( 1 )

K (I X ) - 1

B < 1 ) " Y ( U

i o e 6 = o

GO io n o

15 1 = 1

I 0 E G S I T 0 T - 1

c 5 H t A O 5 » K K f X ( I X ) . (Y (t) » L - 1 » K K )

K ( I X ) - K K

L ~ 1

A (I » I T C T ) s i ,

DC Vi K - 1 , I D L G

J D E G - M + 1

'*5 a (I »m,4)=A(I , M h + l >*X ( IX) bO C ( I ) ~ Y ( L )

L~| +1 1 = 1 + 1 IF ( L ~ K K ) 7 0 » 7 0 j 1 0 0

70 FlOEG-lO'cG

0 0 fib M = 2 »ITCT

A ( J ,H-I ) ---h (I - L j I) - F l O t G

fib FlOfc]G-FlLU-:G"l . A ( I , I T C T ) s O ,

GO TC bO 1 0 0 I S U ^ - I S U M + K K

I F ( I S U M - I T C T ) 1 U H » 1 0 5 « 1 0 5

1 02 iXr. X x + 1

GO TO 2 5 '

105 C A t L C K C U T ( A , C , H , H O T , 2 0 )

110 PKJK'T 115» I D L b , (I # b (1) » 1~1, I TOT )

115 FCpf-'AT (1 H'i) i'PCL t'NOH j .-\L C O E F F I C I E N T S F O R W { X ) w H F R F # »

I D F G H t E OF w IS*' 13/ ( 1 6 » K \ 2 , 3) ) PKJ NT 1 2 5 , (1 ,x {J) ,K (I) » I=s I, IX)

1 2 5 FC W A T (I tiO »5X j i-<LSTK41MTS*»3X > N U M B E R # / {1 ? F 10 .3 j 18) )

}3<J pt:A0 1 35 i L S D » J wS •» 1 H t S

135 F 0 R ; V A ' M 3 I S )

DO 171 t ~1»I 0 0 0

Page 71: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

65

1^5 i-iP-AO ISO* I EM) ,XL ( I > » YL <1) >V-»L (1 > 150 F'Cfit/Ar ( U , 3 H 0 . U )

IF ( IEND-999) 160 •) 1 «0* 160 160 I F { I To r ) 5 0 0 9 1 7 1 , 1 6 1 161 CO 170 KK~) ,1X

I F ( X L ( I ) ~ X (KK>)1 JO 9145»170 170 CONTINUE 171 c o n t i n u e

L L - 1 0 0 0 GO TO hi2

180 L L " I •* 1 1^2 I F ( I W S - 1 ) 1 9 5 »1 OS »195 165 00 190 1 = 1 H I . 190 wt. { I ) - 1 » 195 IF ( T TOT)500 * 2 5 5 * 2 0 0 200 00 25u L=1»LL

V A t . B (1 ) IF t I T 0 T ~ 2 > 2 2 1 ? 2 ) 5 , 2 l 5

215 DO 220 i -^2>JT0T 220 V :AL~VAL*XL (L) +'<S (M) Z21 P l s l .

00 2 ^ 0 K ~ l » I X KK-K (>')

240 P i = pl<> (XL <L) - A (>••> > YL ( U = < Y L ( U - V A L . ) / P I

250 UL (L) «wL (L ) i ; 'PI<: -PI PP INT 252

252 FORMAT (1H0 5 22X^TRANSFORMED DATA POINTS# /3QX , <>X^ ? 1 OX » l»Ytf , 1UX »#¥<#)

255 USUfi = L S i ; - n O T PH1NT 2 5 6 , ( X L ( I I ) ?YL. ( H ) »Wl , (U> » U ~ 1 » L L )

256 FOw.vAT (20x , 3 F U . 3 ) CALL. POuYLS (LSOP >> XL J YL 1 V<L j LL »A 120 > C , OB) N0--LSDR+1 PRINT 2 /0»LSDR 00 275 1=1»NO f l r .LSOR-1 + 1 P R T M 272» I I » t i H U )

272 FORMAT(* A ( # » I 2 . « ) # » E 1 6 . B ) 2 / 5 CONTINUE 2 (0 FORMAT(1H0»*C0FFF. FOR LS POLYNOMIAL,DEGREE#,13)

GO fO ( 1 » 3 0 0 ) » I H E S 300 p i n NT 305 305 FOmwat ( 1H1 ,#«ESlOUAt. D IFF EtfENCf.S* / 1 OX ? *X« • 10X> »

18A-»«PES<*) 310 REAO J 50» IEMO? XX t YY

I F ( IENO«999)3?.0»1»320 320 VAL=B(1>

IF ( TTOT-1) 322 ' 3 ' i5 > 335 322 VAL"0»

P I s: 1 ,

Page 72: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

66

GO "JO 3 o 5 3 3 5 DO 3 V J 11=2»I TOT 3'+0 V A V A L * X X + B (M) 3 ^ 5 P I ~ 1

0 0 3 6 0 M=1»JX KN=K(M)

3 6 0 P I - p 1 ^ ( X X - X ( M ) ) # * K K 3 5 5 V A L 2 - 0 8 ( 1 )

LL~LSUR+ I DO 3 8 0 Ms2» l . L

3 b 0 V a L c = V A L 2 » X X + l3B(f1) fiES"YY~ (VAL + P l ^ V A L i J ) PPTNT 3 9 b » X X » Y Y * K t f S

3 9 5 F O j ^ A T f 3fc 11 • 3 ) GO TO 3 1 0

5 0 0 CONTINUE F N f ) SUpROUT .(ME POLYLS (LSOR»XL» Y|.» vjU , L L » / \ 1 L I H I f C » B )

C « « « FORK NOrtMAL E u U ^ r i C M S AS MATRIX PRODUCT A#B = C C*-»* CP OUT TO SOLVE FOR C O E F F I C I E N T S B ? Wh'EPE THE LS C POLYNOMIAL I S riU)*A*<M + b ( 2 ) # A « < M M - l > * . . » + [ 3 ( M H ) .

i j l ! . : F ^ S l O r l XL (1J »YL ( 1 ) »WL ( 1 J »« ( L I M 1 » X M 1 ) , n U ) >C Q > NOrrLSuR+I DO 15 K « l » N O

15 A ( K 1 1 > ~ 0 * C» t f * FOpv F I !<ST CCLUf-N OF A

0 0 5 0 1=1 »LL V A L ~ ',v L ( t ) # X L ( I ) # » L 5 0 P t )045 K ™ 1 9NO J = f ; C " K + l A < J , 1) =A U » 1 ) • V A L

45 V A L s V A L « X L ( I ) 50 c o n t i n u e

FORV UPPEP TPlArvGULMP M/ iTUIX DO 7 5 t . - l U . S D H L I M " N O ~ L +1 DO 7 0 J » 2 « L I M

70 A ( j - 1 i l . + l } =A ( J » I J V5 CONTINUE

C # # * FORV LAST c o l u m n a n d c o n s t a n t c c l u h m 00 q o J = 1 , M 0 C < j ) = 0 .

9 0 A t ^ j N O J ' - O . 0 0 ]HQ I «1? LL V A I, = W l_ ( I ) V A L 2 - w L ( I ) "• YL ( £ ) 00 1 3 5 K = 1 » N 0 J = N C ~ K + I A ( J ,i\ 'G) - A < J»NC) + VAL

Page 73: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

67

J 25 C ( J ) --C ( J ) +VmL2 V A L = V A L # X L ( I )

135 VA|.2 = VAL2»XL u ) 1'VO CO\iT I r-Uli"

LC\\ER TRiAMoULAR H A l K l X no 170J : 'K*LSDH VAL~A(J>NO) '^"LSOR™ ,J +1 DO 16 b K s 1 , M

165 A ( J + K?NC--K) =VAL 170 CONTINUE

PRINT 175 1 f b FORMAT t 1 r i-0 3 ttCGLif- F1C LENT MATRIX OF i\'ORfiA!. EQUATIONS'®*)

DO <>00 i^= l iNC P R I M ^Ob i (A {K1 J) i J~ 1 s NO) » C (K)

c 05 FGRt-'»iT ( 1 H * BE i 6 . d) 200 00NT I <nlit:

CALL CKOur ( A , C » ' H » w C t L I H l ) RETURN EM) SUnRQUTlNE CROUf (A i C j X t N I t, IM1 ) DIMENSION A ( L l M l , L l M i ) , C U ) * X ( 1 ) }H.zt\/2

DO 5 6 0 I ] t X h i l~ ( A ( I » I } ) (5fo0 »5uO f 5 6 0

5 00 1}0 S1 u K " I 9 N I F { A ( * U ) )525»5 iO»13 i ;5

5H) CCNTir-tHE PRl f \ ;T '518

S i b FORf/AT (1H 1 ? vEHRO^"2E»<0 DIAGONAL ELEHENT JfiPUT T0#» i # CUCUT*)

CAI.L EXIT 5 ^ 5 00 5 ^ 0 J = 1 , N

S ~ A (1 »J) A (T , J ) ~t\ {K »J)

5-40 A ( K » J ) = S S-C < I ) C ( I ) = C ( K ) C (K) =;S

5 6 0 CONTINUE 00 1^0 J - 1 s N DO l \ h I s 1*N I F ( J ~ l ) U 5 > U 5 i 4 5

45 5 = 0 I F { I - J ) 6 0 , 7 5 i 7 5

60 L l M = I - l 0 I V ~ A { I ) I ) 60 TO 65

75 L l M s J - 1 0 I V « 1 .

0 5 J f" (L I r i •" 1 } 9 5 i H 6 » H 6

Page 74: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

68

66 00 <50 K - 1 » L J M 90 S=S + A( L »K) (K».J) 95 A ( 1 , J ) - ( A ( I , J ) - S ) / D i V

11S CON f I - U t I'dO CCNTIiJUb'

00 2 0 0 I - 1 » N s=o I F ( 1 - 1 ) 1 »185 > 16S

165 L -l M™ J. ~ 1 DO 180 K " 1 , L I M

180 S = S + A ( I i K ) '::"C (ft ) l b 5 C ( I ) " ( C ( I ) - S ) / A f I , I ) 200 C«MTlwUE

X ( ^ ) " C ( W ) IF ( f \ - 1 ) 2 & 5 i 2 8 b i 2 3 ^

235 J = N - 1 240 S~0

L I M ~ J + 1 DC 2 6 0 I=L1M»N

260 S™S + A ( J « I ) X ( I ) X ( J ) - C ( J ) - S J - - J - 1 JF < J ) 2 « 5 » 2 h t j f 2 ^ 0

205 ntTUK-' l ENO

Page 75: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

APPEND IX C

PROGRAM TO COMPUTE BICUBIC SPLINE FUNCTIONS

The method descr ibed in Chapter M l f o r f i t t i n g a b i c u b i c s p l i n e

f u n c t i o n t o data is programmed in t h e F o r t r a n program SPLINES. The

inpu t c o n s i s t s of t h e data f rom g r i d p o i n t s t h a t are shown in F igu re 1

of Chapter I I I . The se ts of l i n e a r equat ions (3-19) th rough (3-22) in

Theorem 3 .6 are so lved t o y i e l d t he requ i red u . j , v j j > and w j j . Next,

t h e c o e f f i c i e n t s of t h e b i c u b i c polynomial f o r each rec tang le Rj . a re

determined by equat ion (3 -17 ) . These c o e f f i c i e n t s may be l i s t e d as

o u t p u t . F u r t h e r , t h e s p l i n e f u n c t i o n may be eva luated a t any ( x ' , y ' ) in

t h e reg ion R. The ( x ' , y ' ) is read by t h e program which then determines

t h e R. . such t h a t ( x ' y 1 ) e R . . . The b icub ic poIynomiaI f o r R s t is i j U 'J

eva lua ted a t ( x ' , y ' ) and t h e r e s u l t i n g p o i n t ( x ' , y ! , z ' ) is p r i n t e d .

P repara t i on of Input Data

Input t o t he program is from cards . B a s i c a l l y t h e r e are f o u r

t ypes : c o n t r o l ca rd ; data p o i n t ca rds ; e v a l u a t i o n p o i n t ca rds ; and

t r a i l e r c a r d .

Cont ro l Card

N_ . Columns 1-5 Format 15 The number of columns in t he input da ta .

M. . Columns 6-10 Format 15 The number of rows in t he input da ta .

KSW Columns 13-14 Format 12 Switch i n d i c a t i n g types of ou tpu t des i red . KSW = 10 means ou tpu t on ly t h e c o e f f i c i e n t s of t h e b i c u b i c p o l y -

nomia1s.

69

Page 76: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

70

KSW = 01 means t o eva lua te t h e sur face a t ( x ' , y T ) data p o i n t s and p r i n t ( x ' , y ' , z T ) .

KSW = 11 means t o p r i n t both the above t ypes .

LAST Columns 16-20 Format 15 Switch i n d i c a t i n g l a s t problem. LAST >_ 0 i nd i ca tes t h a t inpu t f o r another spl ine f u n c t i o n f o l l o w s

t h e c u r r e n t s e t . LAST < 0 i n d i c a t e s t he l a s t se t of data f o r t he computer j o b .

I MESS(I) ,1=1,6 Columns 21-80 Format 6A10 Alphanumeric i n f o rma t i on which is p r i n t e d on t he ou tpu t l i s t t o i d e n t i f y the problem.

Data Po in t Cards

(XCI) ,1=1,N) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The X coo rd ina tes of t h e input g r i d p o i n t s . These must be coded in ascending numerical o r d e r . I f N > 8, t he X va lues are coded on success ive ca rds .

(Y(J ) ,J=1,M) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The Y coord ina tes of t h e input g r i d p o i n t s . These a l so must be coded in ascending o rder and on successive cards i f M > 8 .

( ( Z ( J , I ) , l = 1 , N ) , J = 1 , M ) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The Z va lues a t each g r i d p o i n t ( X j , y . ) .

(U(J ,1 ) ,J=1 ,M) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The p a r t i a l d e r i v a t i v e w i t h respect t o X f o r each g r i d p o i n t of column 1. I f M > 8, these parameters are cont inued on consecu t i ve ca rds .

(U(J ,N) ,J=1,M) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The p a r t i a l d e r i v a t i v e w i t h respect t o X f o r each g r i d p o i n t of column N. I f M > 8, these parameters are con t inued on successive ca rds .

( V ( 1 , I ) , 1 = 1 , N ) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The p a r t i a l d e r i v a t i v e w i t h respect t o Y f o r each g r i d p o i n t of row 1. These are coded on successive cards i f N > 8.

(V (M, I ) ,1=1 ,N) Columns 1 - 1 0 , 1 1 - 2 0 , . . . , 7 1 - 8 0 Format 8F10.0 The p a r t i a l , d e r i v a t i v e w i t h respect t o Y f o r each g r i d p o i n t of row M. I f N > 8, t h e V (M, I ) are con t inued on successive cards .

W ( J , I ) , I = 1 , N ; J = 1 , M Columns 1 -10 ,11-20 ,21-30 .31-40 Format 8F10.0 The p a r t i a l d e r i v a t i v e w i t h respect t o X and Y f o r each corner g r i d ' p o i n t : W(1,1) , W(1,N), W(M,1), W(M,N).

Page 77: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

71

Eva lua t ion Po in t Cards

These cards are coded i f KSW f 10.

X' Columns 4-13 Format F10.0 The X coo rd i na te of a p o i n t f o r which t h e s p l i n e su r face is t o be eva lua ted .

Y' Columns 14-23 Format F10.0 The Y coo rd i na te of a p o i n t f o r which t h e s p l i n e sur face is t o be eva lua ted .

Tra i l e r Card

Th is card is coded i f KSW i- 10. I f f o l l o w s the l a s t e v a l u a t i o n p o i n t card and has a 999 coded in columns 1 -3 .

Each parameter is coded r i g h t j u s t i f i e d in the f i e l d s i n d i c a t e d .

The data p o i n t cards and e v a l u a t i o n p o i n t cards may inc lude decimal

numbers. The Z va lues on t he data p o i n t cards are coded by rows w i t h

e i g h t va lues per c a r d . A l I of t h e va lues on row one are coded consec-

u t i v e I y, f o l lowed by those f o r row two w i t h th6 i n i t i a l va lue of row two

coded in t h e next f i e l d a f t e r t h e n^^ va lue of row one. Th is procedure

con t inues th rough a i l m rows.

Page 78: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

72

L I b r I M'.3 OF Fcr<TK«!M PROGRAM

PKCGHaM SPLlNtSfl -:PUT J OUTPUT) CCMyC-i Z(50,50)» 0(50*50)» V(50?50)» W(50,50) CGMPCU X(50}, Y(50)

COMMON !J i (50) ? U2(50)» C (50) » ANS(50)> A(4»4), 8(4)4) 01 Mf US I ON K S W (3) » I fif-I S S (o)

5 PEAO 10, N,M, (KSW(K) ,K = 1»3) »LAST, ( 1 M E S S U ) » I=l»6> 10 FORMAT (2I5,2X*3I1« I5»6A1U) 20 FGpvAT (iFlO.0)

PfcAO 20,. (X (1) 9 1 = 1 »N) PF-AD 20, (Y (J) , jssl fM) HEaO 20, ( (2 (J, I) , f~l,N) Rf.AO 20, (U (J) 1 ) , J=1 ,M) PEAO 20, (U (0 ? i•)) j «J™ 1 * H) RtAO 20, (V(l»l),1-1,M) RtAO 20, <V(M»I)»I~1»N> H L" A 0 2 0 , W ilil)* w ( 1 , N) , W (' < i 1 ) , w (M , N) PRINT 50, (IMtSS(l)»1=1,6)

50 FCp^AT U h l ,6A10) CALL SPGRID(N,H) P R I M 200, ( (u<J»I) » 1 = 1 » 1 0) »J=.l j iO) PRINT 200, ((V(J,I) , 1 = 1,10) »Jr: 1 »1 0) PPINT 200* ((W(J »I)» J ~ 1 i 10)> J"1•10)

200 f- 0 R U A 1 ( IH1 1 (10 F 13•> ) ) CALL SPOUT(KSW IF (LAST) 100,5>5

] o o continue end subroutine SPO^Jo{N»M) CCmn'GN <?(b0,50), U (50 > 50) t V(50»50), V.<(50,50) CCm^GM x (50),Y(50)

C^MN'GN U1 (5{;) t U2(5U) 9 C(b0)> AftS(50)« A (4,4), 0(454) C « S C L V t * StTS OF LINEAR EOUATIO^S IN (3"l9)

KM 1 -- N-l NM? ~ N-2 MSw = 1 DG 25 1«2>N

25 U1 (I-l) = X (I)» X(1-1)

DO 35 I~2,N

35 U2(I~1) =. 2 . M U 1 I J.) +Ui (I-l) ) OG 80 J=1,M DG 50 I~2)NM1

SO C(I-I) a 3.#(Ul(l"l)^{2(j tI + l ) - Z ( j , I ) ) / u l - t U

i + Ul <I)MZ(Jj I)~Z(J»i-l) )/ljl (I«»l) ) c(1) = C(1)-ul(2)*U(J,1) C(K'V2) " C(N'M2) - U1 (NMl) *U (vj, N) C^LL 1.1NS0L (U1 »'J2 * C • AUS , i\'I '2 j MSiv ) DG 75 I~Z» MMl

75 U(J,I) s AMs(I~i)

Page 79: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

73

HO C C N T l f j U E

S O L V E S i iTS C F L I N E A R E Q U A T I O N S I N < 3 - ? l ) Kf-'l ~ M~ 1

- f/j—2 MSw = 1 0 G \ 2 5 v J — 2 s M

1 2 5 U K J - l l - Y ( J ) ~ Y ( J - 1 ) UC 1 3 5 J = 2 , M

} 3 5 U 2 ( J - l ) •- 2 , # ( U l ( J ) t U J ( J - U }

DO I d 0 ,1 1 »N 0 0 I S O

T j O C ( J - 1 ) = 3 . * ( U 1 ( J - l ' ) » ( 2 ( J + l , { ) » Z ( J , I ) ) / i j l { J ) I + U l ( J ) » ( Z { J , I ) » / ( j « l , | ) ) / u l ( j - i ) )

C ( ] ) C ( 1 ) - U l ( 2 ) » V < 1 j I >

C ( M f * ' 2 ) ~ C ( m M 2 } - U l (MM1 ) « V (M* I )

C L L L I w S 01. ( U 1 ? i J 2 •> C j A N S »i-'i f-i 2 j M S •'>) UC 1 7 : 3 J = 2 i M M 1

1 7 5 V ( J « 1 ) « A N s ( J " l ) 1 H 0 C O M I r-JUf£

c * * * s c ; i \ / e s e t s o f l i h e . a r e q u a t i o n s i n ( 3 - 2 0 ) k s w = 1 0 0 2 2 5 I ~ 2 » h

2 2 5 U l ( 1 - 1 ) ~ x ( I ) - / ( I ~ l )

DO 2 3 5 I ~ 2 » N

2 3 b t j 2 ( I - 1 ) = 2 , * t U ! ( U + U 1 ( 1 - 1 ) )

0 0 2 & 0 J - , I » M j H M l

0 0 2 h i ) I = 2 , N M 1 2 b O C < X - 1 > = 3 . *• (tJ 1 { [ ™ 1 ) & ( V ( J 1 I + 1 } ~ v ( J 1 I ) ) / t 1 1 ( 1 )

1 + U l < 1 ) « ( V ( J , J ) « v ( J * 1 - 1 ) ) / u l { I ~ 1 ) )

c ( i ) = c d ) » u i { 2 ) - « ' w ( j , n C ( N ^ 2 ) = C ( M M 2 ) '• U l ( N M l ) { J , M )

C A L L L I *nS01- ( U 1 1 U 2 1 C 1 A N 5 »sN! 12 > MSW)

DO 2 7 5 l a 3 , N M l

2 7 5 W ( J , 1 ) = A N i S ( I - l )

2BO C O N T I N U E C # # # S O L V E - S E T S C F L I N E A R E Q U A T I O N S I M ( 3 - 2 2 )

KSW = 1 0 0 3 2 5 J = 2 , M

3 2 5 U l ( J - l ) n Y ( J ) - f ( J * • 1 )

DC 3 3 5 3 3 5 i j 2 ( j ~ l ) = 2 , » ( u l ( J ) 4-IJl ( J ~ 1 ) )

0 0 3 8 0 I - 1 9 N DC 3 5 0

3 5 0 C ( J - 1 ) - 3 . # ( U l { J « l ) f t ( | j ( j t l , I ) . U { j , I ) ) / l i l ' { J )

I • U l < J ) # < U < J » I > - u U ~ l » I > ) / l j l ( J - l ) )

C ( 1 ) = C < 1 > -• U.i ( 2 ) # w ( l , I )

C {Mr.'2 ) -- c (f IMS ) - U 1 (MM 1 ) " M» I J C A | J , 1.1 ''iSOl. ( U I » U 2 * C ) ANS J •'•Hi2 « > ISW) 0 0 3 7 5 J = 2 » M M 1

3 7 5 "i ( J , 1 ) s Ai'.'S ( J " 1 ) 3 8 0 C O N T I N U E

Page 80: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

74

i a o

ANS ( b 0 ) » > > (A ? A ) i B (!\ i 4 )

20

35

50

60 6 IS

RETURN END SUp R 0UT1 N S P C G £ F < I * J > CCmiyGiJ ^ ( 5 0 » b 0 ) » I j ( ! r > 0 f 5 0 ) » V ( 5 0 , S 0 ) f W ( U U , 5 0 ) CCM"C.-; A (SO) , Y ( 5 0 ) CGN.WO.-J U l { 5 0 ) » U 2 ( 5 G ) » - C ( 5 0 ) » U I M E I j S I O N Y I C M M DAT/H i r i j / 1 / DX ~ A ( l + l ) ~ X d ) DY S Y ( J + l ) - Y ( J ) 6 0 TC ( 2 0 » b 5 ) » I N I IN 1=2 DC 6 0 K = l f 2 0 0 6 0 L = l » 4 I K ( K - L ) 3 5 » 5 0 » 3 5 X I CK * L > - 0 Y 1 (L » K ) - 0 GO TO 60 X1 (:< i K ) - 1 , Y1 (K i K ) = 1 . cc r . 'TP- 'ne x i (4 , ?:) X I (3 » i ) X l ( 3 » 3 ) X 1 ( 3 « ^ l X I < 3 j 2 ) K 1 ( 4 » i ) X 1 Cm 3) X I (A »'t) Y 1 ( 4 * 4 ) Y1 ( 2 , / 0 Y 1 ( 1 , 3 ) Y I < 3 * 3 ) Y 1 ( * }»3) Y l ( ? » 3 ) Y1 ( 1 * 4 ) Y l (3« 4) 0 0 1 8 0 < = 0 0 1 B O L "

~ 1 * / (0 X "'** 0 X)

= - 3» # x 1 ( :m ?.) ~ - X I ( 3 , 1 ) - " 1 « / 0 X = ? , # X U 3 » / 0 = 2 , / U a * » 3 = - X l C u l ) = x i r * , 2 ) - l . / ( O Y « O Y ) --•Yl ( A , 4 J = - 3 , » Y 1 ( ^ s ^ ) - - Y 1 ( I » 3) = - 1 , / O Y = 2 » ^ Y I ( 4 > 3 ) = 2 . / 0 f * » 3 - - Y l < 1 »'+)

1 » 3 1 2 1 > 3 f 2

M = I + K / 2 N s J + L / 2 A (K • L ) " Z (N»M) A < K j L + 1 ) = V (N > m ) A ( K + 1 > U ) a U ( N , M ) A (K * 1»1- + 1) W (i •! 1 r-1 ) CALL f i A r i - U . I L ( X l » A » H » 4 ) CALL I-IATMUL (B j Y1 , A f 4 ) RETUh'fi ENO SU»HCUT INE MATMt »L <A. <3 , C i N) D IMENSION A ( N * > ) ) » Li (r j» N) , C (N»N)

Page 81: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

75

DO 25 ~ 1 »N DO 25 L=1»N SUm=0, 00 20 f-1" X 9,N!

ZO SUM •" S'.Ji i A (K ? M) ":*tM M »L) 25 C ( K f L ) - SUM

PFTUNN FNf) s u f j n c u i ih[-: n u s n i . ( u i »ua»D»x,NC»Msw) DIMENSION U1 ( i ) »UJJ(J ) » C ( 1 ) » X ( 1 ) , 0 ( 1 ) GO TO (10 j25) i l - iSW

10 DO } 5 1=2,NO 15 U 2 ( l ) = U 2 ( I ) - U H l - ) ) ^ U l ( I + l ) / U < ? ( I - l )

MSW = 2 25 DO 35 I::2»NC 35 D ( T) =•• i J ( I ) ~ U1 ( 1 + 1 ) * l ) ( i ~ 1 ) / U 2 ( 1 - 1 )

X (N0} - 0 ( i iO ) /U2 CMC) t;OK\ M0~ 1 DO hO l = l»NiOMl J - NO •• I

6 0 x ( J > - < L > ( J ) - U 1 ( J ) # a I J + 1 ) ) / U 2 ( j )

END SUG^OUT;NI-: SPOUT (KSW,h»M» I MESS)

NSlON KSW (3) , I r^tSS f b) C0M.''0f-J ^ ( 5 0 , 5 0 ) j 0 ( 5 0 * 5 0 ) » V 150 5 50 ) , w ( 5 0 , 5 0 ) CCMVC^I x { 0 > , Y ( 50) COMMON HI (50) » 1J2(50)» C (50) » ANS(SO), A ( 4 » * ) > B ( 4 » 4 ) DO 1000 MM™1{3 . IF (KSw(^f i ) ) J 0 0 0 , 1000 , 15

15 GO TO ( 1 0 0 , 2 0 0 , 4 0 0 ) » M M 100 tvM 1 ~ M - 1

NKi 1 = W - l DC ] 45 J= I • l-'i'l 1 00 145 1 = 1? I'mjM 1 PRINT 115 , I ? J , ;< ( I ) j Y ( J)

115 FORI* AT (1 HO •# 1 = * . 13 »3X , * J = & »13 »5X » • E 1 2 . 5 1 5X » # Y - # » 1 P ; 1 2 . 5 / 1 5 X , * P C / F k CF Y*» 11X , *0<* , 1IX j 1»» U X ,«?.»» 11X t 2 * 3 * / 2 4 X , »X*)

CALL SPCOKF( I i J ) DO 145 L = l » 4 IX = L - l PRINT HO? I X t ( A ( V , K K ) » K K = 1 , 4 )

1^0 F O R M A T ( t 2 5 , l / » 4 F l 2 « 5 ) 1^5 CONTINUE

GO TO 1000 O t f * EVALDftTF S P L I iM F FUNCTION A I DATA POINTS

200 PRINT P.i) 1 201 FOHVAT ( lHO»^EVAt.U/<riON CF OATA^ / l 2X , * X * 1 ]. 1 X « #Y* ,

1 l l X » » Z « ) 204 RFAO 2 0 5 , I ALL , X A * YY

Page 82: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

76

H'>5 F C f ^ A n i ; j , ? p 1 0 , 0 ) IF ( I/\LL'"*>99 ) 2 1 5 » 1 000 ,215

215 jf- (XX-X () ) )23bi£?.Q*d?.Q ?.£0 I r (XX-X <>!) ) 22b,22b»23b ?.cri IF (YY-Y ( 1) ) 235 i 230»230 230 fF {YY-Y (M) ) 2-V5?2^>235 235 PHI NT ^ 0 * XX? YY 2 * 0 FCRfAT (J. X , 2r 12«5, 4X t ^OUTSIDE RAM^F*) 2'»S 00 25*3 1=*»N

If* ( XX-X ( I ) ) 260?26b?25b 2'o5 CCNTI-mUF 260 1 = 1 - 1 / 2"5 on 2 / b J « 2 *>M '

IF {YY-Y (J) ) ? m } 28b i c l b 275 CCNTlilUr: 2tin j a j . i 2H5 CA|.L SPCOFF(I»J)

l i s 0 . 00 320 K ~ i ? 4 00 320 L = l * ' t KKsK-l L L s L - l L 'L - * A (K ? L) J-M ( A a-A ( I ) ) * »KK) ^ ( (YY"Y(J) ) L)

320 CCMTINUC PH1M 330? XX > YY» LL

330 F G r v a T ( 1 X , 3E12 .5 ) GO TO 204

4 00 CONTINUE 1000 CCNTIWUe

HtTUHW end

Page 83: POLYNOMIAL CURVE AND SURFACE FITTING/67531/metadc130895/... · Curve Fitting by Spiine Functions I I. METHOD OF LEAST SQUARES 24 Polynomials of Least Squares Least Squares Polynomial

BIBLIOGRAPHY

Books

Hi Idebrand, F. B . , I n t r o d u c t i o n t o Numerical A n a l y s i s , New York, McGraw-H i I I Book Company, 1956.

N ie l sen , Kaj L.., Methods o f Numerical A n a l y s i s , New York, The Macrnil lan Company, 1956.

Pe ' r l i s , Sam, Theory o f Ma t r i ces , Reading, Massachusetts, Add ison-Wes I ey P u b l i s h i n g Company, 1958,

A r t i c l e s

B i r k h o f f , G a r r e t t and de Boor, C a r l , "P iecewise Polynomial Sur face F i t t i ng , " Proceedi ngs, Genera I Motors Research Labora to r i es Sym~ posiurn: Approx imat ion of Func t ions , e d i t e d by H. L. Garabedian, E l s e v i e r , Amsterdam, E l s e v i e r P u b l i s h i n g Company, 1965.

De Boor, C a r l , "B i cub i c Sp l i ne I n t e r p o l a t i o n , " Journal of Mathematics and Phys ics , XLI (September, 1962), 212-218.

K l o p f e n s t e i n , K. L . , " C o n d i t i o n a l Least Squares Polynomial Approx i -mat ion , "Mathematics of Computat ion, X V I I I (October, 1964), 659-662.

77