# Math Help - Newbie to Mathematica - I don't know how input it!

1. ## Newbie to Mathematica - I don't know how input it!

I tried to input this expression on mathematica for some calcs and plotting but i got the error and because i'm newbie to mathematica i don't know how to fix it because the error info is insufficient. So i need some help from you guys

[IMG]ftp://ftp.ua.pt/incoming/estga_aee/mota.JPG[/IMG]

Regards
Ricardo Mota

2. Post the code you're having problems so we can look at it but first you need to convert it to "raw input form" so that it can be cut and paste in text mode. For example, I wanted to solve:

$r^2y''+ry'+r^2y=0$

Then I'd use the DSolve command and enter into Mathematica:

$\text{DSolve}\left[r^2 y''[r]+r y'[r]+r^2 y[r]==0,y,r\right]$

then execute the command. Now select the cell (click the bracket on the right margin), then choose Cell/Convert To/Raw Input form in the menu. Ok, now it's in a text form that can be cut and paste. Cut it and now paste it into the thread here like I did below. But I also enclosed the text in code commands to make it look nicer but you don't have to do that:

Code:
In[1]:=
DSolve[r^2*Derivative[2][y][r] +
r*Derivative[1][y][r] + r^2*y[r] == 0,
y, r]

Out[1]=
{{y -> Function[{r}, BesselJ[0, r]*C[1] +
BesselY[0, r]*C[2]]}}

3. fm = 450
f0 = 3000
T0 = 1/f0
T = 0.15*T0
A = 6
n = 13
(T*A)/T0 Cos[2 \[Pi]*fm*t] + \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$n = \(-\[Infinity]$$\), $$\ \[Infinity]$$]$$\([$$$$FractionBox[\(T*A$$, $$2 T0$$] Sinc[
\*FractionBox[$$n*T$$, $$T0$$]]
\*SuperscriptBox[$$E$$, $$\[ImaginaryJ]*2 \[Pi] \((\((n*f0 + fm)$$
t)\)\)] +
FractionBox[$$T*A$$, $$2 T0$$] Sinc[
\*FractionBox[$$n*T$$, $$T0$$]]
\*SuperscriptBox[$$E$$, $$\[ImaginaryJ]*2 \[Pi] \((\((n*f0 - fm)$$
t)\)\)]\)$$]$$\)\)

Sorry my mistake :S here is the code

4. That's still messy. It still has some left-over formatting codes in it that makes the output hard to follow. Should not get that FractionBox in there. That's a clear sign that your conversion to raw input was not done correctly. Also, first rule of Mathematica: use lower case variable names. Upper case may conflict with internal commands. But just for now leave them in. Also, you do realize that when you speciffy an infinite sum like that with variables such as "t" that have not been assigned a number, Mathematica will attempt to store that infinite sum exactly and even if the syntax were correct, it would just hang using up as much memory it could use. But you can't use brackets in the sum. I changed them to parenthesis. This is how I re-wrote it and I just sumed it for a few since you specify a variable t. Also, I changed that double-struck j to a double-struck i. That is imaginary i in mathematica which when converted to raw-input, gets changed to upper case I.

Code:
fm = 450
f0 = 3000
T0 = 1/f0
T = 0.15*T0
A = 6
n = 13
((T*A)/T0)*Cos[2*Pi*fm*t] +
Sum[T*(A/(2*T0))*Sinc[(n*T)/T0]*
E^(I*2*Pi*((n*f0 + fm)*t)) +
T*(A/(2*T0))*Sinc[(n*T)/T0]*
E^(I*2*Pi*((n*f0 - fm)*t)), {n, -3, 3}]

5. Many thanks man for the quick and very useful help !

Another question, now how can i plot the graph for the coefficients $T*(A/(2*T0))*Sinc[(n*T)/T0]$ of each 'n'? i tried using the plot function but i got something like a sinc function and what i pretend was something like this:

[IMG]ftp://ftp.ua.pt/incoming/estga_aee/untitled.JPG[/IMG]

One more time many thankeful for the great help

6. Here's a table of the coefficients I created with n going from -25 to 25 and a plot of the results ( of course you'll have to initialize T, A, T0 before you execute this code) and remember to use lower case names from now on.

Code:
clist = Table[{n, T*(A/(2*T0))*Sinc[(n*T)/T0]},
{n, -25, 25}]
ListPlot[clist]