Using Newtonian Approximation to solve equations
If you want to solve polynominal equations, you can use the Newton-Raphson method of approximating the solutions.
This routine takes parameters too.
Author: Jim Brown Function NewtonApprox (root As Double, tolerance As Double, maxIter As Integer, params() As Double) As Integer Dim iter As Integer Dim h As Double, diff As Double iter = 0 Do h = .01 * root If Abs(root) < 1 Then h = .01 ' calculate guess refinement diff = 2 * h * MyFx(root, params()) / (MyFx(root + h, params()) - MyFx(root - h, params())) ' update guess root="root" diff iter = iter + 1 Loop While (iter <= maxIter) And (Abs(diff) > tolerance) If Abs(diff) <= tolerance Then NewtonApprox = True Else NewtonApprox = False End If End Function |
||

Editor: Jim Brown Last update: 2020-07-13 Copyright 1995-2020 VBI |