# HP Forums

Full Version: A New Variant of the Bisection Method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Encircling-Variant of Bisection

This algorithm is inspired by the Bisection method. It requires, in general, fewer iterations than the Bisection. The basic idea is to start with x=A, such that A<Xroot, and march towards the root. As the value of A passes over the root, we change the sign of the marching step and also reduce it. This change makes the value of A move around the root and closes in on it.

Given a function f(x)=0 and x=A, such that A<Xroot, and the root bracketing interval [A,Z], and the tolerance Toler. The value of Z is needed only to calculate the initial search step. You can eliminate Z if you provide the value for the initial search step.

Removing the nested IF statement causes the algorithm to slow down and require significantly more iterations than the Bisection method.

Code:
```Delta = (Z-A)/2 Fa = f(A) Do   B = A   Fb = Fa   A = A + Delta   Fa = f(A)   If Fa*Fb<0 then     Delta = -Delta/4     C = (A + B) / 2     Fc = f(C)     If Fa * Fc > 0 Then       A = C       Fa = Fc     End If   End If Loop Until Abs(Delta)<=Toler Return A as the refined root```

Enjoy!

Namir
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :