Please help me write this summation in MATLAB

I am trying to write this double summation in MATLAB. However, I am not getting the correct. Please help me write this.
Please note that the upper limit in the second summation is the floor function.

7 件のコメント

Dyuman Joshi
Dyuman Joshi 2023 年 1 月 1 日
What have you tried yet? Please show your code.
Manotosh Kumbhakar
Manotosh Kumbhakar 2023 年 1 月 1 日
編集済み: Manotosh Kumbhakar 2023 年 1 月 1 日
Hi Dyuman Joshi, I have now done it using symsum in MATLAB. Earlier I was using for loop. However I observed that there is 'symsum' available in MATLAB, which can easily handle such summation notation. For this case, I have written the code as follows and it's now working well!
syms k x n
n_term=50;
f=symsum(((((-1)^(k-1))*(x)^k)/(factorial(k)*2^(k-1)))*symsum(1/(1+(2*n)),n,0,floor((k-1)/2)),k,1,n_term)
f = 
Torsten
Torsten 2023 年 1 月 1 日
Manotosh Kumbhakar
Manotosh Kumbhakar 2023 年 1 月 1 日
Sorry. That was a typo. It should be (x^k). I will edit it.
Walter Roberson
Walter Roberson 2023 年 1 月 1 日
When I tested the inner symsum early this morning, I found that it gave the wrong results when the upper bound uses floor. I will write this up later today.
Torsten
Torsten 2023 年 1 月 1 日
So the floor function cannot be used in symbolic summation ?
Walter Roberson
Walter Roberson 2023 年 1 月 1 日
False alarm. I was working on my phone in MATLAB Mobile in the early hours of the morning, and did not notice that in one case I was using 1/(2*k+1) but in another case I was using 1/(2*k-1)

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

 採用された回答

Walter Roberson
Walter Roberson 2023 年 1 月 1 日
編集済み: Walter Roberson 2023 年 1 月 1 日

1 投票

n_term = 50/2;
syms n N k integer
syms x
inner = symsum(1/(2*k+1), k, 0, floor((n-1)/2))
inner = 
outer = (-1)^(n-1)*x^n/factorial(n)/2^(n-1) * inner
outer = 
outer_even = simplify(subs(outer, n, 2*N))
outer_even = 
outer_odd = simplify(subs(outer, n, 2*N+1))
outer_odd = 
sum_even = symsum(outer_even, N, 1, n_term)
sum_even = 
sum_odd = symsum(outer_odd, N, 1, n_term)
sum_odd = 
result = simplify(sum_even + sum_odd)
result = 
result_unsplit = symsum(outer, n, 1, n_term*2)
result_unsplit = 
Hmmm... the difference between the two is that the split version has one extra term, the x^51 term. I am not going to bother to chase that down.
result_unsplit = symsum(outer, n, 1, inf)
result_unsplit = 

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by