Symbolic nested summations with empty indexes

2 views (last 30 days)
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

Answers (1)

Tushar Behera
Tushar Behera on 4 Oct 2022
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

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!