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 wanted to investigate the periodicity of functions so I tried to Plot them on Mathematica using the Plot function.

The particular function was $\cos(\cos(x))+\cos(\sin(x))$.

What I did was first plot them individually, then together. Individual results were as follows:

Plot[Cos[Cos[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}],
{1.530, 1.535, 1.540}}, AspectRatio -> .1]

diagram 1

Plot[Cos[Sin[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}], 
{1.530, 1.535, 1.540}}, AspectRatio -> .1]

diagram 2

Plot[Cos[Cos[x]] + Cos[Sin[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}],
{1.530, 1.535, 1.540}}, AspectRatio -> .1]

diagram 3

Now all together:

Plot[{Cos[Cos[x]], Cos[Sin[x]], Cos[Cos[x]] + Cos[Sin[x]]}, {x, -Pi, Pi}, Ticks ->
{Table[x*Pi, {x, -1, 1, 1/2}]}, AspectRatio -> 1/2]

diagram 4

See the yellow plot? That's supposed to be my original function but the individual function plot seems to be very different. Why is that so? Is it some system error or is it my fault?

share|improve this question
    
Please use the site's built-in image uploader. If you use external image hosting, the images will likely disappear with time (most services don't keep them indefinitely). –  Szabolcs May 12 '12 at 13:36
add comment

1 Answer 1

up vote 4 down vote accepted

All the plots are correct, but what may be catching you out is the windowing of the Y-axis and your tick specification. Adding PlotRange -> {{-4, 4}, {0, 2}} should help you see what is happening.

Plot[Cos[Cos[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}]},
  AspectRatio -> .1, PlotRange -> {{-4, 4}, {0, 2}}]

Mathematica graphics

Plot[Cos[Sin[x]], {x, -4, 4}, Ticks -> {Table[x*Pi, {x, -2, 2, 1/2}]},
  AspectRatio -> .1, PlotRange -> {{-4, 4}, {0, 2}}]

Mathematica graphics

So for the combined plot you would get:

Plot[{Cos[Cos[x]], Cos[Sin[x]], Cos[Cos[x]] + Cos[Sin[x]]}, {x, -Pi, 
  Pi}, Ticks -> {Table[x*Pi, {x, -1, 1, 1/2}]}, AspectRatio -> 1/2, 
 PlotRange -> {{-4, 4}, {0, 2}}]

Mathematica graphics

share|improve this answer
    
thanks for the answer but how come the ticks were affecting the range of the function ? –  The-Ever-Kid May 12 '12 at 8:48
    
BTW how did you get such perfect screen shots? –  The-Ever-Kid May 12 '12 at 8:51
1  
@The-Ever-Kid In your first two plots the specifications for the Y ticks are such that they are not visible since they are at {1.530, 1.535, 1.540}, which are not in the displayed range of the plot. –  image_doctor May 12 '12 at 9:00
    
and about the screenshots? –  The-Ever-Kid May 12 '12 at 9:03
1  
Is there a reason that you didn't upload the images to StackExchange instead of a third-party service? –  celtschk May 12 '12 at 12:27
show 11 more comments

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.