# amplitude * cosine(2 * pi * f * t + phase) how to plot [closed]

Sorry, but I'm a bit confused with Mathematica. I would like to plot the cosine this way: amplitude * cosine(2 * pi * f * t + phase) in Mathematica, but now the cosine crosses the x-axis at less then pi/8.

cosine[amplitude_, frequency_, t_, phase_] :=
amplitude*Cos[2*Pi*frequency*t + phase*(Pi/180)];

Plot[cosine[1, 1, t, 0], {t, -1, 1},
Ticks -> {Range[-Pi, Pi, Pi/4], Automatic}]


The result is not as expected. I thought the cosine would go from -Pi to Pi. This way it would work, but it's not the way I would like to define it.

Plot[Cos[x], {x, -Pi, Pi}, Ticks -> {Range[-2 Pi, 2 Pi, Pi/4], Automatic}]


or this way.

cosine[amplitude_, frequency_, t_, phase_] :=
amplitude*Cos[frequency*t + phase];
Plot[cosine[1, 1, t, 0 \[Degree]], {t, -2 Pi, 2 Pi},
Ticks -> {Range[-2 Pi, 2 Pi, Pi/4], Automatic}]


-
I don't understand the question, but keep in mind that mathematica takes the argument of the cosine to be in radians, not degrees –  acl Dec 3 '12 at 21:41
I think you are confusing the time and angle domains. The x-axis is used here for t, which I presume is in seconds, but you insist in using radians which are used for angles. –  Sjoerd C. de Vries Dec 3 '12 at 21:42
That's some code from Matlab: f = 1; phase = 0; t = -pi:.1:pi; y = cos(2*pi*f+t + phase) plot(t,y) It plots the cosine from -3 to 3, not from -1 to 1. –  ontsch Dec 3 '12 at 21:44
BTW welcome on Mathematica.SE! I voted to close this question as "too localized", meaning that I feel it probably won't be very useful to other visitors. Nothing personal, just a way to keep the place as clean and search-able as possible. Feel free to post more questions, but try to figure out the elementary things yourself first before posting. In this case there are two problems: understanding the syntax for specifying plot ranges in Mathematica and understanding the equation itself. It's amplitude against time not angle. –  Sjoerd C. de Vries Dec 3 '12 at 22:00
OK, I voted to close this as "too localized"; please don't interpret this as a personal insult or anything. we generally close questions that could be answered by the docs after the person asking works out the problem –  acl Dec 3 '12 at 22:00

## closed as too localized by acl, Sjoerd C. de Vries, whuber, Jens, halirutanDec 3 '12 at 22:44

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

I think this is what you want.

Plot[cosine[1, 1, t, 0], {t, -1, 1},
Ticks -> {Transpose[{Range[-1, 1, 1/4], Range[-Pi, Pi, Pi/4]}],
Automatic}]


The problem was on the specification of ticks.

This specification means you only want those positions to show ticks:

Tikcs -> Range[-Pi, Pi, Pi/4]


This specification means you want those positions (Range[-1, 1, 1/4]) to show labels specified (Range[-Pi, Pi, Pi/4]):

Tikcs -> Transpose[{ Range[-1, 1, 1/4], Range[-Pi, Pi, Pi/4]}]


-