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.

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
1  
Have a look at NestList. –  b.gatessucks Jun 24 at 8:42
add comment

2 Answers 2

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 at 9:05
    
sorry mistake was on my part (typo) –  eldo Jun 24 at 10:50
add comment

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
add comment

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.