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 commentaires

Ameer Hamza
Ameer Hamza le 23 Juin 2020
Can you show your equations in mathematical form?
AVM
AVM le 23 Juin 2020
Thanks for your reply. Here the math. Equation in written form as an attachment.
AVM
AVM le 24 Juin 2020
@Ameer: Is there any way to solve that error? Please let me know.
Ameer Hamza
Ameer Hamza le 24 Juin 2020
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 le 24 Juin 2020
Thanks for your information. But how to use floating-point math ? Pl show me the corresponding command for that with an example.
AVM
AVM le 24 Juin 2020
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 le 24 Juin 2020
Modifié(e) : AVM le 24 Juin 2020
Thanks for your reply. Okay, with this I must try.

Connectez-vous pour commenter.

Réponses (0)

Question posée :

AVM
le 23 Juin 2020

Modifié(e) :

AVM
le 24 Juin 2020

Community Treasure Hunt

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

Start Hunting!

Translated by