Problem in summation with floor function
Afficher commentaires plus anciens
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
le 23 Juin 2020
Can you show your equations in mathematical form?
AVM
le 23 Juin 2020
AVM
le 24 Juin 2020
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
le 24 Juin 2020
AVM
le 24 Juin 2020
Ameer Hamza
le 24 Juin 2020
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));
Réponses (0)
Catégories
En savoir plus sur Numbers and Precision dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!