Computing the infinite sum

I would like to compute the sum of
(1/factorial(x))*(rho^x) between x = 1 and x = s-1
And the sum of
(1/factorial(s))*(s^(x-s))*(rho^(x)) between x = s and x = infinity
I have tried using the following:
r
ho = 2
s = linspace (2.1, 10,100)
x = 1:(s-1);
y = s:2E+6
sum1(s) = double(symsum((1/factorial(x))*(rho^x),x))
sum2(s) = double(symsum((1/factorial(s))*(s^(x-s))*(rho^(x)),y))
However get the error code
Undefined function 'symsum' for input arguments of type 'double'.
Error in aUntitled2 (line 5)
sum1(s) = double(symsum((1/factorial(x))*(rho^x),x))

回答(2 个)

It is likely best to initially leave out the numbers, then substitute them in later.
Try this:
syms rho s x y
sum1(s) = vpa(symsum((1/factorial(x))*(rho^x),x))
sum2(s) = vpa(symsum((1/factorial(s))*(s^(x-s))*(rho^(x)),y))
producing:
sum1(s) =
symsum(rho^x/factorial(x), x)
sum2(s) =
(rho^x*s^(x - 1.0*s)*y)/factorial(s)
So the first one does nothing, although the second appears to work. I leave you to do the substitutions using the subs function.

2 个评论

syms rho y
syms x s integer
assumeAlso(x>=1);
assumeAlso(s>=1);
sum1 = symsum(1/factorial(x)*(rho^x),x, 1, s-1)
sum2 = symsum(1/factorial(s)*s^(x-s)*rho^(x), x, s, inf)
for rho = 2 sum2 will be Inf
@Walter — Thank you for the additional cnditions!

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by