Casio FX-850P Scientific Library 116

5230

Lagrangsche Interpolation

LIB5230 (1058 Bytes)

5 ONERRORGOTO1000:DEFSEG=0
10 MODE8:DIM:c$=CHR$(5):n=2:x=0:ERASEa,b:m$="Lagrange's interpolation"
20 CLS:PRINTm$;TAB(0);"1:x       2:set data";
30 k=VAL(INPUT$(1,@)):ONGOTO200,60
40 GOTO30
60 CLS:PRINT"Number of data";
70 s$="n":z=n:GOSUB500:n=z:IFTHEN20
75 IFn<2 ORn>200 ORFRACn<>0 THEN 70
80 DIMa(n),b(n):LOCATE15,0:PRINT"=";n;
110 FORi=1 TOn
120 s$="x"+MID$(STR$(i),2):z=a(i):GOSUB500:IFTHENIFi=1 THEN60 ELSEi=i-1 ELSEa(i)=z
130 s$="y"+MID$(STR$(i),2):z=b(i):GOSUB500:IFTHEN120 ELSEb(i)=z
140 NEXT:GOTO20
200 LOCATE0,1:PRINTc$;"x?";:INPUT@10;z$:LOCATE0,0:IFz$="" THEN20 ELSEx=VALF(z$)
220 c=0:FORi=1 TOn
230 p=1:FORj=1 TOn
240 IFi<>THENp=p*(x-a(j))/(a(i)-a(j))
250 NEXT
260 c=c+p*b(i):NEXT
280 LOCATE12,1:PRINT":y=";STR$(c);:z$=INPUT$(1,@):GOTO200
500 LOCATE0,1:PRINTc$;s$;"=";z;"?";:INPUT@10;z:LOCATE0,0:w=PEEK(&H65B)-13:RETURN
1000 IFERR=1 THENCLS:ONERRORGOTO0
1010 IFERL=500 THENRESUME500
1020 IFERL=200 THENRESUME200
1030 IFERL=80 THENERASEa,b:RESUME80
1050 LOCATE0,1:PRINTc$;"not found";:z$=INPUT$(1,@):RESUME20

Generated by (c) Casio FX-850P/FX-880P Notepad 2.02

(c) by mani.becker@web.de - http://blog.manib.bplaced.net