numerical differentiation by the regularization method

8
COMMUNICATIONS IN APPLIED NUMERICAL METHODS, VOl. 2, 625-632 (1986) NUMERICAL DIFFERENTIATION BY THE REGULARIZATION METHOD ALLAN J. MACLEOD Department of Management Studies, Scottish College of Textiles, Galashiels, Scotland SUMMARY A description is given of the regularization method of numerical differentiation. The method is compared with the recent method of McNamee, and is shown to perform well, especially with very noisy data. A FORTRAN program is also given. INTRODUCTION In a recent paper, McNamee’ proposed a new method for the numerical differentiation of tabulated data. The numerical results presented showed the method to be very effective compared to numerous other methods. Not all available methods, however, were considered, especially the regularization method proposed by Cullum2 and developed by Anderssen and Bl~omfield.~ McNamee mentions this method, but suggests that its practical implementation would take a great deal of work. The present paper describes the Anderssen-Bloomfield-Cullum (A-B-C) method, compares its performance with McNamee’s method, and gives a FORTRAN program (Appendix I) for its implementation. ANDERSSEN-BLOOMFIELD-CULLUM METHOD An excellent discussion and description of the application of regularization to numerical dif- ferentiation is contained in the paper by Baart.4 The following is essentially a summary of part of Baart’s paper. Suppose we have a function g, defined on [a,b], and we wish to find f = g‘“), n 3 1. We assume, without loss of generality, that g is zero at both a and b. Let D, be the operator defined by Then, g(”) is the solution of the operator equation Dnf = g. This is an integral equation of the first kind, which is ill-posed, and hence numerically unstable. Regularization, as introduced by Tihonov,’ considers the well-posed problem where Hm[a,b] is a Sobolev space with for some positive integral value of m. Cullum showed that (2) could be solved numerically using linear equations, and hence O(n3) Address for correspondence: Department of Mathematics & Statistics, Paisley College of Technology, High St., Scotland. Paisley, 0748-8025/86/060625-08$05.00 0 1986 by John Wiley & Sons, Ltd. Received April I986

Upload: allan-j-macleod

Post on 11-Jun-2016

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Numerical differentiation by the regularization method

COMMUNICATIONS IN APPLIED NUMERICAL METHODS, VOl. 2, 625-632 (1986)

NUMERICAL DIFFERENTIATION BY THE REGULARIZATION METHOD

ALLAN J . MACLEOD

Department of Management Studies, Scottish College of Textiles, Galashiels, Scotland

SUMMARY A description is given of the regularization method of numerical differentiation. The method is compared with the recent method of McNamee, and is shown to perform well, especially with very noisy data. A FORTRAN program is also given.

INTRODUCTION

In a recent paper, McNamee’ proposed a new method for the numerical differentiation of tabulated data. The numerical results presented showed the method to be very effective compared to numerous other methods. Not all available methods, however, were considered, especially the regularization method proposed by Cullum2 and developed by Anderssen and B l~omf ie ld .~ McNamee mentions this method, but suggests that its practical implementation would take a great deal of work.

The present paper describes the Anderssen-Bloomfield-Cullum (A-B-C) method, compares its performance with McNamee’s method, and gives a FORTRAN program (Appendix I) for its implementation.

ANDERSSEN-BLOOMFIELD-CULLUM METHOD

An excellent discussion and description of the application of regularization to numerical dif- ferentiation is contained in the paper by Baart.4 The following is essentially a summary of part of Baart’s paper.

Suppose we have a function g, defined on [a,b], and we wish to find f = g‘“), n 3 1. We assume, without loss of generality, that g is zero at both a and b.

Let D, be the operator defined by

Then, g(”) is the solution of the operator equation Dnf = g. This is an integral equation of the first kind, which is ill-posed, and hence numerically unstable.

Regularization, as introduced by Tihonov,’ considers the well-posed problem

where Hm[a,b] is a Sobolev space with

for some positive integral value of m. Cullum showed that (2) could be solved numerically using linear equations, and hence O(n3)

Address for correspondence: Department of Mathematics & Statistics, Paisley College of Technology, High St., Scotland.

Paisley,

0748-8025/86/060625-08$05.00 0 1986 by John Wiley & Sons, Ltd.

Received April I986

Page 2: Numerical differentiation by the regularization method

626 A. J . MACLEOD

