Symbolic nested summations with empty indexes

조회 수: 1 (최근 30일)
Francesco Piccioli
Francesco Piccioli 2021년 1월 21일
답변: Tushar Behera 2022년 10월 4일
Hello.
I have a problem using nested symbolic summations when the symbolic engine finds no valid sum indexes.
Specifically, I am trying solving the following problem:
I want to calculate a nested summation that looks something like the following:
Where .
I have defined symbolic integer variables d, T, T1, c1, c2 and a symbolic function c20(T1,c1).
Then I use the following code to calculate the sum:
S(d,T) = symsum(...
symsum(...
symsum(1,...
c2,c20(c1,T1,T),d-1),...
c1,T1,d-1),...
T1,1,T-1)
At another point in the code I assign a numeric value to T and d and try to convert everything to double:
DoubleVal = double(subs(S(Tval,dval)));
Now, for Tval = 1 the summation is supposed to be zero. However I think that the symbolic engine is trying to assign a NaN value to T1 which causes an error in the nested sum, as c1 cannot be NaN. As a result instead of getting DoubleVal = 0 I get an "inconsistent assumptions" error. The same thing happens when d is too small wrt T.
How can I force matlab to assign zero as the result of a summation in which there are no available indexes?
Thank you very much

답변 (1개)

Tushar Behera
Tushar Behera 2022년 10월 4일
Hi Francesco Piccioli,
I believe you want to implement
Where
The code written by you seems fine however I noticed that you have exchanged the positions of d” and “T” variable while calculating sum S(Tval,dval). In addition to that whenTval” is 0 the upper limit is lower than the lower limit.
Regarding the error that you are encountering, this is a known issue which was fixed in MATLAB R2021a.
From R2021a onwards, the symsum function will return 0, when lower limit is greater than the upper limit.
Thanks and regards,
Tushar Behera

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by