필터 지우기
필터 지우기

How to compute the sum term ?

조회 수: 2 (최근 30일)
Yamina chbak
Yamina chbak 2021년 1월 21일
댓글: Yamina chbak 2021년 1월 22일
Hi, I hope you can help me in this problem :
Compute the sum term solution : which .
I don't need
% I have two solution U1 and U2
alpha = 0.6;
p = 0;
S = 0;
for n=2:50
p = p+1;
qnp=(n-p+1)^(1-alpha)-(n-p)^(1-alpha);
S = S+qnp*(U1-U2);
% Compute the new solution
U = 0.5*(U2+S);
% Overwrite the two solution
U1 = U2;
U2 = U;
end
% Resultat
U
The problem is
  • when n=2 then p=1, qnp=, and S = S+qnp*(U1-U2)=0+()*(U1-U2)= ()*(U1-U2)
It's Correct , then overwrite U1=U2 (i write it u2) and U2=U ( i write it u3)
  • When n=3 then p=2, qnp=, and S = S+qnp*(U1-U2) = ()*(U1-U2) + ()*(u2-u3).
It's not Correct because S = ()*(U1-U2) +()*(u2-u3) .
  • When n=4, then p=3 and the sum term is exactly : S = S+qnp*(U1-U2) = +qnp*(u3-u4)
which u3 and u4 has overwrited.
So, How can i compute the sum correctly ?
Thanks.

채택된 답변

David Hill
David Hill 2021년 1월 22일
alpha = 0.6;
U(1)=1;%you need to specify U(1) and U(2)
U(2)=.5;
S=2^(1-alpha)*(U(1)-U(2));
U(3)=(U(2)+S)/2;
for n=3:50
S=S+sum(((n-[1:n-1]+1).^(1-alpha)-(n-[2:n]).^(1-alpha)).*(U(1:n-1)-U(2:n)));
U(n+1) = (U(n)+S)/2;
end
  댓글 수: 1
Yamina chbak
Yamina chbak 2021년 1월 22일
Thanks @David Hill yes it's working you use index of the solution U(1),U(2),...U(n)
But it's possible to no use index and just overwrite the solution U1=U2, U2=U which U is the new solution ? if you say yes, Can you say me how ?

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by