please help me with this calculus question

this is the question:
Consider the sum A inferred by the following:
A = 1 -1/4 + 1/9 - 1/16 + 1/25...
If the 1st term is t1 = 1 and the 2nd term is t2 = -1/4, use MATLAB to determine the sum
of terms at the 57th term (i.e. including the 57th term). Give answer to 4 decimal places. Also, provide MATLAB code.
this is my Matlab code but its not giving me the answer i expect. please help me with this. thank you
syms n x
F(x)=symsum((-1)^(n-1)/n^2,n,1,57)

댓글 수: 1

Matt J
Matt J 2021년 10월 9일
편집: Matt J 2021년 10월 9일
We don't know what you expect. The result that I get doesn't surprise me.

댓글을 달려면 로그인하십시오.

답변 (1개)

David Hill
David Hill 2021년 10월 9일
편집: David Hill 2021년 10월 9일

0 개 추천

No reason to use symbolics.
round(sum((-1).^(2:58)./(1:57).^2),4);

댓글 수: 4

Should be,
round(sum((-1).^(0:56)./(1:57).^2),4)
why am i getting this error when i run your code
Invalid call to round. Correct usage is:
-- round (X)
David Hill
David Hill 2021년 10월 9일
Did you copy and past it into your command line? The above code works.
See the documentation section on Compatibility Considerations. (It always helps to use the Release window to post the release being used.)
It is easy to emulate the version introduced in R2014b
roundn = @(x,n) round(x .* 10.^n)./10.^n;
.

댓글을 달려면 로그인하십시오.

카테고리

제품

질문:

2021년 10월 9일

댓글:

2021년 10월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by