Newton-Raphson Method With Complex Numbers

Click For Summary

Discussion Overview

The discussion revolves around the application of the Newton-Raphson method for finding zeros of functions that may yield complex values, particularly focusing on how to effectively find real roots when the function is complex in parts of its domain. Participants explore the challenges and strategies involved in coding this method for such cases.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that while the function $$y=\sqrt{x-6}-2$$ has a real root at 10, initial guesses below 6 lead to complex results, complicating the search for real roots.
  • Another participant expresses skepticism about the convergence to a complex solution $$x = 11 + 8.94i$$, arguing that it does not seem to be near the actual root based on magnitude and angle calculations.
  • A suggestion is made that if the real part of the domain is known, success might be achieved by trying initial guesses in each connected component, but this knowledge is often lacking.
  • One participant mentions a specific function that is only real in a very narrow interval, highlighting the difficulty of identifying real parts of the domain.
  • Another participant shares that after fixing a bug in their code, they were able to converge on the real solution of 10, even starting from a complex initial guess.
  • A historical perspective is provided by a participant who previously wrote a program to find zeros of complex functions using a non-calculus approach, which successfully found a root at 10 for the discussed function.
  • Concerns are raised about the effectiveness of only searching for real parts of the domain, as it may reduce the likelihood of convergence.
  • There is a question about the general applicability of the code and whether the complex Newton-Raphson method can reliably find roots near the initial guess.

Areas of Agreement / Disagreement

Participants express differing views on the effectiveness of the Newton-Raphson method when applied to complex functions, particularly regarding the initial guesses and the identification of real parts of the domain. There is no consensus on a definitive approach, and the discussion remains unresolved regarding the generalizability of the proposed solutions.

Contextual Notes

Some limitations include the potential for missing narrow intervals where functions are real, as well as the uncertainty surrounding the convergence behavior of the method when starting from complex initial guesses.

person123
Messages
326
Reaction score
52
TL;DR
How do you find real roots using Newton-Raphson method on functions that are only real for part of their domain?
I'm trying to code Newton Raphson's method for finding zeros. I realize that even if the solution is real, it's possible for guesses to be complex. For example:

$$y=\sqrt{x-6}-2$$

While 10 is a valid real root, for any guess less than 6, the result is complex.

I tried to run the code allowing for complex numbers, starting with 1. It converged on ##11+8.94i## which may be a solution, but I was hoping it would be able to find the real solution of 10.

Would it be possible to get the method to find real roots on functions with complex values, without a priori knowing where the real part of the domain is?

Thanks!
 
Physics news on Phys.org
person123 said:
TL;DR Summary: How do you find real roots using Newton-Raphson method on functions that are only real for part of their domain?

I'm trying to code Newton Raphson's method for finding zeros. I realize that even if the solution is real, it's possible for guesses to be complex. For example:

$$y=\sqrt{x-6}-2$$

While 10 is a valid real root, for any guess less than 6, the result is complex.

I tried to run the code allowing for complex numbers, starting with 1. It converged on ##11+8.94i## which may be a solution, but I was hoping it would be able to find the real solution of 10.

Would it be possible to get the method to find real roots on functions with complex values, without a priori knowing where the real part of the domain is?

Thanks!
I don't see how ##x = 11 + 8.94i## could be anywhere near a solution of the given equation. If I subtract 6 from the number above, I get ##5 + 8.94i##, which is a complex number whose magnitude is about 10.24, and that makes an angle of about 60.74° with the positive real axis. The square root of this number must therefore have a magnitude of about 3.2 (~##\sqrt{10.24}##) and make an angle of about 30.37° with the positive real axis. Finally, subtracting 2 from this potential solution doesn't get us anywhere close to 0, so that x value can't be a solution.
 
For a complex function, for some initial guesses the method will not converge, see here.
If you know the real part of the domain, you'd likely have success by trying one initial guess in each connected component of that domain. But absent that knowledge, you can't do anything much. You could write a program to try to identify real parts of the domain, and then use those. But it might miss some, eg if they were very narrow. For instance the function:
$$f(x) = 0.01 -\sqrt{0.01^2 - (x-10)^2}$$
is only real on ##[9.99, 10.01]## and has a single root 10. An algorithm searching for a region where the function is real could easily miss that small interval.
 
  • Like
Likes   Reactions: WWGD, person123 and topsquark
Thank you!

I guess I'll stick with initially searching for real parts of the domain as @andrewkirk suggested, and just work in this real domain. If it can't find a real part, I'm okay with just throwing an error; I don't intend it to work for everything, just work for most basic sort of equations.
 
The Complex i would have to disappear somehow when you take the root, so when you subtract 2, you get 0. I don't see how that can happen.
 
I realize I had a bug in my code. After fixing it, it does end up converging on 10 (plus 1e-14i, which I can just remove in a machine zero check)!

So in this case, even though I started at 1, which is a complex part of the domain, it converges to the real solution. (As for how I'm performing operations on complex numbers, I'm just using mathjs).

Do you think this would work in general?
 
Some years back I wrote a BASIC program to search for zeros of complex functions by using a simple "follow the greatest decline" principle (avoiding the calculus) in searching for a minimal of the absolute value of the complex function. I resurrected it and entered your function and got z=10. Probably no non-real zero as WWGD said.
 
  • Like
Likes   Reactions: WWGD
person123 said:
I guess I'll stick with initially searching for real parts of the domain as @andrewkirk suggested, and just work in this real domain.
@andrewkirk was not suggesting that, he was pointing out that only using the real parts would make it even less likely to converge.

person123 said:
Do you think this would work in general?
Does your code work in general? No idea. A good way to find out if code works is to use unit testing.

Does complex Newton-Raphson find a complex root which is "near enough" (for convergence) to the initial guess? In general yes. What therefore do you think we can say if there is a real root and it lies "near enough" (for complex convergence) to a real initial guess?
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 0 ·
Replies
0
Views
3K
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K