2
$\begingroup$

I have a loop that iterates a variable $i$ from 0 to some boundary $b$. Let $p=4i+4$. Each iteration of the loop I add $(p^3+5p)/3+2$ to a sum variable $s$ which is initially set to 0.

Question: Instead of this loop, how can I convert this all into a closed form expression that gives me the same $s$ based on the value of $b$?

1 Answers 1

3

In the end of the loop, if I understand correctly, you have: $\begin{align*}s&=\sum_{i=0}^b \left(\frac{(4i+4)^3+5(4i+4)}{3}+2\right)=\sum_{i=0}^b \left(4\frac{16i^3+48i^2+53i+21}{3}+2\right)\\&=\frac{64}{3}\sum_{i=0}^b i^3+64\sum_{i=0}^b i^2+\frac{212}{3}\sum_{i=0}^b i+30\sum_{i=0}^b 1 \end{align*}$ Using the formulas (which you can prove by induction, if you want): $\sum_{i=0}^b 1=b+1, \hspace{10pt} \sum_{i=0}^b i=\frac{b(b+1)}{2}, \hspace{10pt} \sum_{i=0}^b i^2=\frac{b(b+1)(2b+1)}{6}, \hspace{10pt} \sum_{i=0}^b i^3=\frac{b^2(b+1)^2}{4}$ You can get: $\begin{align*}s&=\frac{64}{3}\frac{b^2(b+1)^2}{4}+64\frac{b(b+1)(2b+1)}{6}+\frac{212}{3}\frac{b(b+1)}{2}+30(b+1)\\&=\frac{16}3 b^4+32 b^3+\frac{218}3 b^2+76 b+30=\frac23(b+1)(8 b^3+40 b^2+69 b+45)\end{align*}$

  • 0
    If $p=4i+1$, in the sum you will have $\frac13((4i+1)^3+5(4i+1))+2=\frac13(64i^3+48i^2+32i+6)+2=\frac13(64i^3+48i^2+32i+12)$, so your coefficients seem to be wrong. There is a $\frac13$ missing...2012-11-27