0

Y = (Sin[2 [Pi]t]) (1 + (1/5) Sin[6 [Pi]t] + (1/10) Sin[8 [Pi]t])

I'm trying to plot this function in Mathematica, however when I run Plot[Y, {t, -15, 15}] nothing will show up on the graph.

I think the problem is I'm entering the syntax wrong for all the trig functions?

Sorry I'm new to Mathematica. Thank you for any help! Joe

Joe
  • 15
  • 4
  • Thank you @Guest 86, I'll try that. – Joe Mar 09 '13 at 23:00
  • Ah I deleted the comment, sorry - I said that Y is evaluated once for some t when it's defined. Y[t_]:= (Sin[2 Pi t]) (1 + (1/5) Sin[6 Pi t] + (1/10) Sin[8 Pi t]) makes it a function which can be used in Plot[Y[x], {x,-15,15}] – Guest 86 Mar 09 '13 at 23:03
  • @guest86 In[116]:= Y[t_] := (Sin[ 2 [Pi]t]) (1 + (1/5) Sin[6 [Pi]t] + (1/10) Sin[8 [Pi]t])

    During evaluation of In[116]:= SetDelayed::write: Tag Times in (Sin[6.28319 sin^2 x] (1+1/5 Sin[18.8496 sin^2 x]+1/10 Sin[25.1327 sin^2 x]))[t_] is Protected. >>

    Out[116]= $Failed

    – Joe Mar 09 '13 at 23:07
  • If you used copy-paste, there might be some hidden space (Or another char) there, somewhere. Try retyping Y[t_]:= (Sin[2 Pi t]) (1 + (1/5) Sin[6 Pi t] + (1/10) Sin[8 Pi t]) manually. – Guest 86 Mar 09 '13 at 23:15
  • @guest86 Thanks for all the responses I just retyped it all, no extra spaces or anything and get:

    In[120]:= Y[t_] := (Sin[ 2 [Pi]t]) (1 + (1/5) Sin[6 [Pi]t] + (1/10) Sin[8 [Pi]t])

    During evaluation of In[120]:= SetDelayed::write: Tag Times in (Sin[6.28319 sin^2 x] (1+1/5 Sin[18.8496 sin^2 x]+1/10 Sin[25.1327 sin^2 x]))[t_] is Protected. >>

    Out[120]= $Failed

    – Joe Mar 09 '13 at 23:19
  • @guest86 I just closed the program and reopend it and copy pasted what I've been entering... Of course now there is no error haha. It still wont plot anything though.

    In[2]:= Y[ t_] := (Sin[ 2 [Pi]t]) (1 + (1/5) Sin[6 [Pi]t] + (1/10) Sin[8 [Pi]t])

    In[4]:= Plot[Y[t_], {t, -15, 15}]

    Out[4]= a blank graph

    – Joe Mar 09 '13 at 23:25
  • @Joe Try clearing all your variables. Clear[x,t,Y] Then make your $Y$ function again, using the delayed evaluation Y[t_] := (your function in t) (The t should turn green in your expression.) Then do your plot again: Plot[ Y[t] , {t , -15, 15} ]. – Alexander Gruber Mar 09 '13 at 23:25
  • @Joe The reason what you have written there isn't working is the _ after t in your Plot. _ is used in conjunction with := to denote a delayed evaluation, meaning that it won't evaluate what's on the RHS of the := until Y is called with an argument. When you put t in Y[t] in the Plot, you're actually fixing a t, so there's no need for _. (You're calling a function, not making a function.) – Alexander Gruber Mar 09 '13 at 23:28
  • @Guest86 Thank you! I needed a space in between the pi and t's in the formula. Also, thank you for showing me how to enter formulas as functions correctly. – Joe Mar 09 '13 at 23:32
  • @AlexanderGruber Thank you! The plot is working great now! – Joe Mar 09 '13 at 23:32

1 Answers1

1

Remove the brackets from around $\pi$ and use parentheses instead (or the times operator *).

So, like this:

In[1]:= Y = (Sin[2 (Pi)t]) (1 + (1/5) Sin[6 (Pi)t] + (1/10) Sin[8 (Pi)t]);

In[2]:= Plot[Y, {t, -15, 15}]

AndJM
  • 1,331
  • Y = (Sin[2[Pi]t]) (1 + (1/5) Sin[6[Pi]t] + (1/10) Sin[8[Pi]t])

    Syntax::sntxf: "2" cannot be followed by "[Pi]t".

    Syntax::tsntxi: "[Pi]" is incomplete; more input is needed.

    Syntax::sntxi: Incomplete expression; more input is needed .

    – Joe Mar 09 '13 at 23:04
  • [] is Mathematica's way of denoting functions. You are confusing the program writing [Pi]. If you need a grouping symbol to visually help you see the code, just use parentheses. – AndJM Mar 09 '13 at 23:11
  • I'm entering them as esc p esc but when I copy paste them here it changes them to [Pi]. Is the esc p esc method ok? – Joe Mar 09 '13 at 23:13
  • @Joe yes that works. \[Pi] is the ASCII form of the Pi symbol. Are you connecting the Pi and the t close together? You need a space between them (\[Pi] t, not \[Pi]t) otherwise Mathematica will interpret the pair as a single symbol/variable. – amr Mar 09 '13 at 23:16
  • @Sasha THANK YOU!!!! This was the problem I had from the beginning... I needed a space between the pi and t. – Joe Mar 09 '13 at 23:31