Product inside summation in Matlab

5 次查看(过去 30 天)
Irem Sara
Irem Sara 2022-2-22
评论: Torsten 2022-2-23
Hi, I am trying to code the below series in Matlab. To simplify, I am using a and b here, but essentially they are elemets of vectors.
I wrote it as:
I am not sure how to deal with the product inside the addition. Could anyone help me with how to code this? (a and b are not symbols so symprod would probably not work)

回答(2 个)

Torsten
Torsten 2022-2-22
编辑:Torsten 2022-2-22
The expression equals
a^(t+1) + b^(-t*(t+1)/2) * sum_{k=t+1}^{oo} a^(k+1)*b^(k*(k+1)/2)
This should be easy to code.
  5 个评论
Torsten
Torsten 2022-2-23
No, you didn't make a mistake, but
b^((4*t+6)/2) = b^(2*t+3) = b^(t+1)*b^(t+2)
Irem Sara
Irem Sara 2022-2-23
编辑:Irem Sara 2022-2-23
You are completely right, that's my bad! I got confused with the rules of exponents.
Just wondering, if a and b are non constant since they are the elements of a vector, is there a way to code that in? (I don't think I asked the initial question in the best way possible, sorry about the confusion!)
I guess a better way to write this is:

请先登录,再进行评论。


Torsten
Torsten 2022-2-23
编辑:Torsten 2022-2-23
For infinite vectors (a)_j and (b)_j and oo replaced by Kmax
t = 2;
Kmax = 50;
prod1 = a(t+1:Kmax).^(t+2:Kmax+1);
B = b(t+1:Kmax).^(t+1:Kmax);
prod2 = cumprod(B);
summands = prod1.*prod2;
expr = a(t)^(t+1) + sum(summands)
  2 个评论
Torsten
Torsten 2022-2-23
All in one line:
expr = a(t)^(t+1) + sum(a(t+1:Kmax).^(t+2:Kmax+1).*cumprod(b(t+1:Kmax).^(t+1:Kmax)))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by