operations. Anderssen and Bloomfield developed an alternative method of solution which is much more efficient.

Since g(u) = g(b) = 0, g can be expanded as a Fourier sine series,

with +j = rrj/(b-u). It was shown that the solution of (2) was then

where rn

w,? = 1 + aR” +P. k=O

Usually, we only have N pairs (xL, gi ) , i = 1, . . . , N , with x I = a , x N = b , andgj = g ( x i ) . In

The value of (Y is chosen to minimize the following function L , based on a maximum likelihood such a case, we can construct a finite sine series corresponding to (4).

estimate:

where Ti denotes the finite Fourier coefficients, and i, the value of w, with 4j = 7 r j / ( N - l ) .

PRACTICAL IMPLEMENTATION

Given observed data values, ( x l , fi), i = 1, . . . , N , the basic format of the computation is: (a) transform so that the function is zero at x1 and x N ; (b) calculate the Fourier coefficients; (c) calculate the value of a which minimizes L; (d) evaluate the derivative values from (6).

Parts (a) and (d) are relatively straightforward, although it should be noted that the derivatives are calculated simultaneously, not one at a time. Both Anderssen and Bloomfield and Baart discuss part (b) in terms of the fast Fourier transform (FFT). This is not used in our program for two basic reasons. First, the FFT only becomes computationally advantageous for N fairly large. Since differentiation is a local procedure we should never need to consider large sets. Secondly, the FIT is most effective when N is a power of 2, so both the above papers discuss extending the data set to have this property. This perturbation of an ill-conditioned problem seems an unsat- isfactory method of proceeding.

The Fourier coefficients are calculated using Goertzel’s method combined with Reinsch’s modi- fications. The paper by Oliver6 gives a rounding error analysis of these methods. The analysis led us to use the following algorithm for the calculation of the Fourier coefficients.

S

Suppose we wish to calculate b(0) =

(i) 0 s 0 s 0.275 rr, set ds = us = C,:

C, sin r0 : let x = cos0. r= 1

r = s-1,. . ,1. 1 calculate d, = 2 (x-1) + d,+l + C,

ur = d r + ur+l

0 2 x - 1 is calculated as -2 sin2 - .

(ii) 0.275 rr < 0 < 0-725 rr, set us+ , = 0, u, = C,:

calculate u, = 2 x u,+, - u , + ~ + C,, r = s-1, . . . , 1.

Page 3: Numerical differentiation by the regularization method

NUMERICAL DIFFERENTIATION BY THE REGULARIZATION METHOD 627

(iii) 0.725 rr S 8 < T, set d, = us = C,:

r = s -1 , . . . , 1 . I calculate dr = 2(x + 1) u,+ - d,+ + C,

ur = dr - ur+1 J 8 x + 1 is calculated as 2 cosz ~ 2 ’

In all cases, b(8) = u1 sin 8.

a = 0, w, = 1, which can lead to severe problems in the calculation of ln(1 - i,). Let In part - (c) of the calculation the function L is not used in the form given by equation (7). For

m

k=O

Then GI = 1/(1 + as,). A simple piece of algebra gives

The method used to minimize L is a standard quadratic interpolation algorithm given in the book by Nash.’

NUMERICAL RESULTS

The A-B-C method was compared to McNamee’s method using the following simulation. For a given function f , N data points (xi, fi) were calculated, with the xi values equally spaced in a certain interval, and xi < xi+l . The fj values were then perturbed by uniform random numbers to give values fj, such that

where TOL is a variable parameter. For a variety of points in the interval the true value of the derivative was then compared with

the calculated values from both methods, and the relative error calculated. For each value of TOL the process was repeated 100 times, and the overall r.m.s. relative error calculated.

Table I . Numerical results from simulation

Function Tolerance McNamee A-B-C( m=O) A-B-C( m=2) A-B-C( m=4)

0.001

0.1 0.001

0- 1 0.001

0.1

0.001

0.1

0.001

0.1 0.001

0.1

eh 0.01

sin x 0.01

x6- 5x 0.01

I (X+l) . 1)2 0.01

ln(x+2.01) 0.01

l/(x-2-111) 0.01

0.46E- 1 051EO 0.32E+ 1

0.56E-2 0.37E- 1 0.32EO 0.44E- 1 0.59EO 0.42E+ 1

0.76E-2 0.58E- 1 0.58EO

