# please help me, how do I make the code for the equation in the following picture?

2 views (last 30 days)
Muhammad Rohim on 17 Apr 2020
Commented: Ameer Hamza on 21 Apr 2020

Tommy on 17 Apr 2020
If you have the symbolic math toolbox:
syms n;
double(symsum(sin(2*n)/n^2,1,inf))
Muhammad Rohim on 17 Apr 2020
Thanks
darova on 17 Apr 2020
You can use 200 percent scale for the picture if you want

Peter on 17 Apr 2020
You can't code an infinite sum exactly, but fortunately, this one is bounded (x^2 on the denominator and the numerator is bounded between -1 and 1).
Pick a big n:
n_max=100;
ns = 1:n_max;
sum_n = cumsum( sin(2*ns)./ns.^2);
plot(ns, sum_n)
You will see it very quickly converges, after 20 terms or so.

Show 2 older comments
Peter on 17 Apr 2020
Muhammed,
I'm not sure. I copied the code block directly from the response to check and it seemed to run in the command line without a problem. Generally you get that error if there is an unclosed parenthesis in an expression: each '(' gets a ')'. If you typed it manually, perhaps double-check your entry? The space between the opening parenthesis of the cumsum function and the sin function can also be removed, although that shouldn't make a difference.
Muhammad Rohim on 17 Apr 2020
Thank you very much. It ia work.
Ameer Hamza on 21 Apr 2020
"You can't code an infinite sum exactly"
Peter, I think you meant the opposite.

### Tags

No tags entered yet.

R2013a

Translated by