How can I solve the following summation?

1 view (last 30 days)
David
David on 19 Dec 2013
Answered: Image Analyst on 23 Dec 2013
from 0 to infinity
0.5^(n+1)/(2n+1)!

Answers (3)

Walter Roberson
Walter Roberson on 19 Dec 2013
You use the Symbolic Toolbox, calling evalin() or feval() to use the toolbox's sum() command.
The answer is (1/4)*sqrt(2)*(exp((1/2)*sqrt(2))-exp(-(1/2)*sqrt(2))) which is also expressible as (1/2)*sqrt(2)*sinh((1/2)*sqrt(2))
For example,
syms n
feval(symengine, 'sum', 1/factorial(n), 'n = 0 .. infinity')

Roger Stafford
Roger Stafford on 19 Dec 2013
That's a convergent series, Kei Hin, but it would be a lot easier to evaluate sqrt(.5)*sinh(sqrt(.5)) which gives the same value.

Image Analyst
Image Analyst on 23 Dec 2013
kei: You for got to do the sum in your code. Try this:
numberOfTerms = str2double(cell2mat(inputdlg('Enter the last term number')))
sumOfTerms = 0;
whos numberOfTerms
for n = 0 : numberOfTerms
r = 0.5^(n+1)/factorial(2*n+1);
sumOfTerms = sumOfTerms + r;
fprintf('For term #%d, r = %.5f, and sumOfTerms = %.5f\n',...
n, r, sumOfTerms);
end

Tags

Community Treasure Hunt

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

Start Hunting!