# Mathematica plotting doesn't work

• June 3rd 2009, 12:03 PM
new guy
Mathematica plotting doesn't work
Hi guys,

Please help me understand why the output doesn't work as it should . What am I doing wrong ? thanks
• June 3rd 2009, 01:12 PM
CaptainBlack
Quote:

Originally Posted by new guy
Hi guys,

Please help me understand why the output doesn't work as it should . What am I doing wrong ? thanks

What do you expect the plot to look like, and do you think Mathematica can plot that?

(the sum is a pulse train of delta functionals)

CB
• June 3rd 2009, 03:52 PM
shawsend
How about taking the sum symmetrically and then plotting the limit superior and limit inferior:

$\mathop\text{lim inf}\limits_{N\to\infty} \left\{1+2\sum_{n=1}^{N} \cos(2\pi nt)\right\}$

$\mathop\text{lim sup}\limits_{N\to\infty} \left\{1+2\sum_{n=1}^{N} \cos(2\pi nt)\right\}$

Here's my code to plot (empirically) the limit superior based on the first 100 terms:

Code:

f[t_, kmax_] := 1 + 2*Sum[Cos[2*Pi*k*t],       {k, 1, kmax}]; ListPlot[Table[{t, Max[Table[f[t, nval],       {nval, 1, 100}]]},   {t, 0, 5, 0.011}]]
Is that close to what it would look like in the limit?
• June 3rd 2009, 09:57 PM
new guy
Okay thank you both, I understand my mistake now .

I have another question that troubles me , and I'll appreciate your advices.
Given Sum of : X_N(t) =Sum [ Exp(j2*Pi*k*t) ] with lower limit -N and upper limit +N , -2<= t <= 2
I need to calculate x(t) ,so I used Euler :
X_N(t) = Sum e^(j2*pi*k*t) = Sum [ cos(2pi*k*t) + j*sin (2pi*k*t) ].

Now ,if I'm mistaken the sinus part becom equal to zero , because the cycle
of sinus is PI . But I have a problem with the Cosinus part , how can I
simplify it ? the "t" parameter interrupts with the simplifying ......
maybe separating it to conditions ? N=2R ------> even , N=2R+1 --> odd ?

• June 4th 2009, 03:45 AM
CaptainBlack
Quote:

Originally Posted by new guy
Okay thank you both, I understand my mistake now .

I have another question that troubles me , and I'll appreciate your advices.
Given Sum of : X_N(t) =Sum [ Exp(j2*Pi*k*t) ] with lower limit -N and upper limit +N , -2<= t <= 2
I need to calculate x(t) ,so I used Euler :
X_N(t) = Sum e^(j2*pi*k*t) = Sum [ cos(2pi*k*t) + j*sin (2pi*k*t) ].

Now ,if I'm mistaken the sinus part becom equal to zero , because the cycle
of sinus is PI . But I have a problem with the Cosinus part , how can I
simplify it ? the "t" parameter interrupts with the simplifying ......
maybe separating it to conditions ? N=2R ------> even , N=2R+1 --> odd ?

Due to symetries:

$x_N(t)=\sum_{k=-N}^N e^{j 2 \pi k t}=1+\text{Re}\left[2\sum_{k=1}^N e^{j 2 \pi k t}\right]$

and the sum on the right is a finite geometric series and so you should know that it sums to:

$x_N(t)=\text{Re}\left[2\ \frac{1-e^{j2\pi t (N+1)} }{1-e^{j2\pi t}}\right]-1$

which you should be able to simplify further.

CB
• June 4th 2009, 08:57 PM
CaptainBlack
Quote:

Originally Posted by CaptainBlack
Due to symetries:

$x_N(t)=\sum_{k=-N}^N e^{j 2 \pi k t}=1+\text{Re}\left[2\sum_{k=1}^N e^{j 2 \pi k t}\right]$

and the sum on the right is a finite geometric series and so you should know that it sums to:

$x_N(t)=\text{Re}\left[2\ \frac{1-e^{j2\pi t (N+1)} }{1-e^{j2\pi t}}\right]-1$

which you should be able to simplify further.

CB

There is of course another way of thinking of the finite two sided series as a geometric series which does not involve taking real parts, but I will leave that to the reader to sort out.

CB
• June 5th 2009, 03:12 AM
new guy
Quote:

Originally Posted by CaptainBlack
Due to symetries:

$x_N(t)=\sum_{k=-N}^N e^{j 2 \pi k t}=1+\text{Re}\left[2\sum_{k=0}^N e^{j 2 \pi k t}\right]$

and the sum on the right is a finite geometric series and so you should know that it sums to:

$x_N(t)=1+\text{Re}\left[2\ \frac{1-e^{j2\pi t (N+1)} }{1-e^{j2\pi t}}\right]$

which you should be able to simplify further.

CB

thanks for the help .
Something is not clear to me , how did you make your first move with the :
1 + 2*Re(Sigma[....]) ? where did the "1" come from ?
Nonetheless , I need to see how X_N(t) "behaves" with a large "N" , and
assuming (with your solution) N---->infinity , the x(t) would be what exactly ?

X_n(t) = 1 + 2[ 1-cos(2pi*t*(N+1]) ] / 1-cos(2pi*t)

I tried to to something like what you said , using a geometric series . I'd like your opinion with my point of view . thanks again (:
• June 5th 2009, 03:47 AM
CaptainBlack
Quote:

