HP Forums

Full Version: New Ostrowski-Halley root seeking algorithm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As I promised last week, here is my new algorithm that enhances Halley's method using an approach by Ostrowski (that he applied to Newton's method). To get the PDF file containing the report and the two Excel files containing the test functions click here and select the last item at the bottom to download the ZIP file associated with.

The pseudo code for the new algorithm is:

Code:
Given the function f(x)=0, an initial guess, x, and a tolerance Toler for the guess:

Do
  h = 0.01 * (1 + |x|)
  F0 = f(x)
  Fp = f(x + h)
  Fm = f(x - h)
  Deriv1 = (Fp - Fm) / 2 / h
  Deriv2 = (Fp - 2 * F0 + Fm) / h / h
  Diff = F0 / Deriv1 / (1 - F0 * Deriv2 / Deriv1 / 2 / Deriv1)
  z = x - Diff
  Fz = f(z)
  Deriv1b = (F0 - 2 * Fz) / (x - z)
  Deriv2b = (Fp - 2 * Fz + Fm) / h / h
  Diff2 = Fz / Deriv1b / (1 - Fz * Deriv2b / Deriv1b / 2 / Deriv1b)
  x = z – Diff2
Loop Until |Diff2| < Toler 
Return X as the refined guess for the root.

The report on my website actually shows and explains two flavors for the algorithm. The test functions are applied to both flavors.

Enjoy

Namir
I uploaded a new version of the algorithm that compromises between the two flavors of the algorithm I posted yesterday. You can upload the new ZIP file using the link in my first message.

The pseudo-code for the new version is:

Code:
Given the function f(x)=0, an initial guess, x, and a tolerance Toler for the guess:

Do
  h = 0.01 * (1 + |x|)
  F0 = f(x)
  Fp = f(x + h)
  Fm = f(x - h)
  Deriv1 = (Fp - Fm) / 2 / h
  Deriv2 = (Fp - 2 * F0 + Fm) / h / h
  Diff = F0 / Deriv1 / (1 - F0 * Deriv2 / Deriv1 / 2 / Deriv1)
  z = x - Diff
  Fz = f(z)
  If |x - z| < h Then h = x -z
  Deriv1b = (F0 - 2 * Fz) / (x - z)
  Deriv2b = (Fp - 2 * Fz + Fm) / h / h
  Diff2 = Fz / Deriv1b / (1 - Fz * Deriv2b / Deriv1b / 2 / Deriv1b)
  x = z – Diff2
Loop Until |Diff2| < Toler 
Return X as the refined guess for the root.
Reference URL's