# How to evaluate sum with different coefficient in each term?

I would like to know if there is a syntax that allows me to enter a sum that has coefficients that vary for every term? I have no interest in evaluating them numerically, but rather to keep them as symbols with indices set by the iteration variable of the sum.

See for example this spherical harmonics, where the f coefficient is what I'm referring to.

The ultimate goal is to enter a similar sum in a way that allows me to calculate its partial derivatives.

• Have you tried using Sum ? Commented May 19, 2015 at 11:15
• Well yes, I can use that for basic sums. However, I do not find any syntax for entering the coefficient f (in the example sum), and make it have different indices set by the iteration variables (l and m in this case). Commented May 19, 2015 at 11:25
• f is just a function depending on two variables. Here you can find an example with 2 nested summations. Other than that I really don't see what can be done besides getting your hands dirty and experimenting with Sum. Commented May 19, 2015 at 11:34
• I guess the answer to my question is a "no" then. Thank you for your answers! Let's see if I can make this work the long way. Commented May 19, 2015 at 11:57
• Rikard, how should we interpret the $f(m,l)$ in your summation? Are you really defining $f(r,\theta,\phi)$ as a function of the same $f(m,l)$, or should the second f be considered a parameter? In which case you should probably give it another name to avoid confusion... Commented May 19, 2015 at 13:23

g[r_,θ_,ϕ_] :=

• It is not, because you have a function g defined in terms of f. And OP has f defined in terms of f. Commented May 19, 2015 at 13:18
• @Sektor well I did wonder about that too. I wonder in particular if the OP actually meant that as you interpret it, or whether the $f^m_l$ is just a parameter... Commented May 19, 2015 at 13:26
• The whole beastie is expressible as a single sum: Sum[f[l, m] r^l SphericalHarmonicY[l, m, θ, ϕ], {l, 0, ∞}, {m, -l, l}]`. Note the Mathematica convention of having the outermost iterator come first. Commented May 19, 2015 at 15:18