0.91E-2 0.53E- 1 0.46EO 0-51E-2 0.67E- 1 0.41 EO

0.74E- 1 0.65EO 0.66E+ 1 0.68 E - 2 0.69E-1 0.69EO 0.llEO 0.67EO 0.65E+1 O.llE-1 0,llEO O.llE+l 0.78E-1 O.llE0 0.77EO 0-97E- 1 0.12EO 0.72EO

0.74 E - 1 0.64EO 0.43E+ 1 0.68E -2 0.69E-1 0.2OEO 0,llEO 0.68EO 0.53E+1

0.11 E- 1 0.99E-1 0.29EO

0.78E-1 0.llEO 0.70EO 0.97E- 1 0.12EO 0.69EO

0.74E- 1 0.46EO 0.22E+ 1

0.59E-2 0.27E-1 0.12EO O.llE0 0.51EO 0.24E+1

0.67E-2 0.30E-1 0.12EO 0.llEO O.llEO 0.27EO 0.87E-1 0.97E- 1 0.39EO

Page 4: Numerical differentiation by the regularization method

628 A. J . MACLEOD

The interval [ -2,2] was used to generate the data values, with the derivatives evaluated in [-1.5, 1.51. For N = 41, TOL = 0.001, 0.01, and 0.1, and a variety of functionsf, the results are given in Table I. The A-B-C method was tried with three values of rn (in (3)), namely rn = 0, 2, 4.

The results do not give a consistently better method. Clearly the A-B-C method is better with m=4 than with m=O. For TOL = 0.001, McNamee’s method usually gives better results, but for the other values of TOL, the A-B-C method, with rn = 4, shows up well.

The A-B-C method is more versatile than McNamee’s method in three ways: (a) it can be used right up to the end of the interval; (b) it can give derivatives at points which are not evaluation points; (c) the calculation of higher derivatives is as easy as the calculation of the first derivative.

McNamee’s method is significantly faster than the A-B-C method. For N = 41 it is at least three times as quick.

APPENDIX I

F I L E : DFABC FORTRAN A 1 SCOT COMPUTER CENTRE VM/SP 3.1

C C C C C C C C C C C C C C C C C C

C C C

C C C

100 C C C

C C C

C C

SUBROUTINE DFABC( NIX* FINOICOTNE T X E T F E )

T H I S SUBROUTINE CONTROLS THE PROCESS OF CALCULATION OF THE D E R I V A T I V E S

INPUT PARAMETERS ARE: N = THE NO. OF DATA P O I N T S X = AN ARRAY OF S I Z E N T CONTAINING THE P O I N T S AT WHICH THE

F = AN ARRAY OF S I Z E N 9 CONTAINING THE FUNCTION VALUES FUNCTION I S EVALUATED

ND = THE NUMBER OF THE D E R I V A T I V E WANTED CUD = THE DEGREE OF SYOOTHING N E = THE NO. OF P O I N T S WHERE A O E R I V A T I V E IS REPUIRED XE = AN ARRAY OF S I Z E N E t C O N T A I N I N G THE P O I N T S AT WHICH A

D E R I V A T I V E I S REQUIRE0

OUTPUT PAR.4HETERS ARE: F E = AY ARRAY OF S I Z E N E T C O N T A I N I N G THE CALCULATED O E R I V A T I V E S

D I M E N S I O N X ( 2 0 0 ) r F ( 2 0 0 ) r X E ( 2 O O ) r F E ( 2 0 0 ) r G A ( 2 O O ) r G ( 2 0 O ) r M ( Z O G ) D I M E N S I ON S W ( 200)

SET UP CONSTANTS

G ( 1 ) = O m 0 G ( t J ) = O . O NM1 =N-1 ANM 1= FLOAT ( NM 1) P I = 3.14 1 5 9 2 6 5 3 5 8 9 7 9 XNO=X ( 1 ) - X ( 1 ) FNO=F ( Y ) - F ( 1) A M = FNO/ XNO AC=F( 1)

TRANSF3RFn DATA

DO 100 I = Z t N M l G ( I ) = F ( I ) - A W ( X ( 1 ) - X ( 1 ) ) - A C

CALCULATE ‘OURIER C O E F F I C I E N T S

C A L L DCT(NIGTGA) C A L L

CALCULATE THE OPTIMAL VALUE OF ALPHA

SW I( NINDIMDT SW )

C A L L O P T A L P ( N r G A * S W r O A L P ) C A L L WJ (N~OALPISWTW)

START CALCULATION O f O E R I V A T I V E S

OFAOOOlO OFAOOOZO O f A000 30 D F A 0 0 0 4 0 D F A 0 0 0 5 0 O F A 0 0 0 6 0 D F A 0 0 0 7 0 DFhOOO80 DF A00090 DF AOOlOO DFAOO 110 DF A 0 0 1 2 0 DFAOO 130 D F A 0 0 1 4 0 D F A 0 0 1 5 0 DFAOO 160 D F A 0 0 1 7 0 DFA 00 180 D F A 0 0 1 9 0 DF A00200 DFAOO2lO DFAOO22O D F A 0 0 2 3 0 D F A 0 0 2 4 0 OFAOO2 50 D F A 0 0 2 60 D F A 0 0 2 7 0 DFAOO28O D F A 0 0 2 9 0 DFA 00 300 D F A 0 0 3 1 0 D F A 0 0 3 2 0 D F A 0 0 3 3 0 D F A 0 0 3 4 0 O F A 0 0 3 5 0 O F A 0 0 3 6 0 O F A 0 0 3 7 0 D F A 0 0 3 0 0 D F A 0 0 3 9 0 O F A 0 0 4 0 0 D F A 0 0 4 1 0 D F A 0 0 4 2 0 D F A 0 0 4 3 0 DFA00440 D F A 0 0 4 5 0 D F A 0 0 4 6 0 D F A 0 0 4 7 0 D F A 0 0 4 8 0 O F A 0 0 4 9 0 3 F A 0 0 5 0 0

Page 5: Numerical differentiation by the regularization method

C

11 0

13 0 120

15 0 15 1

C C C C C C C C C C C C C C

C C C

C C C

C C C

C r, C C

NUMERICAL DIFFERENTIATION BY THE REGULARIZATION METHOD

DO 110 I = l r N E FE( I ) =3 -0 CO 120 J = 2 t N H 1

J M l = J - l F J = P I * J M l S 1= GA 4 J ) * W ( JM 1 ) * ( FJ** FL OA T ( ND ) ) F 9= ND *P I / 2 * 0 DO 130 I = l r N E

