Calculaing the table of values for function defined as an infinie series
显示 更早的评论
I need this code below to caluate the sum of the first 50 terms of the series :t to the power n for t value. That is, a kind of table of values for the series for t=1:10 It gives the error message: ??? Error using ==> power Matrix dimensions must agree. Please someone help % Calculating the sum of an infinite series
t =1:10;
n=0:50;
E(1,:)= sum(t.^n)
采纳的回答
更多回答(1 个)
Roger Stafford
2014-7-19
Also you can use this:
E = sum(bsxfun(@power,1:10,(0:50)'),1);
4 个评论
Chuzymatics Chuzymatics
2014-7-20
Roger Stafford
2014-7-20
It should be noted that these are what are known in algebra as geometric series, and, except for the case t = 1, their sum can be computed by a simpler method which does not require summation of all 51 terms:
N = 50;
t = 2:10;
E(t) = (t.^(N+1)-1)./(t-1);
E(1) = N+1;
For example, E(2) = (2^51-1)/(2-1) = 2251799813685247.
Roger Stafford
2014-7-20
编辑:Roger Stafford
2014-7-20
A Side Note: The value of your E(10) would be 1111...11, a string of fifty-one 1's in decimal, if it were computed exactly. This reminds me of one of the Fifty-Eighth Putnam Exam questions which posed the intriguing problem: "Let N be the positive integer with 1998 decimal digits, all of them 1; that is, N = 1111...11. Find the thousandth digit after the decimal point of the square root of N." (Surprisingly, it is solvable without using a computer.)
Chuzymatics Chuzymatics
2014-7-21
类别
在 帮助中心 和 File Exchange 中查找有关 Time Series Events 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
