필터 지우기
필터 지우기

infinite loop and the term within loop again contains infinity

조회 수: 2 (최근 30일)
math seeker
math seeker 2018년 5월 27일
댓글: Walter Roberson 2018년 5월 28일
I want to solve a loop given below
prev_val=0;
for m=0:inf
curr_val=(beta/(2*m+1)*pi)*sin((2*m+1)*pi/beta)*exp((2*m+1)^2)*alpha;
prev_val=prev_val+curr_val;
endfor
gt=const*prev_val;
I am facing two problems with this. In this, the upper limit of the loop, as per the equation to be solved, is infinity. In addition, the value of beta is again infinity. How can I solve this problem?
  댓글 수: 5
math seeker
math seeker 2018년 5월 28일
I mean beta is a constant and its value is infinity.
Walter Roberson
Walter Roberson 2018년 5월 28일
In that case, as I posted, the sum over m is sign(alpha) times infinity

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

답변 (2개)

Rik
Rik 2018년 5월 27일
I found an answer to your question on stackoverflow: if you don't have the symbolic toolbox, quadgk can still solve your integral.
f = @(x) x.*exp(-x);
a = quadgk(f, 0, inf)
a =
1.0000
How you can deal with beta being infinity is something I don't have any ideas for. Maybe you can try with just a big number, maybe enlarging it in a while loop to simulate the limit function.
f=@(m) (beta/(2*m+1)*pi)*sin((2*m+1)*pi/beta)*exp((2*m+1)^2)*alpha;
  댓글 수: 1
Ameer Hamza
Ameer Hamza 2018년 5월 27일
You can also use integral(). The function name integral() appears to be more intuitive as compared to quadgk() as himself mentioned by Mathwork cofounder.

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


Walter Roberson
Walter Roberson 2018년 5월 27일
For the case of limit as beta approaches infinity, then under the assumption that m is a non-negative integer, the individual terms are
Pi^2*exp(4*m^2+4*m+1)*alpha
The sum of this over m = 0 to infinity is sign(alpha) * infinity

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by