You are on page 1of 1

Sub polinomio_Lagrange()

'Dimensionamiento

Dim N, I, J, L, XINT, FXINT, X(), FX() As Double

'Entradas

N = Cells(3, 2)

ReDim X(N + 1), FX(N + 1)

XINT = Cells(4, 2)

For I = 0 To N
X(I) = Cells(10, 2 + I)
FX(I) = Cells(11, 2 + I)
Next I

'Proceso

FXINT = 0
I = 0

While I <= N
L = 1
J = 0
While J <= N
If I <> J Then
L = L * (XINT - X(J)) / (X(I) - X(J))
End If
J = J + 1
Wend
FXINT = FXINT + L * FX(I)
I = I + 1
Wend

Cells(7, 2) = FXINT

End Sub

You might also like