1

I'm writing a fixed point iteration script in Octave and need to check if the method converges. At the moment the only thing I've come up is a quite rudimentary check of the derivative of g(x) evaluated in x0.

if (conv_x<=1)
  fprintf("\nThe method guarantees convergence:\n|g'(x0)| <= 1\n%d <= 1\n", conv_x)
else
  fprintf("\nThe method does not guarantee convergence:\n|g'(x0)| > 1\n%d > 1\n", conv_x) 
endif

Although there are cases in which it does converge even though it isn't guaranteed. Example (command window):

The method does not guarantee convergence:
|g'(x0)| > 1
2.48318 > 1

 i       x_i             Ea              Er              Er%
0        1.000000
1        3.623970        0.292484        0.080708        8.07081%
2        3.277427        0.346543        0.105736        10.5736%
3        2.929255        0.348173        0.118860        11.886%
4        2.663926        0.265329        0.099601        9.96007%
5        2.531185        0.132741        0.052442        5.24424%
6        2.490991        0.040194        0.016136        1.61356%
7        2.482583        0.008408        0.003387        0.338681%
8        2.481053        0.001530        0.000617        0.0616501%
9        2.480784        0.000270        0.000109        0.0108692%
10       2.480736        0.000047        0.000019        0.00190502%
11       2.480728        0.000008        0.000003        0.000333541%
>>

Is there a way in which I can make the program read the results and THEN have it say if it converges or not? Instead of just saying if convergence is guaranteed or not before the method is applied.

  • It is not clear what you are asking. To see if a method converges, you look at the error and check if it gets smaller at successive iteration steps. That is the definition of convergence. – Cris Luengo May 11 '20 at 15:22
  • @Cris Luengo The thing is that I know that the error is getting smaller in this example, even though convergence isn't guaranteed because of the chosen x0. I want to know if there's a way to display a message that states that the method is converging despite |g'(x0)| > 1. – Giancarlo Caorsi May 11 '20 at 15:37
  • Numerical methods typically compare the current result to the one in the previous step. If the difference is smaller than some chosen value, it considers that the process has converged and stops iterating. If you reach this point, you write out "the method converged". If you don't reach this point (you quit iterating after a fixed number of steps have been run) you write out "the method didn't converge". Is that what you are asking about? – Cris Luengo May 11 '20 at 15:41

1 Answers1

0

The solution ended up being extremely simple. I made a vector which stored all the values of the absolute error. Then compared the first value with the last to check if the method was converging.

err_v = [err_v, err_abs]

err_v is inside the fixed point method loop, so it stores every value.

Then I just compared the first value with the last like so:

I stored the first and last values in separate variables:

err_v_i = err_v(1);
err_v_f = err_v(:,end);

Finally I just compared the two with an if statement.

if(err_v_i > err_v_f)
  fprintf("\nMethod is converging\n")
else
  fprintf("\nMethod is NOT converging\n")
endif

This made it possible to point out situations in which the method converges even though |g'(x0)| > 1

Thanks Cris Luengo, your first comment made me realize how simple this was.

  • so you've defined convergence as 'error of current step is less than error at step 1'. normally convergence is defined as either - total/absolute error calculated falls below _some_value_, or error between two steps becomes consistently small (relative error). In this case, comparing it with 'error of step 1' seems a fairly arbitrary choice that could be mostly influenced by your starting condition, irrespective of whether or not the solution is actually converging. is your error guaranteed to be monotonic? could it oscillate non-convergently about a value that is less than err_v_i? – Nick J May 13 '20 at 16:06