how do i solve this summation ?

2 ビュー (過去 30 日間)
Osman Ballhysa
Osman Ballhysa 2021 年 6 月 3 日
回答済み: Walter Roberson 2021 年 6 月 3 日
how can i solve this summation ? everybody here on the community seems to hate symsum, so what´s the alternative . Please help

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 3 日
People here do not hate symsum(), but many people try to use symsum() for things it was not intended for.
syms x i n
y = symsum((-1)^i * x^(2*i+1)/factorial(2*i+1), i, 0, n)
y = 
See, it worked fine. It just doesn't tell you anything useful because MATLAB does not happen to recognize the pattern as matching any special function.
y20 = subs(y, n, 20)
y20 = 
fplot(y20, [-3 3])
subs(y, n, inf)
ans = 
... it did not recognize the pattern because it was truncated. You can see that if you let n approach infinity then symsum() recognizes the pattern.
A lot of people try to use symsum() to do indexing, like symsum(x(i)^2/factorial(i), i, 1, 10) but you can never index with a symbolic variable so symsum cannot do that.
symsum() should mostly be reserved for finding formulas, the way that with inf it was able to find the sin() formula. In cases where you are using it to add a bunch of terms, a finite number of them, then most often it is better to construct the sequence of terms and sum() them.

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 3 日
Use of loop: [for .. end] and [while ... end]. If the numbers get large and accuracy is a concern to use: vpa()
  1 件のコメント
Osman Ballhysa
Osman Ballhysa 2021 年 6 月 3 日
can you make a concrete example with the exercise above , i´m struggling a lot to solve it

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by