MATLAB Answers

how to calculate Somme of vector elements ?

114 views (last 30 days)
diadalina
diadalina on 21 Oct 2018
Edited: Bruno Luong on 28 Oct 2018
i would like to calculate the somme k=1:10^5 of 1/k^2,using the command sum, can anyone help me ?

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 21 Oct 2018
Edited: madhan ravi on 21 Oct 2018
k=1:10.^5;
sum(1./(k.^2))

  6 Comments

Show 3 older comments
diadalina
diadalina on 28 Oct 2018
is there any method to verify the obtained result ?
Bruno Luong
Bruno Luong on 28 Oct 2018
"is there any method to verify the obtained result ?"
s = sum(1./(k.^2))
s / (pi^2/6)
That gives
s =
1.6449
ans =
1.0000
Seems alright to me.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!