9
$\begingroup$

First the background. I'm trying to solve for the roots of a rather messy complex equation. This is not the exact equation, but it's a decent (simpler) stand in:

Tan[x - I a] + I == I (x - I a)^(-1/2)

I can use FindRoot to solve for a particular root, i.e.

FindRoot[Tan[z] + I == (I) (z)^(-1/2), {z, Pi - .3 I}]

which gives {z -> 3.08945 - 0.465902 I}. The thing is, the real part of these equations (as well as the imaginary parts) alone have periodic solutions. For example, look graphically at this solution:

Mathematica graphics

However, realizing that the real roots tend to be spaced roughly at integer factors of $\pi$ (i.e. consider Tan[x]==x^(-1/2)), using FindRoot[Tan[z] + I == (I) (z)^(-1/2), {z, 2 Pi - .3 I}] indeed gives the next root. However, in the actual equation some roots get spaced un-evenly, and it's possible to miss particular roots when using this guess method.

I recognize that another approach to doing this explicitly solves the real and imaginary parts of the equation as simultaneous roots to two real equations:

 FindRoot[{Re[Tan[x + I y] + I] == Re[(I) (x + I y)^(-1/2)], 
   Im[Tan[x + I y] + I] == Im[(I) (x + I y)^(-1/2)]},
  {{x, Pi}, {y, -.3}}]

and gives the same result, {x -> 3.08945, y -> -0.465902}.

Given this info, is there a way to use a RootSearch-type function to find all complex (simultaneous) roots to this (these) equation(s) over a particular range of real values without guessing each real part of root to be an integer value of $\pi$?

Edit As an added complication, I actually have two complex equations that I need to solve simultaneously, so if the solution could be generalizeable to allow for this sort of thing, that would be an added bonus.


Also Edit I've tried a few of the suggestions in the comments and answers below. Some work for the sample case I gave above, but for my actual problem they don't really work. So, I figured may as well give the whole crazy thing I'm trying to solve:

    s1 = {(-2 ky Pi wavelength Cot[
      1/2 (b ky + n Pi)] + (km - I nm) (4 Pi^2 + 
       ky^2 wavelength^2 - 
       2 ky (km - I nm) Pi wavelength Tan[
         1/2 (b ky + n Pi)]))/((km - I nm) wavelength) == 0, 
          (-2 kx Pi wavelength Cot[
      1/2 (a kx + m Pi)] + (km - I nm) (4 Pi^2 + 
       kx^2 wavelength^2 - 
       2 kx (km - I nm) Pi wavelength Tan[1/2 (a kx + m Pi)]))/((km - I nm) wavelength) == 0}

This equation needs to be solved for different values for the parameters in this equation a, b, wavelength, etc. Here's a sample:

wavelength = 26 10^-3;
nm = -100;
km = 5;
a = 13 10^-4;
b = 64 10^-5;
m = 1;
n = 0;

Now, if I try

Solve[{Sequence@@s1, Abs[kx] <= 10, Re[kx] >= 0, Abs[ky] <= 10, Re[ky] >= 0}]

I get an error "This system cannot be solved with the methods available to Solve.". However, trying Sequence@@N@s1 it suggests trying exact input. Similarly, Reduce does not work with N values, and with exact values takes impossibly long to solve.

So, I'm still looking for a fast numerical approach. Perhaps something like J.M. suggested in a comment could be generalized for more than two equations?

$\endgroup$
2
  • 3
    $\begingroup$ For solving real and imaginary parts simultaneously, maybe this can help... $\endgroup$ Feb 16, 2012 at 16:16
  • $\begingroup$ @J.M. I think something like that might work for the specific example here, but not the coupled complex equations. $\endgroup$
    – Eli Lansey
    Feb 16, 2012 at 16:59

2 Answers 2

5
$\begingroup$

You can use Solve to specify a range of interest.

In[10]:= Solve[{Tan[z] + I == (I) (z)^(-1/2), Abs[z]<=10}, z]

(*
Solve::incs: Warning: Solve was unable to prove that the solution set found is
 complete.
*)
Out[10]= {
 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   -7.132251035054214302104690186362585697068142403087646814465 - 

    0.842662781181162221826225669202853177237728217131893274490 I}]}, 

 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   -4.0072460838160107316714173702742991366776869325551029661934 - 

    0.7019645733961268997044074293090492296764597316326821770525 I}]}, 

 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   -0.9400640610224741334606974053019750421040015028175053694335 - 

    0.3643340656419651371252025602838905385545008341650161006297 I}]}, 

 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   0.42502056063258650274891169514957099586187780514338474096327 + 

    0.28887193948823718272333177173656870529846993666625322445517 I}]}, 

 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   3.0894479592377390694689578127850505603723837467810656253546 - 

    0.4659016059311814902662713357028283109716496004755022472595 I}]}, 

 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   6.2485902300197850812539412523087220367984004253401247062207 - 

    0.6952369865703343084749992220176303906987008887723814228223 I}]}, 

 {z -> Root[{-I + I Sqrt[#1] + Sqrt[#1] Tan[#1] & , 

   9.3988273465945532374205413428073199349703889446719754737117 - 

    0.8189381870367646618319736159465519157976282115012488727359 I}]}}

I doubt any roots were missed, warning message notwithstanding. But it can be iffy when dealing with functions that are not everywhere analytic in the region of interest.

$\endgroup$
6
  • 1
    $\begingroup$ Will this work with 2 coupled complex equations? Also, what would happen if the functions are not everywhere analytic (e.g. discontinuous)? $\endgroup$
    – Eli Lansey
    Feb 16, 2012 at 17:17
  • $\begingroup$ I don't know the answer to either. I think it is possible that coupled equations will be amenable. Discontinuities? I'm really not sure. $\endgroup$ Feb 16, 2012 at 17:29
  • $\begingroup$ Also, consider Solve[{Tan[z] + I == I (z), Abs[z] <= 2 Pi && Re[z] > 0}, z]. If I choose 2 Pi as the maximum range, it finds more roots than if I choose 4 Pi. See here for an image. $\endgroup$
    – Eli Lansey
    Feb 16, 2012 at 18:31
  • $\begingroup$ I am confused by the difference between Solve and Reduce in v8. Only Reduce works in v7. Is Solve in v8 expanded to include the function of Reduce or do they still have distinct purposes? $\endgroup$
    – Mr.Wizard
    Feb 17, 2012 at 5:21
  • $\begingroup$ I was wondering that myself, actually. $\endgroup$
    – Eli Lansey
    Feb 17, 2012 at 14:30
2
$\begingroup$

A very good algorithm for this is demonstrated here. Details of how Reduce finds such roots and what problems it can do are discussed here.

$\endgroup$
2
  • $\begingroup$ Ted, how would those algorithms compare to your fantastic RootSearch function for finding real solutions? $\endgroup$
    – Eli Lansey
    Feb 17, 2012 at 14:30
  • $\begingroup$ The algorithm In the demonstration I pointed to will often converge on a complex root even if the initial guess is a real number. The great thing about that method is that it quickly converges for a very wide range of initial guesses. My RootSearch function can only find real roots. If real roots are what you want my function would be better because it will never wonder off the real axis. So each method is very good for different types of problems. $\endgroup$
    – Ted Ersek
    Feb 17, 2012 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.