ratio using for loops

Dear All,
I would like to calculate this and find out s^*. How can I calculate it using loop. I think reindexing doesn't help, since boundaries are different.
Thank you very much,
I tried in this way, but it doesn't work.
sum_x_s_ast_2 = 0;
sum_y_s_ast_2 = 0;
for n=((s_asterisk+1):1:(T-1))
sum_x_s_asterisk_2=sum_x_s_ast_2+x_2^n;
sum_y_s_asterisk_2=sum_y_s_ast_2+y_2^n;
ratio_1(n+1)=(sum_x_s_ast_2/sum_y_s_ast_2)*epsilon_2^(s_asterisk);
end
sum_x_s_ast_1 = 0;
sum_y_s_ast_1 = 0;
for l=(0:1:s_asterisk)
sum_x_s_ast_1=sum_x_s_ast_1+x_1^l;
sum_y_s_ast_1=sum_y_s_ast_1+y_1^l;
ratio_2(l+1)=(sum_x_s_ast_1/(sum_y_s_ast_1+K^(1/gamma)*x_1^T))*epsilon_1^(s_asterisk);
end
z=ratio_1(n+1)/ratio_2(l+1);

4 个评论

It helps to make assumptions. Like if can be negative, that can change the calculation a log
syms s s__ast T integer
assumeAlso(s__ast >= 0)
assumeAlso(T - 1 >= s__ast + 1)
syms x_2 y_2 real
syms eta_2
part1 = symsum(y_2^s, s, s__ast + 1, T - 1)
part1 = 
part2 = symsum(x_2^s, s, s__ast + 1, T - 1)
part2 = 
part3 = simplify(part1 / part2 * eta_2^s__ast)
part3 = 
Raushan
Raushan 2023-10-19
编辑:Raushan 2023-10-19
Thank you for your answer. However, I didn't get your answer. Is there any other way to do that?
syms s s__ast T integer
assumeAlso(s__ast >= 0)
assumeAlso(T - 1 >= s__ast + 1)
syms x_2 y_2 real
syms epsilon_2
part1 = symsum(y_2^s, s, s__ast + 1, T - 1)
part1 = 
part2 = symsum(x_2^s, s, s__ast + 1, T - 1)
part2 = 
part3 = simplify(part1 / part2 * epsilon_2^s__ast)
part3 = 
This shows you how to construct the numerator for the expression. You follow similar steps to create the denominator for the expression.
Then you consider the expression P/Q >= 1 and multiply both sides by Q to get P >= Q . Subtract Q from both sides and you get P - Q >= 0 . Now you can solve() or vpasolve()
Can you do better than that? Maybe. But it would requiire assumptions that we as outside observers are not permitted to make. As onlookers, we do not know whether the values involved are real-valued or complex-valued. If or are negative then we would want to know whether their absolute values are greater less than 1 . For that matter, we would also want to know about the absolute values of those variables even if the variables are positive in order to be able to reason about convergence.

请先登录,再进行评论。

回答(0 个)

类别

标签

提问:

2023-10-19

Community Treasure Hunt

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

Start Hunting!

Translated by