hi guys ,I am try to solve numerical question.I try to finish my loop till when I get result less then error which I want(10^-12).Why I get NAN values.Thanks.

댓글 수: 2

Are you sure your formula is correct? The terms diverge:
for n = 0:50
term(n+1) = ((((-1)^n)*(pi/3)^(2*n+1))/(2*n+1));
end
h = plot(term,'.-');
set(h,'MarkerSize',14)
It's an alternating series, so it could still converge, but will be slow. But I also looked at the sum of pairs of terms, and those look to diverge as well. (Admittedly, it has been long while since I have thought about series convergence.)
Where did you get the formula from?
emre arat
emre arat 2021년 5월 5일
thanks sir.I forgot to answer your reply.There is mistake in question information.

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

답변 (1개)

DGM
DGM 2021년 4월 22일

0 개 추천

Let's see. By iteration #7694, you're calculating
(pi/3)^15389
Your result is going to end up infinite shortly. Once that happens, you end up trying to calculate
Inf - Inf
which is undefined, i.e. NaN.

댓글 수: 1

emre arat
emre arat 2021년 5월 5일
thanks.I understood what you meant.Have nice day.Sorry for late answer.

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

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2021년 4월 22일

댓글:

2021년 5월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by