Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
3  
have you looked at PlotRange in the documentation? –  rm -rf Jul 17 '12 at 2:16
    
I have not, I will do so. Thank you! –  MCP_infiltrator Jul 17 '12 at 2:50

3 Answers 3

up vote 8 down vote accepted

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]
share|improve this answer
    
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

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

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

LogPlot

share|improve this answer
    
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

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}}]
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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