       Re: Real and Complex Roots presented in a single plot

• To: mathgroup at smc.vnet.net
• Subject: [mg91850] Re: [mg91820] Real and Complex Roots presented in a single plot
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Wed, 10 Sep 2008 05:08:41 -0400 (EDT)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <200809091056.GAA27909@smc.vnet.net>
• Reply-to: murray at math.umass.edu

```Here's some suggestions.

First, since the roots of the function include complex numbers, it's
better to call the input variable z, and then use a different name for
the function.

Second, you might have better luck if you rationalize the coefficients,
solve "exactly", then take the numerical values of the exact roots
found.  That way you won't have to do lots of FindRoot instances.

Third, it seems to me that plotting the real and imaginary parts of each
root separately, on the x- and y-axes, respectively, will not be very
enlightening unless all you're interested in is those real and imaginary
parts:  you won't be able to tell which real part goes with which
imaginary part.  So I also suggest that you plot the complex points
themselves.  If you want, in addition, to plot the real and imaginary
parts of each on an axis, that should now be simple to add to the plot.

Here's one way I would do it; undoubtedly there's a simpler way than I
show to obtain the {x,y} pairs from the real and non-real roots.

f[z_] := (13/10) Sin[(17/10) z] + (6/10) Sin[4 z]

(* find the roots *)
roots = z /. Solve[f[z] == 0, z]
nRoots = N /@ roots

(* massage roots to get {x,y} coordinates for each *)
coords = nRoots /. Complex[a_, b_] -> {a, b}
xyPairs = Replace[coords, x_?(Length[#] == 0 &) -> {x, 0}, 1]

(* plot the roots *)
ListPlot[xyPairs, PlotStyle -> PointSize[Medium]]

With David Park's "Presentation" package, this is MUCH easier, as no
massaging of the roots is needed:

<< Presentations`Master`

Draw2D[{PointSize[Medium], ComplexPoint /@ roots},
Axes -> True, AspectRatio -> 0.5]

Narasimham wrote:
> z[x_] = 1.3  Sin[1.7* x] + 0.6 Sin[4* x] ;
> Plot[z[x], {x, 0, 18}]
>
> In the above plot we can see all the real roots of z very
> approximately at {2.1,3.4, 5.5, 7.6, 9, 11, 13.1, 14.5, 16.5}, as the
> curve crosses x-axis.
>
>          We can also recognize and see the real parts of all the
> complex roots of z where the curve is nearest to x -axis at  {1.4,
> 4.2, 6.6, 9.6, 12.3, 15.3, 17.7}. They are near to x-values where the
> local maxima/minima occur.But we cannot 'see' their complex parts, as
> they need to be computed.
>
> After computation of all real and complex roots I would like  to
> represent all roots,  real and complex  roots alike, on an ( x - y )
> Argand diagram (in a 2D plot)  with the real part on x - axis and
> imaginary part on y - axis.   How to do this ?
>
>   Regards,
>   Narasimham
>

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

```

• Prev by Date: Re: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]?
• Next by Date: Re: Real and Complex Roots presented in a single plot
• Previous by thread: Re: Real and Complex Roots presented in a single plot
• Next by thread: Re: Real and Complex Roots presented in a single plot