How do I run an infinite series by creating a function?

 Accepted Answer

Only possible if you have symbolic toolbox
syms n
y = symsum(1/n^2, 1, inf);
Result
>> y
y =
pi^2/6
Otherwise you will need to numerical approximation using a finite number of elements
n = 1:10000;
y = sum(1./n.^2);
Result
>> y
y =
1.6448

3 Comments

thanks my friend and this serie : 1+(1/3^2)+(1/5^2)+...........+(1/n^2)+........ how?
by function?
function Y=serieinf(n) or what?
You can define the denominator like this
syms n
y = symsum(1/(2*n-1)^2, 1, inf);

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!