infinite series with loop in MATLAB
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
how can find F in matlab , where the initial value of z =1
and i is loop from
i=1:10
thanks so much for any help.need code of program if possible

2 件のコメント
David Hill
2021 年 1 月 22 日
It is unclear what z array is (from i=1:10) and how i changes in the equation. Should there be another summation on the outside changing i from 1:10?
thank you for your reply
yes .to chang z
there must summation for i=1:10 ,with initial value to z=1
and another summation k=1:infinity .....for series
採用された回答
Walter Roberson
2021 年 1 月 22 日
syms z I k real
F = symsum((-z*I)^k/(k*factorial(k)), k, 1, inf)
F = 

However, examine the behavior when k = 0, the lower bound from the equation. The denominator is k*k! which would be 0 * 0! which would be 0*1 which would be 0. So we have a potential problem with singularities, and need to look at the limit. For non-zero z and i, (-z*i)^0 would be 1. Thus we are looking at 1/0 and that is infinite. As that is a term that is included in the actual sum (k = 0 to infinity) we must conclude that F is infinite except for the case where z or i are 0.
12 件のコメント
hasan s
2021 年 1 月 22 日
thanks for reply
I want loop to evaluate or change z(i) , by using "for i=1:10 ....end" ,with initial value z=1
and summation k=1:infinity .....for series.
is that possible in matlab???
Walter Roberson
2021 年 1 月 22 日
syms z I k real
F = symsum((-z*I)^k/(k*factorial(k)), k, 1, inf)
F = 

Fsum = sym(0);
for i = 1 : 10
Fsum = Fsum + subs(F, I, i);
end
Fsum1 = subs(Fsum, z, 1)
Fsum1 = 

vpa(Fsum1)
ans = 
fplot(Fsum, [1 10])

Fvals = zeros(10,1,'sym');
for i = 1 : 10
Fvals(i) = symsum((-z*i)^k/(k*factorial(k)), k, 1, inf);
end
fplot(Fvals(1:3), [1 10]); legend({'i=1', 'i=2', 'i=3'})

hasan s
2021 年 1 月 22 日
thanks a lot
but in my question z(i) , not z*i
Do I just change it and the program remains correct???
Walter Roberson
2021 年 1 月 22 日
No, your question is z*i not z subscript i.
- Your equation has subscripted k=0 on the summation, so if subscripting was intended on the z then it could have been done
- Your equation has k(k!) and there is no way you could possibly index scalar k at location factorial(k) . Therefore in your equation A(B) indicates A multiplied by B.
Walter Roberson
2021 年 1 月 22 日
syms k real
Z = sym('z', [1 10]);
assume(Z, 'real')
Z(1) = 1;
F = sym(0);
for i = 1 : 10
F = F + symsum((-Z(i))^k/(k*factorial(k)), k, 1, inf);
end
F
F = 

If the z values are fixed, the way that
is fixed, then this would be a scalar outcome that you would not be able to plot.
thank you very much for all your reply
yes I need the last program when the values of z are fixed numbers.I need the output of this series to be Known value
when I run the last program the output is
F =
- z2*hypergeom([1, 1], [2, 2], -z2) - z3*hypergeom([1, 1], [2, 2], -z3) - z4*hypergeom([1, 1], [2, 2], -z4) - z5*hypergeom([1, 1], [2, 2], -z5) - z6*hypergeom([1, 1], [2, 2], -z6) - z7*hypergeom([1, 1], [2, 2], -z7) - z8*hypergeom([1, 1], [2, 2], -z8) - z9*hypergeom([1, 1], [2, 2], -z9) - z10*hypergeom([1, 1], [2, 2], -z10) - hypergeom([1, 1], [2, 2], -1)
if possible ...
what is meaning "hypergeom "
Walter Roberson
2021 年 1 月 22 日
Replace
Z = sym('z', [1 10]);
assume(Z, 'real')
Z(1) = 1;
with assigning specific values to Z(1:10)
hypergeom is described at https://www.mathworks.com/help/symbolic/hypergeom.html#bt1nkmw-2 . It is a standardized infinite series rather than a closed form solution in itself. MATLAB knows how to reason about the standardized function, such as knowing how to take a derivative.
syms z
f = hypergeom([1, 1], [2, 2], -z)
f = 

diff(f,z)
ans =

Standardized infinite series are common in mathematics; for example sin(x) is a standardized infinite series.
hasan s
2021 年 1 月 22 日
Is it possible to add a condition to the program so that the output does not contain hypergeom???
I need the output are real values
Walter Roberson
2021 年 1 月 22 日
As usual, you can double() the result, provided that all of the z have been given specific numeric values.
hasan s
2021 年 1 月 22 日
ok I will give z specific numeric values. but excuse me, if possible , what mean double() the result?? what I change in program??
Walter Roberson
2021 年 1 月 22 日
編集済み: Walter Roberson
2021 年 1 月 22 日
format long g
z = [1, rand(1,9)];
syms k real
F = sym(0);
for i = 1 : 10
F = F + symsum((-z(i))^k/(k*factorial(k)), k, 1, inf);
end
F
F =

result = double(F)
result =
-4.34857820351754
hasan s
2021 年 1 月 22 日
Thank you very much
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