T = ( X E (I ) - X ( 1) ) / X N O C l = S I N ( F J * T * F 9 )

F E ( I ) = F E ( I ) * S l * C l CON T I N U E C 1= X N O * * ( F L O A T ( ND ) ) 30 150 I = l r N E

F E ( I ) = F E ( I ) / C l R E T U R N E N D

I F( ND .EP. 1) FE (I ) = F E (I ) * F N O

S U E R O U T I N E D F T ( N 7 G v G A )

T H I S S U B R O U T I N E C A L C U L A T E S T H E F O U R I E R C O E F F I C I E N T S O F T H E T R A N S F D R M E O F U N C T I O N V A L U E S I T U S E S G O E R T Z E L ' S M E T H O D W I T H R E I N S C H ' S M O O I F I C A T I O N A C C O R D I N G T O T H E A N A L Y S I S I N THE P A P E R OF O L I V E R

I N P U T P A 9 AMET ER 5: N = T H E NO. O f F U N C T I O N V A L U E S G = A N A R R A Y OF S I Z E N t C O N T A I N I N G T H E T R A N S F O R M E O F U N C T I O N

VALUES

O U T P U T P A R A M E T E R S : G A AU A R R A Y O F S I Z E N v C O N T A I N I N G T H E F O U R I E R C O E F F I C I E N T S

D I M E N S I ON

S E T U P C O N S T A N T S

G A ( 1)=0.0 G A ( N ) =O .O N M 1 =N-1 N M 2 = N - 2

G (2 00 ) t GA ( 2 00 )

ANN l=FL O A T ( NP 1) 5 C= 2 O/ A N M l P I = 3 . 1 4 1 5 9 2 6 5 3 5 d 9 7 9

S T A R T C A L C U L A T I O N

110 1000 ! = 2 * N M l TH= ( 1 - 1 ) / A N M 1 T L = O . S - T H

T E S T WHERE T H E T A L I E S

I F ( A B S ( T 1 ) . G T . O . Z 2 5 ) G O T O 1001

