Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Thank you so much for the helpful comments. Now able to manage to plot all the functions.

Remove[q, qC, IIC]

ass = {d > 1, num > 0, \[CapitalDelta] > 0, t > 0, n >= 0};

q[\[Nu]_, num_, \[CapitalDelta]_, t_] := 
 1/num (1 + 
    2 Exp[-\[Nu]] NSum[
      Sin[(\[Pi] d)/num]/((\[Pi] d)/num) Exp[-d \[CapitalDelta]^2] 
       Cos[(\[Pi] d)/num (2 t + 1)] \[Nu]^(n + d/2)/Sqrt[
       n! (n + d)!], {d, 1, 10}, {n, 0, 10}])

AbsoluteTiming[Table[q[2, 4, 0.2, t], {t, 0, 200, 20}]]

Plot[q[2.0, 4.0, 0.2, t], {t, 0, 200}]

qC[\[Nu]_, num_, \[CapitalDelta]_, t_] := 
  1/num (1 + 
     2 Exp[-\[Nu]] Sum[
       Sin[(\[Pi] d)/num]/((\[Pi] d)/num) Exp[-d \[CapitalDelta]^2] 
        Cos[(\[Pi] d)/num (2 t + 1)] \[Nu]^(n + d/2)/Sqrt[
        n! (n + d)!], {d, 1, 20}, {n, 0, 20}]);

AbsoluteTiming[Table[qC[2., 4., 0.2, t], {t, 0, 200, 10}]]

ListPlot[Table[{t, qC[2, 4, 0.2, t]}, {t, 0, 200}]]

IIC[\[Nu]_, num_, \[CapitalDelta]_] := 

Log[2, num] - Sum[(q[[Nu], num, [CapitalDelta], t]) Log[2, q[[Nu], num, [CapitalDelta], t]], {t, 0, num - 1}]; AbsoluteTiming[Table[IIC[[Nu], 4, 0.2], {[Nu], 1, 200, 20}]] ListPlot[Table[{[Nu], IIC[[Nu], 4, 0.2]}, {[Nu], 1, 50}], PlotRange -> All, AxesOrigin -> {0, 0}]

share|improve this question
4  
I and N are built-in symbols, so don't use as custom function or variable names. Please try to come up with a minimal (as short as possible) test case that demonstrates the problem you are having, and describe the problem and the question in detail. If you simply post a large body of code, saying that it doesn't work, but not explaining what you're trying to do and what went wrong, then it's unlikely people will help. –  Szabolcs Mar 26 '13 at 16:29
    
Thank you Verbeia for the editing!!! –  Herman Apr 2 '13 at 12:02

1 Answer 1

up vote 1 down vote accepted

The first plot just works fine, although it takes a long time.

Plot[q[2.0, 4.0, 0.2, t], {t, 0, 200}]

Mathematica graphics

The table contains the same values, because you sample the periodic function periodically.

The data of the second plot is sampled badly. You should increase the frequency:

ListPlot[Table[{t, qC[2, 4, 0.2, t]}, {t, 0, 20, .1}]]

Mathematica graphics

The last plot doesn't work because your function IIC has t both in its argument list as well as in the iterator of the Sum.

share|improve this answer
    
thank you so much Sjoered C. de Vries. I correcetd my silly mistake and managed to plot the function IIC. –  Herman Apr 3 '13 at 8:56
    
IIC[[Nu]_, num_, [CapitalDelta]_] := Log[2, num] - Sum[(q[[Nu], num, [CapitalDelta], t]) Log[2, q[[Nu], num, [CapitalDelta], t]], {t, 0, num - 1}]; AbsoluteTiming[Table[IIC[[Nu], 4, 0.2], {[Nu], 1, 200, 20}]] ListPlot[Table[{[Nu], IIC[[Nu], 100, 0.2]}, {[Nu], 1, 100}], PlotRange -> All, AxesOrigin -> {0, 0}] –  Herman Apr 3 '13 at 9:27
    
@herman If you like the answer, please upvote and/or accept it (using the check mark button). –  Sjoerd C. de Vries Apr 3 '13 at 13:59
    
@ Sjoerd C. de Vries-in the expression q[[Nu]_, num_, [CapitalDelta]_, t_] the summations over d & d by 10 simply to see if their is any way to get it to work, if it goes to infinity,that is very slow to complete, is there any way to converge? –  Herman Apr 5 '13 at 14:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.