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 have the following sequence

list = {p1, p2, p3, p4 ....}

I am summing up the p items as follows:

p1 + p2 + 2*sqrt (p21*p2) = p12

p12 + p3 + 2*sqrt (p12*p3) = p123

p123 + p4 + 2*sqrt (p123*p4) = p1234

How do I get the end result to be an addition of p12 + p123 + p1234 ?

share|improve this question
Have a look at NestList. – b.gatessucks Jun 24 '14 at 8:42
up vote 3 down vote accepted
Fold[#1 + #2 + 2*Sqrt[#1*#2] &, First[list], Rest[list]]
share|improve this answer
I have done this step for step with Symbols a, b, c, d., and I get another result. Also, I think you have to sum up the terms (p12 + p123 + p1234): – eldo Jun 24 '14 at 9:05
sorry mistake was on my part (typo) – eldo Jun 24 '14 at 10:50

Perhaps I misread your intent, but I think what you're after is:

Total@Rest@FoldList[#1 + #2 + 2*Sqrt[1 ##] &, First[list], Rest[list]]
share|improve this answer

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.