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 commentaires

David Hill
David Hill le 22 Jan 2021
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?
hasan s
hasan s le 22 Jan 2021
Modifié(e) : hasan s le 22 Jan 2021
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

Connectez-vous pour commenter.

 Réponse acceptée

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 commentaires

hasan s
hasan s le 22 Jan 2021
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
hasan s le 22 Jan 2021
thanks a lot
but in my question z(i) , not z*i
Do I just change it and the program remains correct???
Walter Roberson
Walter Roberson le 22 Jan 2021
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.
hasan s
hasan s le 22 Jan 2021
Modifié(e) : hasan s le 22 Jan 2021
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
hasan s le 22 Jan 2021
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
Walter Roberson le 22 Jan 2021
As usual, you can double() the result, provided that all of the z have been given specific numeric values.
hasan s
hasan s le 22 Jan 2021
ok I will give z specific numeric values. but excuse me, if possible , what mean double() the result?? what I change in program??
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
hasan s le 22 Jan 2021
Thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by