How can I solve the following summation?

Answers (3)

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

Asked:

on 19 Dec 2013

Answered:

on 23 Dec 2013

Community Treasure Hunt

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

Start Hunting!