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))

Answers (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 Comments

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!

Sign in to comment.

Danielle Smith
Danielle Smith on 1 Feb 2020
Thank you both very much!

Asked:

on 30 Jan 2020

Commented:

on 1 Feb 2020

Community Treasure Hunt

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

Start Hunting!