Re: Real and Complex Roots presented in a single plot

• To: mathgroup at smc.vnet.net
• Subject: [mg91852] Re: Real and Complex Roots presented in a single plot
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Wed, 10 Sep 2008 05:09:04 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <ga5koj\$r82\$1@smc.vnet.net>

```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 ?

Assuming I have correctly understood what you are looking for,
visualizing real as well as complex roots can be achieve by formatting
the list of solutions as a list of pairs {Re, Im} that can be displayed
with ListPlot. For instance,

z[x_] = 1.3 Sin[1.7*x] + 0.6 Sin[4*x]
g = Plot[z[x], {x, 0, 18}]
sols = Reduce[Rationalize[z[x], 0] == 0, x] // N
Select[List[sols /. C[1] -> 0 // ToRules], (0 <= Re[x /. #] <= 18 &)]
pts = Through[{Re, Im}[x /. %]] // Transpose
p = ListPlot[pts, PlotStyle -> {Orange, PointSize[Large]}]
Show[g, p]

HTH,
-- Jean-Marc

```

• Prev by Date: Re: How can I do a "grep -v" equivalent in Import[]?
• Next by Date: Re: About NDSolve
• 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