Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to evaluate a simple expression:

Subscript[λ, n] = (2 n - 1) π/(2 L);

And then sum it up:

Sum[Subscript[λ, n], {n, 1, 3}]

The result is:

π/(2 L) + Subscript[λ, 2] + Subscript[λ, 3]

How can i get Mathematica to write the second and third term in the same way as the first?

share|improve this question
Do not understand the question, but may be you wanted this? lam[n_] := (2 n - 1) Pi/(2 L); Sum[ lam[n], {n, 1, 3}] – Nasser Dec 1 '13 at 10:33
Yes that would work, but would it be possible to write each term separately? Like Pi/2L + 3Pi/2L + 5Pi/2L? – Sami Dec 1 '13 at 11:16

I believe you are trying to limit evaluation in the sum. You can use Defer to accomplish this. I Apply (@@) it to a list for partial evaluation.

Subscript[λ, n_] := Defer @@ {(2 n - 1) Pi/2 L};

Sum[Subscript[λ, n], {n, 1, 3}]
(L π)/2 + (3 L π)/2 + (5 L π)/2

Or perhaps more to your liking:

Subscript[λ, n_] := Defer @@ {(2 n - 1) Pi/Defer[2 L]};

Sum[Subscript[λ, n], {n, 1, 3}]
π/(2 L) + (3 π)/(2 L) + (5 π)/(2 L)

By the way, if you are going to use subscripts for function definitions please read Can we use letter with a subscript as a variable in Mathematica?. A number of users would tell you to avoid them for simplicity.

share|improve this answer
This was what I was looking for! Thanks! – Sami Dec 1 '13 at 11:48

Your Answer


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.