2
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ 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). $\endgroup$
    – Szabolcs
    Commented May 12, 2012 at 13:36

1 Answer 1

4
$\begingroup$

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

$\endgroup$
16
  • $\begingroup$ thanks for the answer but how come the ticks were affecting the range of the function ? $\endgroup$ Commented May 12, 2012 at 8:48
  • $\begingroup$ BTW how did you get such perfect screen shots? $\endgroup$ Commented May 12, 2012 at 8:51
  • 1
    $\begingroup$ @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. $\endgroup$ Commented May 12, 2012 at 9:00
  • $\begingroup$ and about the screenshots? $\endgroup$ Commented May 12, 2012 at 9:03
  • 1
    $\begingroup$ Is there a reason that you didn't upload the images to StackExchange instead of a third-party service? $\endgroup$
    – celtschk
    Commented May 12, 2012 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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