Summation with upper limit itself as a variable
31 ビュー (過去 30 日間)
古いコメントを表示
i m trying to optimize the following function
z=-(r)*(L/M)*(1-(((L/M).^x(1))/((gamma(x(1)+1))*symsum(((L/M).^p)/(gamma(p+1)),p,0,x(1)))))+c*x(1);
with
syms p
r=2;
L=10;
M=2;
c=1;
and getting the following error
??? Error using ==> mupadmex
Error in MuPAD command: Illegal range [sum::sum]
can anybody help me how can i set the upper limit as variable in summation??
6 件のコメント
Walter Roberson
2013 年 5 月 19 日
The code you show never has "x" as a symbolic variable, so your upper bound is always numeric. I need to see the version of the code that has the error.
回答 (2 件)
Roger Stafford
2013 年 5 月 20 日
編集済み: Roger Stafford
2013 年 5 月 20 日
In the expression
symsum((L/M)^p/gamma(p+1),p,0,n)
for p an integer ranging from 0 to n it is the sum of the first n+1 terms in the infinite power series expansion for the exponential function exp(L/M). It is extremely doubtful that there exists any known "closed form" for this finite summation in terms of a general n. In integral calculus, there are some integrals for which there are known closed forms (which one can usually find listed in integral tables) but many more for which none are known. In an analogous way there are finite summations for which there are known closed forms such as
symsum(p^2,p,1,n) = n*(n+1)*(2*n+1)/6
and many more for which none are known. As I say, it is very likely the summation you describe belongs to that latter category. One should therefore not blame Mupad for not finding it.
1 件のコメント
Walter Roberson
2013 年 5 月 20 日
Correct, but MuPAD would not return an error about invalid range for that case. MuPAD would create an unevaluted sum() expression (which might get converted to symsum() at the MATLAB level)
Amir
2013 年 5 月 20 日
2 件のコメント
Roger Stafford
2013 年 5 月 20 日
The issue, Amir, is that (presumably) no-one has yet found out how to express your sum as a compact general formula in terms of an unlimited variable x except by using the type of "symsum" or "sum" notation you already have here, and therefore our computers are also unable to do so. With your limit of 100 it would be possible to do the equivalent of listing all one hundred possibilities, but that is surely not what you are looking for.
Walter Roberson
2013 年 5 月 20 日
The error you reported earlier has to do with the bounds being invalid, but you have not yet shown us a code example in which the code using a variable as the upper bound.
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!