Code:
' AITKEN INTERPOLATION
' For SHARP PC-12xx to 14xx by Robert van Engelen
'
' VARIABLES
' N number of points
' A() Aitken coefficients and y-values of points
' X() x-values of points
' X input x to interpolate
' Y interpolated y result
' I,J loop counters
' L,K rows of A()
100 "A" REM AITKEN
110 CLS: WAIT 0: CLEAR
120 INPUT "N=";N: DIM A(N*(N+1)/2),X(N)
130 FOR I=1 TO N
140 PRINT "X("+STR$ I+")=",X(I): INPUT X(I)
150 PRINT "Y("+STR$ I+")=",A(I): INPUT A(I)
160 NEXT I
170 INPUT "X=";X
180 K=N,L=0
190 FOR J=1 TO N-1
200 FOR I=1 TO N-J
210 Y=(A(L+I)*(X(I+J)-X)-A(L+I+1)*(X(I)-X))/(X(I+J)-X(I))
220 A(K+I)=Y
230 NEXT I
240 L=K,K=K+N-J
250 NEXT J
260 WAIT: PRINT "Y=",Y: GOTO 170
Code:
' LAGRANGE INTERPOLATION
' For SHARP PC-12xx to 14xx by Robert van Engelen
'
' VARIABLES
' N number of points
' X() x-values of points
' Y() y-values of points
' X input x to interpolate
' Y interpolated y result
' L Lagrange coefficient
' I,J loop counters
100 "L" REM LAGRANGE
110 CLS: WAIT 0: CLEAR
120 INPUT "N=";N: DIM X(N),Y(N)
130 FOR I=1 TO N
140 PRINT "X("+STR$ I+")=",X(I): INPUT X(I)
150 PRINT "Y("+STR$ I+")=",Y(I): INPUT Y(I)
160 NEXT I
170 INPUT "X=";X
180 Y=0
190 FOR J=1 TO N
200 L=Y(J)
210 IF L=0 GOTO 260
220 FOR I=1 TO N
230 IF I<>J LET L=L*(X-X(I))/(X(J)-X(I))
240 NEXT I
250 Y=Y+L
260 NEXT J
270 WAIT: PRINT "Y=",Y: GOTO 170