60 likes | 399 Views
3. Lagrange Interpolation:. (pp.939). Exp 3.1:. li.txt. 4 0,3 2,60 4,90 10,120 8. Sub lagri_Click () ' Change File li.txt for different problems fl = fl0 + "li.txt": Open fl For Input As 1 Input #1, nx: n=nx-1: ReDim xd(nx), f(nx) For k = 0 To n: Input #1, xd(k), f(k): Next k
E N D
3. Lagrange Interpolation: (pp.939) Exp 3.1:
li.txt 4 0,3 2,60 4,90 10,120 8 Sub lagri_Click () ' Change File li.txt for different problems fl = fl0 + "li.txt": Open fl For Input As 1 Input #1, nx: n=nx-1:ReDim xd(nx), f(nx) For k = 0 To n: Input #1, xd(k), f(k): Next k Input #1, x: Close #1 Call cls1: Print nx: Print For k = 0 To n: Print xd(k), f(k): Next k FX = 0 For k = 0 To n LKX = CDbl(1): LKXK = CDbl(1) For i = 0 To n If i = k Then 55 LKX = LKX * (x - xd(i)): LKXK = LKXK * (xd(k) - xd(i)) 55 Next i FX = FX + (LKX / LKXK) * f(k) Next k Print : Print " RESULT : ", x, FX End Sub