99 768
Assignments Done
98.5%
Successfully Done
In May 2021

# 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).
1
2015-06-01T01:46:45-0400
a) 1^2 + 2^2 + 3^2 +&middot; &middot; &middot;+ 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 &minus; 1/3 + 1/5 - 1/7 + 1/9 -&middot; &middot; &middot;-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) +&middot; &middot;&middot;
s=0;
k=1;
while (1/(k^2*(k+2)^2))&gt;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!