Dim xd, xi, xm, EPS, EPS1, MAXIT, x, i, FI, FD As Double
'Entrada de datos xi = Cells(1, 2) xd = Cells(2, 2) EPS = Cells(3, 2) EPS1 = Cells(4, 2) MAXIT = Cells(5, 2)
i = 1 FI = F(xi) FD = F(xd)
While i < MAXIT
xm = (xi * FD - xd * FI) / (FD - FI) FM = F(xm) ' If Abs(FM) < EPS1 Then Cells(8, 2) = xm Else End If ' If Abs(xd - xi) < EPS Then xm = (xi + xd) / 2 Cells(8, 2) = xm End If ' If FD * FM > 0 Then xd = xm FD = FM End If ' If FD * FM < 0 Then xi = xm FI = FM End If i = i + 1 Wend ' If Cells(8, 2) = "" Then Cells(8, 2) = "El metodo no converge a una raiz" End If ' End Sub
Function F(ByVal x As Double) As Double
F = 10 * x ^ 3 - (0.082 * 353 + 0.4267) * x ^ 2 + 3.599 * x - 3.599 * 0.04267 End Function