infinite series with loop in MATLAB
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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???
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.
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 "
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