THETA L I E S I N C E N T R A L R E G I O N . U S E S T R A I G H T f O R W A R O GOERT ZEL ' S M E T H O D

TH=PX *TH X=C OS (TH) X 2 = 2 . O * X l J l = O . O U 2 = G ( N u l ) D O 1005 I R = 2 t N M Z I R 1 = U - I R U =X 2 ' rUZ-U 1* C ( I R 1) u 1 = u 2 u2=u

1005 C O N T I N U E G A ( I ) = U * S I N ( T H ) * S C C O T U 1000

C

629

D F A O O S 10 O F A 0 0 5 2 0 D F A 0 0 5 3 0 D F A 0 0 5 4 0 D F A 0 0 5 5 0 O F A 0 0 5 6 0 O F A 0 0 5 7 0 O F A 0 0 5 0 0 O F A 0 0 5 9 0 O F A 0 0 6 0 0 O F A 0 0 6 1 0 O F A 0 0 6 2 0 D F A 0 0 6 3 0 D F A 00640 O F A 0 0 6 5 0 O F A O O 660 O F A 0 0 6 7 0 O F A O O 6 8 O O F A 0 0 6 9 0 O F A 0 0 7 0 0 O F A 0 0 7 1 0 O F A 0 0 7 2 0 D F A 0 0 7 3 0 O F A 0 0 7 4 0 D F A O O 750 O F A 0 0 7 6 0 O F A 0 0 7 7 0 O F A 0 0 1 8 0 O F A 0 0 7 9 0 O F A 0 0 0 0 0 O F A O O B l O O F A O O 8 2 0 O F A 0 0 8 3 0 O F A 0 0 8 4 0 O F A 0 0 0 5 0 O F A O O 8 6 0 O F A 0 0 8 7 0 O F A 0 0 8 8 0 O F A 0 0 0 9 0 O F A 0 0 9 0 0 O F A 0 0 9 1 0 D F A 0 0 9 2 0 O F A 0 0 9 3 0 D F A 0 0 9 4 0 D F A 0 0 9 5 0 O F A 0 0 9 6 0 O F A 0 0 9 7 0 O F A 0 0 9 0 0 D F A 0 0 9 9 0 O F A O L 000 D F A O l 0 1 0 @ F A 0 1 0 2 0 D F A O l O 3 0 @ F A 0 1 040 D f A 0 1 0 5 0 O F A 0 1060 D F A 3 1 0 7 0 D F A 0 1 0 8 0 D F A 3 1 0 9 0 D F A O l 1 0 0 O F A O 1 1 1 0 C F A O l 1 2 0 O F A O 1 1 3 0 O F A O l l 4 0 O F A O l 1 5 0 D F A O l l 6 0 O F A O 1 1 7 O D F A O l 1 8 0 D F A O l l 9 0 D F A O 1200 D F A 0 1 2 10 O F A O l Z Z O O F A 0 1 2 3 0 O F A 0 1 2 4 0 O F A O l 2 5 0 O F A 0 1 2 6 0

Page 6: Numerical differentiation by the regularization method

630 A. J . MACLEOD

C TEST WHETHER THETA L I E S AT BOTTOM OR TOP OF RANGE C

C C THFTA CLOSE T O ZERO . USE APPROPRIATE REINSCH MODIF ICATION C

1001 I F ( T ~ . L T ~ O . O ) G I I T O 1010

T H= P I *TH S l = S I N ( T H / 2 9 0 ) x 1= -4 0 3 * s 1 * 5 1 O i = G ( N H l ) U 1= D 1 90 1 0 0 5 I R = 2 * N H 2

I R l = N - I R D 1 = X l *U 1*D1 +G (I R l ) u1=01 + u l

1006 CONTINUE G A ( I ) =U 1 * S I N( TH )* SC G O T O 1000

C C THETA CLOSE TO P I . USE APPROPRIATE REINSCH CODIF ICATION r L

1010 TH=PI *TH 5 l = C O S ( TH/2 -0) X 1=4. G* 5 1 *S 1 D l = G ( NM1) u l = D 1 00 1011 I R = 2 9 N Y 2

