Problem in summation with floor function

I would like to compute the summation involving ''floor function'' as the limit of the sum. Below I have the code. But when I run that some error is apparing which is beyond my understanding. Please somebody help me to solve that issue.
" Error using symengine
Nonnegative integer or a symbol expected.
Error in sym/symsum (line 70)
rSym = mupadmex('symobj::map',fsym.s,'symobj::symsum',x.s,a.s,b.s);
Error in floorfu (line 43)
s23p=symsum(symsum(ss3p.*s2p,l,0,m),k,0,n);"
clc;
syms theta k l p q
W=1.0;
g=0.0001;
lm=0.1;
assume(k>=0);
assume(l>=0);
assume(p>=0);
assume(q>=0);
n=6;
m=6;
t1=floor((k+1)./2); %%%%%%%%%%%%% Floor fun
t2=floor(l./2);
theta=pi./3;
om=sqrt(((W).^2)-(4.*(g.^2)));
mu=sqrt((W+om)./(2.*om));
nu=((W-om)./(2.*g)).*mu;
eta=(((lm)./((2.*g)+W)).*(1+((W-om)./(2.*g)))).*mu;
tau= mu + nu.*cos(2.*theta);
d=k+l-2.*p-2.*q-2;
ag= eta.*cos(theta)./(sqrt(mu.*tau));
s1p=(mu./tau).*((-1).^m).*((1i)^(m+n)).*(2.*eta.*(mu-nu)./(sqrt(2.*mu.*nu))).^(m+n);
s2p=(((nu./2.*eta).*sqrt(mu.*tau)./(mu-nu)).^(k+l)).*factorial(k).*factorial(l).*nchoosek(n,k).*nchoosek(m,l).*exp(1i.*theta.*(k-l));
s3p= ((2./nu.*tau).^(p+q)).*factorial(2.*p + 2.*q +1 -k -l)./(factorial(p).*factorial(q)).*nchoosek(p,k-p).*nchoosek(q,l-q).*exp(-2.*1i.*theta.*(p-q)).*hermiteH(d,ag);
ss3p=symsum(symsum(s3p,q,t2,m),p,t1,n); %%%%%%%%% Actually in this line that error is coming
s23p=symsum(symsum(ss3p.*s2p,l,0,m),k,0,n);
sumout=s1p.*s23p

댓글 수: 8

Ameer Hamza
Ameer Hamza 2020년 6월 23일
Can you show your equations in mathematical form?
AVM
AVM 2020년 6월 23일
Thanks for your reply. Here the math. Equation in written form as an attachment.
AVM
AVM 2020년 6월 24일
@Ameer: Is there any way to solve that error? Please let me know.
Ameer Hamza
Ameer Hamza 2020년 6월 24일
The equations are quite complex, to it is difficult to see where the error is happening. However, I suggest you use floating-point math in this case instead of symbolic equations. Try creating a vector with all the terms and then use sum() function.
AVM
AVM 2020년 6월 24일
Thanks for your information. But how to use floating-point math ? Pl show me the corresponding command for that with an example.
AVM
AVM 2020년 6월 24일
So,in this case shall I have to convert the entire equation in ''matlabFunction''?
For example, if you have a summation like this
following shows how to use symbolic toolbox or the sum() function using floating-point numbers
syms k
n = 10;
y = k^2*sin(k);
y1 = double(symsum(y, k, 1, n));
kv = 1:n;
y2 = sum(kv.^2.*sin(kv));
AVM
AVM 2020년 6월 24일
편집: AVM 2020년 6월 24일
Thanks for your reply. Okay, with this I must try.

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

답변 (0개)

카테고리

질문:

AVM
2020년 6월 23일

편집:

AVM
2020년 6월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by