Can symsum Create a Matrix of Functions Using a Vector of Summation Limits?

1 次查看(过去 30 天)
Right now I've been using a for loop to write out functions because I can't figure out how to write them all using the same symsum command:
zi = 2.5;
syms k q
n=1:18;
f(q) = factorial(q)*zi.^(n+1)
B(k) = symsum(f(q)*(k*zi).^(n-q-0.5).*besselj(n-q+0.5,k*zi),q,0,n)
I want a vector of B(k) functions, one for each value of n, with the summation limit determined by n. I have a bunch of these functions to write, so doing them in a for 1:n loop is extremely slow. Any help will be greatly appreciated!

回答(1 个)

Walter Roberson
Walter Roberson 2013-1-25
编辑:Walter Roberson 2013-1-25
symsum() just might be vectorized over its first argument, what to sum, but I would be fairly sure it is not vectorized over a list of upper bounds.
I ran the expression through a number of potential transformations, and found no useful transforms for this situation.
Interestingly, up to n=9, the results look like they are building up a useful pattern, but from n=10 onward, the analytic results come out in terms of besselj() calls that are not easily expressed as simple constants; and as n increases, more and more besselj() terms get added in to the mess.
I think you are going to end up looping just the way you do now.
[Addendum]
When I tried transforms on the result for specific n, I had some success in Maple, first with convert/elementary and then much better, with convert/Elliptic_related . The elliptic analysis produced the same structure of result for each n, with different coefficients. Potentially with sufficient analysis the expression for the coefficients could be derived.
Up to n=18, the results were:
[-(1/4)*2^(1/2)*(25*cos(25/2)-4*sin(25/2))/Pi^(1/2),
-(5/16)*2^(1/2)*(601*sin(25/2)+200*cos(25/2))/Pi^(1/2),
(25/64)*2^(1/2)*(13625*cos(25/2)-8542*sin(25/2))/Pi^(1/2),
(125/256)*2^(1/2)*(260621*sin(25/2)+317350*cos(25/2))/Pi^(1/2),
-(625/1024)*2^(1/2)*(2901925*cos(25/2)-10124744*sin(25/2))/Pi^(1/2),
-(3125/4096)*2^(1/2)*(-58400203*sin(25/2)+265278100*cos(25/2))/Pi^(1/2),
-(78125/16384)*2^(1/2)*(1015996175*cos(25/2)+979451282*sin(25/2))/Pi^(1/2),
(32421875/65536)*2^(1/2)*(-444369281*sin(25/2)+37312550*cos(25/2))/Pi^(1/2),
(1953125/262144)*2^(1/2)*(750818666075*cos(25/2)-635481183124*sin(25/2))/Pi^(1/2),
(9765625/1048576)*2^(1/2)*(26639137973200*cos(25/2)-769031287741*sin(25/2))/Pi^(1/2),
(48828125/4194304)*2^(1/2)*(644049903002525*cos(25/2)+371964128328578*sin(25/2))/Pi^(1/2),
(8544921875/16777216)*2^(1/2)*(363812095059250*cos(25/2)+504143138559227*sin(25/2))/Pi^(1/2),
(152587890625/67108864)*2^(1/2)*(1819806922548547*cos(25/2)+5178280343225296*sin(25/2))/Pi^(1/2),
(30517578125/268435456)*2^(1/2)*(835854617746266100*cos(25/2)+4754359151282421419*sin(25/2))/Pi^(1/2),
(152587890625/1073741824)*2^(1/2)*(19476608985999283925*cos(25/2)+193620992439805397246*sin(25/2))/Pi^(1/2),
(762939453125/4294967296)*2^(1/2)*(674265625341945660850*cos(25/2)+8987193058841489688977*sin(25/2))/Pi^(1/2),
(19073486328125/17179869184)*2^(1/2)*(6417929201021471562475*cos(25/2)+94058741322934234202548*sin(25/2))/Pi^(1/2),
(95367431640625/68719476736)*2^(1/2)*(363528164903755375039000*cos(25/2)+5443917848856746781665411*sin(25/2))/Pi^(1/2)]

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by