# Plot not plotting entire range of function

I have a simple function that I want to plot. I am using Mathematica 8 on a windows machine.

I type the following code:

Plot[100*0.5^n,{n,0,20}];


And the resulting graph only goes to 25 on the y not 100 like it should. Should I be telling Mathematica to do so?

-
have you looked at PlotRange in the documentation? – R. M. Jul 17 '12 at 2:16
I have not, I will do so. Thank you! – MCP_infiltrator Jul 17 '12 at 2:50

First the reason: Mathematica has to try to display the interesting part of the function for you. Since the function is on a long range very small, it assumes you maybe want a smaller range. Such an approach works most of the times very well but not always.

You have the chance to adjust the range of the plotting by using the PlotRange option:

Plot[100*0.5^n, {n, 0, 20}, PlotRange -> All]

-
Thank you much, I had an inkling that Mathematica was trying to show me what it thought I wanted, y I no let program tell me what's best? – MCP_infiltrator Jul 17 '12 at 2:53

Like halirutan says you can use PlotRange -> All to see the full graph over the given input range. Note that yo can also use PlotRange to select part of the output range:

Plot[100*0.5^n, {n, 0, 20}, PlotRange -> {0, 10}]


If you use PlotRange with two ranges the first one is the range on your x-axis, and overrides the range you chose for the Plot:

Plot[100*0.5^n, {n, 0, 20}, PlotRange -> {{5, 10}, {0, 10}}]

-
That makes for an interesting use of PlotRange now I know specifically how to zoom in on parts of the Range that I might desire. – MCP_infiltrator Jul 17 '12 at 13:50
@MCP_infiltrator - yes, that was the point of my answer. Enjoy :-) – stevenvh Jul 17 '12 at 13:58

Another possibility is to plot the Log of your function; this will show the interesting feature :

LogPlot[100*0.5^n, {n, 0, 20}]


-
This does indeed show an interesting feature, I did not even think to plot the log of it. – MCP_infiltrator Jul 17 '12 at 13:51