Problem with steps, limits and symbolic variable

Hello. I'm trying to calculate this limit with matlab.
I wrote this function, and it works just fine if I do something like f(3)
f = @(x) (sum([1:2:2*x-1]))/(3*x^2);
However, trying to calculate limit yields an error "Unable to compute number of steps from 1 to 2*n - 1 by 2".
limit(f(x), x, 5)
I googled a little, and I think I understand why this happens, but I don't know how I can fix it.
Can someone help?

 採用された回答

John D'Errico
John D'Errico 2020 年 12 月 13 日
編集済み: John D'Errico 2020 年 12 月 13 日

0 投票

Use symsum.
syms n
limit(symsum(2*n-1,0,n)/(3*n^2),inf)
ans = 
As you can see, I used symsum to compute the sum. Then divide by (3*n^2), and take the limit, as n-->inf.
If you wanted to do this without the symbolic toolbox, well then you need to be able to take limits and infintie sums on double precision vectors. This really is something that is best done using symbolic tools. So without those tools, I would do exactly the same thing, but now the work must be done using pencil and paper, because you really do want to work with limits.
If I go back, and read some of your comments, I see your problem arises because you are trying to use the function limit on a colon operator. MATLAB cannot do that. Instead, you really need to compute that sum in some symbolic form, thus best done with symsum.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 12 月 12 日

0 投票

Consider the sum term alone and find what it is for n=4. Now find it for n=5. And now for n=6. Do you see a pattern? Evaluate the full expression for those values; what do you observe? How many terms do you estimate it would take before any asymptope would be effectively negligible?

1 件のコメント

Egor Svito
Egor Svito 2020 年 12 月 13 日
I'm well aware that this sum is basically n^2. But the question isn't about solving this particular limit, but rather about the problem with exactly the sum - that I don't know how to do it via matlab.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

タグ

質問済み:

2020 年 12 月 12 日

コメント済み:

2020 年 12 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by