# Using NSolve in the complex plane

I am trying to find numerical values for $\Im\ e^{\frac{1}{2} +i\ y} = \Im\ \zeta(\frac{1}{2} +i\ y)$ for a given range. I have tried:

NSolve[Im[Exp[0.5 + I x]] == Im[Zeta[0.5 + I x]] && 0 <= x <= 20, x]


I can see that:

Plot[{Im[Exp[0.5 + I x]], Im[Zeta[0.5 + I x]]}, {x, 0, 20}]


gives:

... I am sure it is a problem with my syntax again, but can't seem to fix it :/

-
Why don't you use FindRoot? We discussed the same issue here. Now you might try this: FindRoot[ Im[Zeta[1/2 + I t] - Exp[1/2 + I t]], {t, #, 0, 20}] & /@ {3, 5}. It's hard to say definitely what's wrong with NSolve here, but similar problems one encounters here Issue with NSolve. –  Artes Nov 12 '13 at 18:07
@Artes, I was just looking at that post, trying to figure it out. Is there any way (rather than manually going back & plugging in values) to output full coordinates? Also, is it possible to output all values? FindRoot only outputs two values for the given range. –  martin Nov 12 '13 at 18:14
... what does the {3, 5} stand for? –  martin Nov 12 '13 at 18:17
It appears that entering {3, 6, 5} gives the first three values, but I have no idea why. –  martin Nov 12 '13 at 18:31
Another problem: entering t = 3.1701346526064005; NSolve[Im[Exp[1/2 + I t]]] gives error message NSolve::precsm: Requested precision -0.0470514 is smaller than MinPrecision. Using MinPrecision instead.  :/ –  martin Nov 12 '13 at 18:37

This solution will only work for zeros of odd multiplicity that are spaced far enough apart. We can just look at the sign changes from Plot.

Options[FindAllRootsInRange] = Options[FindRoot];
FindAllRootsInRange[e1_ == e2_, {x_, a_, b_}, ops:OptionsPattern[]] := Module[{p, s, g},
p = Plot[e1 - e2, {x, a, b}];
s = SplitBy[
p[[1, 1, 3, 2, 1]],
Sign[Last[#]] &
];
g = #[[1, 1]] & /@ s;
FindRoot[e1 == e2, {x, #}, ops] & /@ g
]

FindAllRootsInRange[Im[Exp[0.5 + I x]] == Im[Zeta[0.5 + I x]], {x, 0, 20},
WorkingPrecision -> 20]

(* {{x -> -4.8148248609680896326*10^-35},
{x -> 3.1701346526063997557},
{x -> 6.5144026505762818508},
{x -> 9.3682393343876903168},
{x -> 12.091009965923843486},
{x -> 15.176592892192292174},
{x -> 18.423560419608622067}} *)


To be more thorough, one could catch all zeros of even multiplicity by applying this function to the derivative too, then choosing which ones are roots to the original function. (That's not necessary for this example though.)

-
@ RiemannZeta, thanks for your input. My nachine is outputting x -> 1.2037062152420224082*10^-33 for the first value. What is this discrepancy in accuracy about? –  martin Nov 12 '13 at 21:39
@martin perhaps we're using different version? One could fix this by putting Chop around FindRoot. –  Chip Hurst Nov 12 '13 at 22:23