I R l = h ( - I R D 1 = X l * U 1 - D l + G ( I R l ) u 1 = D 1 -u 1

1011 CONTINUE G A ( I ) =U 1 Q: 5 I Id ( TH ) * SC

1000 CUYTINUE RETURN E NO

SUBROUT I N E SW I (Nq NDIMDI SW ) C t T H I SUBROUTINE CALCULATES THE ELEWENTS OF THE SEQUENCE C 5 9 DEFINED BY EQUATION 10 I N THE TEXT L C I NPUT PAR AWET ER 5 :

C ND = VALUE OF D E R I V A T I V E MANTED C MD = DEGREE OF SMOOTHING

C N = N O 9 OF DATA POINTS

C OUTPUT PARAMETERS: C S W = AV AHRAY OF S I Z E N I CONTAINING THE ELEMENTS OF THE t SEQUENCE S W r L

DIMENSION S W ( 2 0 0 )

N H l = N - 1 ANVl=FLOAT(NP 1) MDl=YO* 1 DO ZOO0 1 = 1 1 N H l

P I= 39 1 4 1 5 92 6 5 3 5 8979

F I = P I *I /ANM 1 F I 2 = F I * F I F I N =F I 2 **ND s =o 00 00 2001 K = l t M D l

S =S +F I 2 ** FLOAT ( K- 1) Z O O 1 CJNTINUE

2 0 0 0 CONTINUE RETURN E NO

SW( I ) =F IV*S

SUEROUTINE WJ (VIALPISWTW) C C T H I S SUBROUTINE CALCULATES THE ELEMENTS OF THE SEQUENCE W C DEFIVE3 9 Y EOUATIOV 6 I N THE TEXT

DFA01270 D F A O l Z 8 0 D F A O l 2 9 0 DFA01300 DFAD13 lO D F A O l 3 2 0 DFA01330 D F A O l 3 4 0 DFA01350 D F A O l 3 6 0 D F A O l 3 7 0 D F A 0 1 3 8 0 DFAO1390 DF A 0 1 400 DFA 0 14 10 DFA3142O DFA01430 OFAO 1440 DFA31450 D F A 0 1 4 6 0 DF A 0 1470 DFA01480 DFA01490 DFA01500 DFAO15 10 DFAO 1520 DFA151530 DFA01540 DFACl1550 DFA01560 DFAO1570 D F A O l 5 8 0 OFAO 1 5 9 0 DFA 0 1 600 DFA01610 D F A O l 6 2 0 OFAOl630 DFA01640 D F A 0 1 6 5 0 DFAOL660 DFA01670 DFA01680 D F A O l 6 9 0 DFA01700 DFA 0 17 10 D F A 0 1 7 2 0 DFA 0 17 3 0 DF A 0 1 7 4 0 D F A O l 7 5 0 D F A 0 1 7 6 0 D F A O l 7 7 0 DFAO1780 OFA01790 D F A O l 8 0 0 D F A O l 8 10 D F A O l 8 2 0 DFAO1830 OF A 0 1840 DFA01850 DFA01860 DFA01870 DF A 0 1 880 D F A O l 8 9 0 D F A 0 1 9 0 0 D F A O l 9 l O D F A O l 9 2 0 D F A 0 1 9 3 0 DFA 0 1940 OFAO1950 D F A 0 1 9 6 0 D F A O l 9 7 0 DFAO1980 DF A 01 990 DFAOZOOO DFA 02 010 DFAO2020

Page 7: Numerical differentiation by the regularization method

NUMERICAL DIFFERENTIATION BY THE REGULARIZATION METHOD 63 1

C C INPUT PARAMETER S : C N = NO. OF DATA P O I N T S C ALP = VALUE OF ALPHA C % W = A V ARRAY OF S I Z E N * C U N T A I N I N G THE ELEMENTS OF THE C S’UUENCE S H r L

C OUTPUT PARAMETERS: C W = AN ARRAY OF S I Z E N T CONTAINING THE ELEMENTS OF THE t SESUENCE W 1

D I M E N S i O N S W ( 2 0 0 ) 9 4 ( 2 0 0 ) NM1 =N-1 DO 8000 I = l r i Y M l

RETURN END

8000 W ( I ) = l . O / ( l . O ~ A L D ~ S W ( I ) )

REAL FUNCTION F I A L P ( N g G A q S H * A L P ) C C T H I S FUNCTIOPJ CALCULATES THE VALUE OF THE L I K E L I H O O D FUNCTION * C D E F I N E D BY EQUATION 8 I N T t lE TEXT C C INPUT PARAPET ER S : C N = NO. OF DATA P O I N T S C G A = AN ARRAY OF S I Z E N 9 C O N T A I N I N G THE FOURIER C O E F F I C I E N T S C SW = AN ARRAY OF S I Z E N T C O N T A I N I N G THE ELEMENTS OF THE C SEQUENCE SW C ALP = THE VALUE OF THE REGULAR1 S A T I O N PARACETER ALPHA C

C C I F ALPHA < 0.0 THE FUNCTION I S G I V E N THE VALUE AT ALPHA s 0.0 C

DIMENSION G A ( 2 0 0 ) r d ( 2 0 0 ) t Sd (200 )

I F ( ALP. LE .O.O)A L P = 3 00 F t M l =N-1 Sl=O.O s 2 = 0.0 00 6 0 0 0 I = l r N H l

D l = S W ( I ) / ( l . o * A L P ~ S W ( I ) ) 1 P 1 =I *1 GA9 =G A ( I P 1 ) S 1= Sl * G A 9 *G A 9 * O 1 S Z = S Z * A L J G ( O l )

6000 CUNTINUE F I A L P = N M l * A L O G ( S l ) - S 2 R ETUKN E ND

S UP,ROUT I N E UP TA LP ( N * G A T SW r O A L P )

C C C C C C C C C C C C C C r L

C C C C t

T H I S SUBROUTINE CALCULATES THE VALUE OF ALPHA WHICH G I V E S THE

I N T E R P 3 L A T I O N VETHOD AK3 I 5 SASE0 ON AN ALGORITHM G I V E N I N THE 3 0 3 K aY NASH * WHERE k CONCISE D E S C R I P T I O N CAN BE FOUND . I h P U T PARAMETERS:

M I Y I Y U M OF THE L I K E L I H O 0 9 FUNCTION I T USES A UUADRATIC

N = NO. OF DATA P O I N T S G A = Ah ARRAY OF S I Z E N T C O N T A I N I Y G THE FOURIER C O E F F I C I E N T S SW = AU ARRAY OF S I Z F N 7 C 3 N T A I N I U G THE ELEMENTS OF

THE SEPUEYCE SW

OUTPUT PARAHETFRS: q A L P = TYE VALUE OF ALPHA M I N I P I S I N G THE FUNCTION L

DIMENSION G A ( 2 0 0 ) r S W ( Z 0 O )

I N I T I AL P ARAM f T ER S: 3 = I N I T I A L E S T I M A T E OF MIMIMUM S T = I ’ J I T I A L STEP-LENGTH A 1 9 A2 = SUCCESS 9 F A I L U R E Y U L T I P L I E R S BIG = h NO. SUCH THAT - B I G < ANY FUNCTION VALUE

D F A 0 2 0 3 0 O F A 0 2 0 4 0 D F A 0 2 0 5 0 D F A 0 2 0 6 0 DFA 02 070 D F A 0 2 0 8 0 O F A 0 2 0 9 0 DFAOZ L O O DFAOZ 110 DFAO2 1 2 0 D F A 0 2 1 3 0 DFAO2 140 D F A 0 2 1 5 0 D F A 0 2 1 6 0 D F A O 2 1 7 0 DFAO218O D F A O 2 1 9 0 D F A 0 2 2 0 0 D F A 0 2 2 1 0 3 F A 0 2 2 2 0 O F A 0 2 2 3 0 OF A 0 2 2 40 D F A 0 2 2 5 0 D F A 0 2 2 6 0 D F A 0 2 2 7 0 D F A 0 2 2 8 0 D F A 0 2 2 9 0 D F A 0 2 3 0 0 D F A 0 2 3 1 0 D F A 0 2 3 2 0 D F A 0 2 3 3 0 D F A 0 2 340 DFA02 3 5 0 D F A 0 2 3 6 0 D F A 0 2 370

OFA02 390 D F A 0 2 4 0 0 D F A 0 2 4 1 0 D F A 0 2 4 2 0 D F A 0 2 4 3 0 D F A 0 2 4 4 0 D F A 0 2 4 5 0 O F A 0 2 4 6 0 D F A 0 2 4 7 0 D F A 0 2 4 8 0 D F A 0 2 4 9 0 DFAQ2 500 DFAO25 10 D F A 0 2 5 2 0 D F A 0 2 5 3 0 D F A 0 2 5 4 0 D F A 0 2 5 5 0 D F A 0 2 5 6 0 D F A 0 2 5 7 0 DFA 0 2 5 8 0 D F A 0 2 5 9 0 D F A 0 2 6 0 0 D F A 0 2 6 1 0 DFAO262O D F A O 2 6 3 0 D F A Q 2 6 4 0 D F A 0 2 6 5 0 D F A 0 2 6 6 0 D F A 0 2 6 7 0 D F A 0 2 6 8 0 D F A 0 2 6 9 0 OFAOZ 7 00 D F A 0 2 7 1 0 DFAO 27 20 D F A 0 2 7 3 0 DFAOZ 740 D F A 0 2 7 5 0 D F A 0 2 7 6 0 DF A 0 2 1 7 0 O F A 0 2 7 80

0 ~ ~ 0 2 3 ~ 0

Page 8: Numerical differentiation by the regularization method

632 A . J . MACLEOD

C 8=10e0**( -10.0) ST= l O e O * * ( -8 - 0) A 1 = 1 0 5 A2=-0e25 B IG=1OOOOOOOO.O P z F I A L P (NvGAISUIB)

SO=-BIG X 1 = 0 0 0 BMIN=B

8=8MI N* X2 B9= BH I N *X 1

5002 S l = P

5 0 0 3 X2= X 1 *S T

I F ( 80 EQ .( BM I N * X l ) )GOTO P=FIALP (NIGAT S W T B ) I F ( P o LT .S1) GOTO I F ( SO-GE.Sl)tOTO 5011 so= P x o = x 2 S T=A2*S T GOTO 5003

5010 x o = x 1 so= 51 x l = X 2 S l = P ST=A l *S T GOTO 5303

5 0 1 1 XO=XO-Xl SO= (SO- 5 1 ) *ST

5 0 9 9

501 0

P = ( P-s1 ) * X O IF(PeEQe5O)GOTO 5 0 1 8 ST=Oe5* (P*XO-SO*ST)/(P-SO) X2=X1 + S T B=BMIN*XZ

P=FIALP (NIGAISWIB) I F ( 8. EQ ( BMIN*X 1 ) )GOTO

I F ( Pe LT .S 1 ) GOTO 5018 B=BMIN*X l

P = S 1 GOTO 5020

5020

5 0 1 9

50 19 X 1=X2 5 3 2 0 ST=A2*ST

GOTO 5002 5099 OALP=B

RETURN E NO

DFA02790 DFA02800 DFA 028 LO DFA02820 DFA02830 DFA02840 DFA02850 DFA02860 DFAO2870 DFAO288O DFA02890 DFAO2 900 DF A 0 2 9 1 0 DFA02920 OFAO2930 DF A 0 2 9 4 0 DFA02950 DFA02960 DFA02970 DFA02980 DFA02990 DFA 03000 DFA03O 10 DFA03020 DF A 0 3 0 3 0 DFA03040 DFA03050 DFA 0 3 0 6 0 DFA03070 OFA03000 DFA03090 OFA03100 DFA03110 DFA03120 DFA03 1 3 0 OFA03140 DFA03150 O f A03160 DFA03170 DFA03 1 8 0 DFA03 190 DFA03200 DFA032 10 DFA03220 DFA03230 DFA03240 DFA03250

REFERENCES

1. J . M. McNamee, ‘Numerical differentiation of tabulated functions with automatic choice of step-size’, Int. j . numer.

2. J . Cullum, ‘Numerical differentiation and regularization’, SIA M J . Numer. A m d , 8, 254-265 (1971). 3. R. S. Anderssen and P. Bloomfield, ‘Numerical differentiation procedures for non-exact data’, Numer. Math., 22,

4. M. L. Baart, ‘Computational expericnce with the spectral smoothing method for differentiating noisy data’, J . Cornp.

5. A. N. Tihonov, ‘Solution of incorrectly formulated problems and the regularization method’, Sov. Math. Dokl., 4,

6. J . Oliver, ‘An error analysis of the modified Clenshaw mcthod for evaluating Chebyshev and Fourier series’, J . Insr.

7. J . C. Nash, Compact Numerical Methods for Computers, Adam Hilger, 1979.

methods eng., 21, 1171-1185 (1985).

157-182 (1974).

Phys., 42, 141-151 (1981).

1035-1038 (1963).

Math. Appl . 20, 379-391 (1977).