Sum of near infinite series?

1 次查看(过去 30 天)
John Mitchell
John Mitchell 2019-10-22
评论: David Hill 2019-10-22

Having some trouble figuring out where to start with this problem:
Find the product of the first n (n=9999) terms of the following expression where n is an integer variable greater than one:
eq = 2/1 * 2/3 * 4/3 * 4/5 * 6/5 * 6/7 * 8/7 * 8/9 .... *n-1/n
Any help on figuring this out would be appreciated.

回答(2 个)

David Hill
David Hill 2019-10-22
p=[];
for i=1:2:n+1
p=[p,(n+1)/n,(n+1)/(n+2)];
end
P=prod(p(1:n));
  2 个评论
John Mitchell
John Mitchell 2019-10-22
Thank you for responding, but I forgot to mention that we can't use for loops in the problem, is there any way to do them without loops?
David Hill
David Hill 2019-10-22
a=2*[1:floor((n+1)/2);1:floor((n+1)/2)];
nu=a(:)';
d=[1,nu-1];
p=prod(nu(1:n)/d(1:n));

请先登录,再进行评论。


Stephan
Stephan 2019-10-22
Think about your row. You can rewrite it - always two elements are the same as n^2/(n^2-1).
With this knowledge read about cumprod. This should be enough to bring you to work the rest by yourself.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by