ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
731 B

  1. 10 REM LAGRANGE INTERPOLATION
  2. 12 REM
  3. 14 INPUT "HOW MANY POINTS";N
  4. 16 PRINT
  5. 18 DIM X(N),F(N),L(N)
  6. 20 FOR I=1 TO N
  7. 22 INPUT "X,F";X(I),F(I)
  8. 24 NEXT I
  9. 26 FOR I=1 TO N: L(I)=1
  10. 28 FOR J=1 TO N
  11. 30 IF J=I THEN 34
  12. 32 L(I)=L(I)*(X(I)-X(J))
  13. 34 NEXT J
  14. 36 L(I)=F(I)/L(I)
  15. 38 NEXT I
  16. 40 PRINT
  17. 42 INPUT "DESIRED X";X$
  18. 44 IF X$="X" THEN 78
  19. 48 X=VAL(X$): F1=0
  20. 50 FOR I=1 TO N
  21. 52 IF X<>X(I) THEN 56
  22. 54 F=F(I): F1=1
  23. 56 NEXT I
  24. 58 IF F1=1 THEN 74
  25. 60 T=1: F=0
  26. 62 FOR I=1 TO N
  27. 64 T=T*(X-X(I))
  28. 66 NEXT I
  29. 68 FOR I=1 TO N
  30. 70 F=F+L(I)*T/(X-X(I))
  31. 72 NEXT I
  32. 74 PRINT "F: ";F
  33. 76 PRINT: GOTO 42
  34. 78 END
  35. 80 REM ------------------------
  36. 85 REM APPEARED IN ASTRONOMICAL
  37. 90 REM COMPUTING, SKY & TELE-
  38. 95 REM SCOPE, APRIL, 1984
  39. 99 REM ------------------------