2

I've been trying to write a MATLAB-function which calculates the a root of a function simply by using Newton-Raphson. The problem with this algorithm is it diverges near torsion points and roots with oscillations (e.g for x^2+2 after 10 iteration with initial guess -1 the method diverges). Is there any satisfying condition to identify when we get oscillations and torsions which doesn't count iterations in a really inefficient way?

Danis Fischer
  • 375
  • 1
  • 7
  • 27

3 Answers3

2

You may be interested in the Matlab File Exchange entry called "Newton Raphson Solver with adaptive Step Size". It implements the Newton-Raphson method to extract the roots of a polynomial.

In particular, this function has a while staement on line 147. Simply replace

while( err > ConvCrit && n < maxIter)

with

while( err > ConvCrit) %removing the maximum iteration criterion
marsei
  • 7,691
  • 3
  • 32
  • 41
1

I'd argue that your initial estimate of -1 is poor, hence the estimation error is large and this is what probably causes the algorithm to overshoot and oscillate (and eventually diverge).

You could consider doing successive over-relaxation by multiplying the quotient f(xn)/f'(xn) by a positive factor. I recommended you to look up methods for adaptive successive over-relaxation (which I won't elaborate here), that (adaptively) set the relaxation parameter iteratively based on the observed behavior of the converging process.

Eitan T
  • 32,660
  • 14
  • 72
  • 109
0

I think that you are trying to solve a function which does not have any real roots... so the newton raphson is not going to provide you any results for any initial guess..