home *** CD-ROM | disk | FTP | other *** search
- 1 PRINT "From the April 1984 SKY & TELESCOPE, p. 359."
- 2 PRINT
- 3 PRINT "This program interpolates values in an ephemeris or other table,"
- 4 PRINT "using the mdethod developed by French mathematician J.L. Lagrange."
- 5 PRINT
- 6 PRINT "INPUT: Number of known points to be entered from a table, value (F)"
- 7 PRINT " for each point (X), desired intermediate point."
- 8 PRINT
- 9 PRINT "OUTPUT: Interpolated value for desired intermediate point." : PRINT
- 10 REM LAGRANGE INTERPOLATION
- 12 REM
- 14 INPUT "HOW MANY POINTS";N
- 16 PRINT
- 18 DIM X(N),F(N),L(N)
- 20 FOR I=1 TO N
- 22 INPUT "X,F";X(I),F(I)
- 24 NEXT I
- 26 FOR I=1 TO N : L(I)=1
- 28 FOR J=1 TO N
- 30 IF J=I THEN 34
- 32 L(I)=L(I)*(X(I)-X(J))
- 34 NEXT J
- 36 L(I)=F(I)/L(I)
- 38 NEXT I
- 40 PRINT
- 42 INPUT "DESIRED X (ENTER X TO END)";X$
- 44 IF X$="X" THEN 78
- 46 IF X$>"9" THEN 42
- 48 X=VAL(X$) : F1=0
- 50 FOR I=1 TO N
- 52 IF X<>X(I) THEN 56
- 54 F=F(I) : F1=1
- 56 NEXT I
- 58 IF F1=1 THEN 74
- 60 T=1 : F=0
- 62 FOR I=1 TO N
- 64 T=T*(X-X(I))
- 66 NEXT I
- 68 FOR I=1 TO N
- 70 F=F+L(I)*T/(X-X(I))
- 72 NEXT I
- 74 PRINT "F: ";F
- 76 PRINT : GOTO 42
- 78 RUN"ASTRMENU.BAS"
- )
- 66 NEXT I
- 68 FOR I=1