68 282
Assignments Done
99%
Successfully Done
In November 2018

Answer to Question #52410 in MatLAB | Mathematica | MathCAD | Maple for Steph

Question #52410
Write MATLAB programs to find the following sums with for loops and by vectorization. Time both versions in each case.
1^2 + 2^2 + 3^2 +· · ·+ 1000^2 (sum is 333,833,500).

1 − 1/3 + 1/5 - 1/7 + 1/9 -· · ·- 1/1003 (sum is 0.7849—converges slowly to π/4).

Sum the left-hand side of the series:
(1/1^2.3^2) + (1/3^2.5^2) + (1/5^2.7^2) +· · ·=(pi^2 - 8)/16 (sum is 0. 1169 − with 500 terms).
Expert's answer
Answer:
a) 1^2 + 2^2 + 3^2 +· · ·+ 1000^2
-by loop:
s=0;
for i=1:1000
    s=s+(i*i);
end
s
-by vector:
r=linspace(1,1000);
s=sum(r.*r)
b) 1 − 1/3 + 1/5 - 1/7 + 1/9 -· · ·-1/1003
by loop:
s=0;
p=1;
for i=1:2:1003   
    s=s+p/i;
    p=p*(-1);
end
s
c) (1/1^2.3^2) + (1/3^2.5^2) + (1/5^2.7^2) +· ··
s=0;
k=1;
while (1/(k^2*(k+2)^2))>eps
    s=s+1/(k^2*(k+2)^2);
    k=k+2;
end
s


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions