Newton-Raphson Method With Complex Numbers

In summary: Yes, the code will find a real root that is "near enough" (for complex convergence) to a real initial guess.
  • #1
person123
328
52
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!
 
Mathematics news on Phys.org
  • #2
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.
 
  • #3
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 person123 and topsquark
  • #4
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.
 
  • #5
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.
 
  • #6
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?
 
  • #7
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.
 
  • #8
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?
 

1. What is the Newton-Raphson method with complex numbers?

The Newton-Raphson method with complex numbers is a numerical algorithm used to find the roots of a complex-valued function. It is an extension of the original Newton-Raphson method, which is used for finding roots of real-valued functions.

2. How does the Newton-Raphson method with complex numbers work?

The method involves starting with an initial guess for the root and then using a series of iterations to refine the guess until it converges to the actual root. It uses the derivative of the function at each iteration to update the guess, making it a very efficient and accurate method for finding complex roots.

3. When is the Newton-Raphson method with complex numbers used?

This method is commonly used in engineering, physics, and other scientific fields to solve complex equations that cannot be solved analytically. It is particularly useful for finding the roots of nonlinear equations, which are common in many areas of science and engineering.

4. What are the advantages of using the Newton-Raphson method with complex numbers?

One of the main advantages is its speed and efficiency in finding complex roots. It also has a high rate of convergence, meaning that it quickly narrows down the possible solutions. Additionally, it can handle a wide range of complex functions and can be easily implemented in computer programs.

5. Are there any limitations to the Newton-Raphson method with complex numbers?

Yes, there are some limitations to this method. It may fail to converge if the initial guess is too far from the actual root or if the function has multiple roots in close proximity. It also requires knowledge of the function's derivative, which may not always be available. Additionally, it may produce incorrect results if the function has singularities or other complex behavior.

Similar threads

Replies
16
Views
1K
Replies
13
Views
3K
  • General Math
Replies
1
Views
807
Replies
24
Views
2K
Replies
3
Views
1K
Replies
8
Views
2K
Replies
1
Views
742
Replies
3
Views
2K
Replies
45
Views
4K
Back
Top