1
$\begingroup$
Manipulate[With[{sol=(Reap@FindRoot[Tan@z-(value[[1]]+I
start[[2]]),{z,start[[1]]+I
start[[2]]},StepMonitor:>Sow[z]])[[2,1]]//Flatten},
ComplexListPlot[sol,Joined->True,
PlotLabel->
"start: "<>ToString@Chop[start[[1]]+I start[[2]]]<>
"\nfirst iterate: "<>ToString@Chop@First@sol<>
"\nvalue of first iterate: "<>ToString@Chop@Tan@First@sol<>
"\nlast iterate: "<>ToString@Chop@Last@sol<>
"\nvalue of last iterate: "<>ToString@Chop@Tan@Last@sol<>
"\nvalue: "<>ToString[value[[1]]+I value[[2]]],
AspectRatio->1,PlotRange->All,ImageSize->300,PlotMarkers->Automatic,Epilog->{PointSize[Large],Blue,Point[First@ReIm@sol],Red,Point[Last@ReIm@sol]}]],
{start,{-5,-5},{5,5}},
{value,{-5,-5},{5,5}}
]

I notice that value and value of last iterate are always identical in the real part and always different in the imaginary part (sometimes "extreme", like 3.9I vs. -2.7I). I can't see how I would be treating real and imaginary parts differently in my code. Is that a bug in FindRoot, or do I have a bug in my code?

  • if you see only a red dot in the middle it means that the FindRoot iteration got stuck (FindRoot::lstol). Can you help me get it unstuck and actually converge?
  • is there a way to give the 2dim sliders some GridLines too?
$\endgroup$
1
$\begingroup$

There is a bug in the imaginary part in the equation:

Tan@z-(value[[1]]+I start[[2]])

Change this and it will work, except when FindRoot does not converge.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Duh! Thank you. $\endgroup$ – Andreas Lauschke Oct 14 '19 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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