Originally Posted by new guy
thanks for the help .
Something is not clear to me , how did you make your first move with the :
1 + 2*Re(Sigma[....]) ? where did the "1" come from ? (:

The 1 is the k=0 term of the original series.

The sum tends to a sequence of spikes at integer values of x (which is what I said in my first post

CB
• June 5th 2009, 04:08 AM
new guy
Quote:

Originally Posted by CaptainBlack
The 1 is the k=0 term of the original series.

The sum tends to a sequence of spikes at integer values of x (which is what I said in my first post

CB

But you still count from k=0 to infinity . doesn't it suppose to be from k=1 ?

And now , when N----> infinity
X_n(t) = 1 + 2[ 1-cos(2pi*t*(N+1]) ] / 1-cos(2pi*t) ,
I think there could be a problem with Cos(+inf) .... can you please explain ?
• June 5th 2009, 05:15 AM
CaptainBlack
Quote:

Originally Posted by new guy
But you still count from k=0 to infinity . doesn't it suppose to be from k=1 ?

And now , when N----> infinity
X_n(t) = 1 + 2[ 1-cos(2pi*t*(N+1]) ] / 1-cos(2pi*t) ,
I think there could be a problem with Cos(+inf) .... can you please explain ?

Yes it should be from 1 to infinity, I think I have corrected the offending post (but check it)

It is an impropper sum, you only ever consider finite sums and then take the limit as the upper limit goes to infinity (and what you have in that limit is not a normal function as it is zero every where except at integer values of x where it is infinite - in a particulatly odd manner)

CB
• June 5th 2009, 09:02 AM
new guy
Quote:

Originally Posted by CaptainBlack
Yes it should be from 1 to infinity, I think I have corrected the offending post (but check it)

It is an impropper sum, you only ever consider finite sums and then take the limit as the upper limit goes to infinity (and what you have in that limit is not a normal function as it is zero every where except at integer values of x where it is infinite - in a particulatly odd manner)

CB

I'm trying to develop the X_N(t) you mentioned above ,into a pulse train of deltas ,something like δ(t-nT) however came up empty handed . After
using Euler and taking the Real part out of XN(t) ,I can't see any way to get to delta pulse train . Are you sure that's the way ? thanks you for all the replies !
• June 5th 2009, 10:36 AM
CaptainBlack
Quote:

Originally Posted by new guy
I'm trying to develop the X_N(t) you mentioned above ,into a pulse train of deltas ,something like δ(t-nT) however came up empty handed . After
using Euler and taking the Real part out of XN(t) ,I can't see any way to get to delta pulse train . Are you sure that's the way ? thanks you for all the replies !

Consider the (formal) complex Fourier series of a series of deltas at $0,\ \pm 1,\ \pm 2,\ ..$. You should get every coefficient equal to 1. From there you should be able to get to the sum you seek.

CB
• June 5th 2009, 10:52 AM
CaptainBlack
Quote:

Originally Posted by new guy
I'm trying to develop the X_N(t) you mentioned above ,into a pulse train of deltas ,something like δ(t-nT) however came up empty handed . After
using Euler and taking the Real part out of XN(t) ,I can't see any way to get to delta pulse train . Are you sure that's the way ? thanks you for all the replies !

Code:

> >.. define function to sum the finite series and plot the result > >function FTdelta(n) $global I$  k=[-n:n]'; $t=-0.5:0.001:0.5;$  ss=exp(2*pi*I*k*t); $SS=sum(ss');$  color(12);xplot(t,re(SS')); $hold on;color(10);plot(t,im(SS'));hold off;color(1);$  return SS' \$endfunction > >.. now look at a plot of the series sum > >N=30; >FTdelta(N); >xplot;title("k=30"); > >.. now compute and plot the series sum that we have deduced > >t=-0.5:0.001:0.5; >xx=re(2*(1-exp(2*pi*I*t*(N+1)))/(1-exp(2*pi*I*t)))-1; > > >color(1);xplot(t,re(xx)); >
The results in a single plot are shown in the attachments. (note: the size of the overshoot or ringing is always the same size relative to the peak, this is Gibb's phenoemum (sp?))

CB
• June 5th 2009, 11:14 AM
new guy
Quote:

Originally Posted by CaptainBlack
Consider the (formal) complex Fourier series of a series of deltas at $0,\ \pm 1,\ \pm 2,\ ..$. You should get every coefficient equal to 1. From there you should be able to get to the sum you seek.

CB

Don't get me wrong , I'm greatful for your marvelous help , but you got me
confused this time. First you showed me how to get to
XN(t)=1+2Re*sigma(e^(2pi*jkt)) , and mathematically that's fine of course .But now you're suggesting going back to to Sigma and extract the deltas for there ?

I'll tell you what, I've done a plot of the function with Mathematica and when the "N" is big enough (let us take for example N=200000) I can see
that this is indeed a train of deltas , but I'm very confused about the theoretical point of view . I've tried a few ways however got stucked with them .

As I said before , I'm a beginner in this area and would very much appreciate if you could explain .
• June 5th 2009, 02:20 PM
CaptainBlack
Quote:

Originally Posted by new guy
Don't get me wrong , I'm greatful for your marvelous help , but you got me
confused this time. First you showed me how to get to
XN(t)=1+2Re*sigma(e^(2pi*jkt)) , and mathematically that's fine of course .But now you're suggesting going back to to Sigma and extract the deltas for there ?

I'm not suggesting anything of the sort, the code and plots showed that the finite series and the sum of that which I gave do indeed give that same result.

Quote:

I'll tell you what, I've done a plot of the function with Mathematica and when the "N" is big enough (let us take for example N=200000) I can see
that this is indeed a train of deltas , but I'm very confused about the theoretical point of view . I've tried a few ways however got stucked with them .

As I said before , I'm a beginner in this area and would very much appreciate if you could explain .
Approach this from the other direction, and ask what is the Fourier series of a comb of deltas?

CB