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.