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

Réponses (2)

Star Strider
Star Strider le 30 Jan 2020

0 votes

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 commentaires

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
Star Strider
Star Strider le 30 Jan 2020
@Walter — Thank you for the additional cnditions!

Connectez-vous pour commenter.

Danielle Smith
Danielle Smith le 1 Fév 2020

0 votes

Thank you both very much!

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by