Re: Plotting
- Subject: [mg2163] Re: Plotting
- From: ianc (Ian Collier)
- Date: Wed, 11 Oct 1995 05:58:20 GMT
- Approved: usenet@wri.com
- Distribution: local
- Newsgroups: wri.mathgroup
- Organization: Wolfram Research, Inc.
- Sender: daemon at wri.com ( )
In article <44qj7k$s22 at ralph.vnet.net>, Julian Charko
<jcharko at microage-ll.awinc.com> wrote:
> In order to plot the function f(x) = a^x, where a<0, over a
> range of integer values of x, what plotting options would you
> need to use with the Plot command?
>
> Specifying a plotting range of real numbers in the usual way,
> as shown below, for example, presents problems because
> Mathematica generates complex numbers for fractional exponents,
> and these obviously cannot be plotted by Plot.
>
> Plot[(-1)^x, {x, -5, 5}]
Well, you could either create a list of the function evaluated
for integer avlues of x and then use ListPlot to plot it, or
just plot the real part of your function. Both are illustrated
below.
In[6]:=
pts = Table[{x,(-1)^x}, {x, -5, 5}]
Out[6]=
{{-5, -1}, {-4, 1}, {-3, -1}, {-2, 1}, {-1, -1}, {0, 1},
{1, -1}, {2, 1}, {3, -1}, {4, 1}, {5, -1}}
In[7]:=
ListPlot[ pts , PlotJoined -> True]
Out[7]=
-Graphics-
In[8]:=
Plot[Re[(-1)^x], {x, -5, 5}]
Out[8]=
-Graphics-
I hope this helps.
--Ian
-----------------------------------------------------------
Ian Collier
Technical Sales Support
Wolfram Research, Inc.
-----------------------------------------------------------
tel:(217)-398-0700 fax:(217)-398-0747 ianc at wri.com
Wolfram Research Home Page: http://www.wri.com/
-----------------------------------------------------------