Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
3  
For solving real and imaginary parts simultaneously, maybe this can help... –  J. M. Feb 16 '12 at 16:16
    
@J.M. I think something like that might work for the specific example here, but not the coupled complex equations. –  Eli Lansey Feb 16 '12 at 16:59
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
1  
Will this work with 2 coupled complex equations? Also, what would happen if the functions are not everywhere analytic (e.g. discontinuous)? –  Eli Lansey Feb 16 '12 at 17:17
    
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. –  Daniel Lichtblau Feb 16 '12 at 17:29
    
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. –  Eli Lansey Feb 16 '12 at 18:31
    
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? –  Mr.Wizard Feb 17 '12 at 5:21
    
I was wondering that myself, actually. –  Eli Lansey Feb 17 '12 at 14:30
show 1 more comment

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.

share|improve this answer
    
Ted, how would those algorithms compare to your fantastic RootSearch function for finding real solutions? –  Eli Lansey Feb 17 '12 at 14:30
    
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. –  Ted Ersek Feb 17 '12 at 17:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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