0
$\begingroup$

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

$\endgroup$
10
  • $\begingroup$ Thank you @Guest 86, I'll try that. $\endgroup$
    – Joe
    Mar 9, 2013 at 23:00
  • $\begingroup$ 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}] $\endgroup$
    – Guest 86
    Mar 9, 2013 at 23:03
  • $\begingroup$ @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 $\endgroup$
    – Joe
    Mar 9, 2013 at 23:07
  • $\begingroup$ 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. $\endgroup$
    – Guest 86
    Mar 9, 2013 at 23:15
  • $\begingroup$ @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 $\endgroup$
    – Joe
    Mar 9, 2013 at 23:19

1 Answer 1

1
$\begingroup$

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}]

$\endgroup$
5
  • $\begingroup$ 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 . $\endgroup$
    – Joe
    Mar 9, 2013 at 23:04
  • $\begingroup$ [] 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. $\endgroup$
    – AndJM
    Mar 9, 2013 at 23:11
  • $\begingroup$ 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? $\endgroup$
    – Joe
    Mar 9, 2013 at 23:13
  • $\begingroup$ @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. $\endgroup$
    – amr
    Mar 9, 2013 at 23:16
  • $\begingroup$ @Sasha THANK YOU!!!! This was the problem I had from the beginning... I needed a space between the pi and t. $\endgroup$
    – Joe
    Mar 9, 2013 at 23:31

Not the answer you're looking for? Browse other questions tagged .