Using flag in matlap for secant method

30 Views Asked by At

In a book called optimization we have the following Algorithm for Secant method. Note that we are looking for zeroes of the derivative.

  • Step 1: Given a, b, ε, and Δx, flag = 0;
  • Step 2: Compute $α = (a+b)/2$, $f′(a)$ and $f′(α)$

    If $f′(a) f′(α) < 0$ then $b=α$, set flag = 1 (zero is bracketed) else $a=α$

    If flag == 1 then goto Step 3 else goto Step 2

  • Step 3: Compute $α = x_2 −f ′(x_2 )/ ((f ′(x_2 )− f ′(x_1))/(x_2 − x_1))$

    If $f′(α) > 0$ then $b=α$ else $a=α$

    If $|f′(α)|< ε$ then goto Step 4 else goto Step 3

  • Step 4: Converged. Print $x^* = α$, $f(x^*) = f(α)$


My questions is

  • What does the flag do and why it was 1 in step 2 and then 0 in step 3?
  • What they mean by (zero is bracketed)?
  • In step 3 why we say if $f′(α) > 0$

Can any one help. Thank you very much in advance.

1

There are 1 best solutions below

0
On

The code as presented will not work, it is missing some steps. (E.g., what are $x_1,x_2$?)

From the general structure, there are two stages, the first stage with the iterating Step 2 is a line search for a bracketing interval.

A bracketing interval is a guarantee of a root by the intermediate value theorem in that the function values at the interval end have opposite signs.

One would have to start with a large interval, and even then there is no guarantee that such an interval can be found.

In the second stage, iterating Step 3, the secant root is used as the midpoint of the interval. By ensuring the bracketing condition, this is the regula falsi or false position method with its slow convergence in most cases. However, as you remarked, it is not entirely clear if the bracketing condition is really ensured. It should be $f(b)f(α)>0$, or else some sign change in the definition has to be applied so that from the start $f(b)>0$.