# Plotting a function only non-zero for discrete values of argument

I have a function like:

$$f(E)= \Sigma_{n=0} \Sigma_{\ell=0} \, \delta\left(E+\frac{\ell+2n+2} {R\sec{\rho}}\right) w(n,\rho,\ell)\,,$$

i.e. the function is zero unless

$$E=-\frac{(\ell+2n+2)}{R\sec{\rho}}$$

and $(n,\ell)$ can take only integer values from zero (the function $w$ is boring and not important for the problem, and $\rho$ and $R$ are just constants.).

How can I use Mathematica to plot this function against $E$?

1) I was thinking of use Solve with the domain Integers to spit out the (one or) two pairs of $(n,\ell)$ corresponding to each integer value $m=-(\ell+2n+2)$. Then I know that $E_m=-m/(R\sec{\rho})$, and I can compute $f(E_m)$ by summing the (one or) two corresponding $w(n,\rho,\ell)$ functions. Finally I can make a ListPlot. This didn't quite work as Solve spits out these ConditionalExpressions rather than Integers for some reason.

Any other ideas?

The Solve code I was using: (for example with $m=-7$)

Solve[7 == ell + 2 n + 1, {ell, n}, Integers]

• Please include your Solve[] code – Dr. belisarius Nov 6 '13 at 12:10
• Included code now. – fpghost Nov 6 '13 at 12:17
• u said R & rho are constants so what are their values.also whats the upper limit of the sums – Hubble07 Nov 6 '13 at 13:21
• Upper limits of the sums are infinity, but I don't need to calculate f for an E corresponding to such high values, so in principle the cut-off is arbitrary, depending on the range of the plot one wishes to generate. I don't think it is necessary to know the values of the constants, but an example is $\rho=0.5,R=1000$ – fpghost Nov 6 '13 at 15:41

Instead of using solve you can just get your l,n pairs by hand..:

pairs[m_] := Table[ { m - 2 - 2 n, n }, {n, 0, m/2 - 1}]

Table[pairs[i], {i, 2, 10}]

(*
{
{{0, 0}},
{{1, 0}},
{{2, 0}, {0, 1}},
{{3, 0}, {1, 1}},
{{4, 0}, {2, 1}, {0, 2}},
{{5, 0}, {3, 1}, {1, 2}},
{{6, 0}, {4, 1}, {2, 2}, {0,3}},
{{7, 0}, {5, 1}, {3, 2}, {1, 3}}, {{8, 0}, {6, 1}, {4,2}, {2, 3}, {0, 4}}}
*)


BTW, putting the >=0 conditions in Solve gets you what you want as well:

{ell,n}&/@ Solve[{7 == ell + 2 n + 1, ell >= 0, n >= 0}, {ell, n}, Integers]

• Thanks a lot. Is there an easy way to then build $f(E)$ from this table of pairs? i.e. for each row: compute $E$ and then compute $f(E)$ by adding the $w$ functions from the summand for each $(n,\ell)$ pair in the row... – fpghost Nov 8 '13 at 12:33