what is wrong when using fzero

hi!
i would like to compute this:
function z=theta(m)
digits 250;
s=sym('s');
p=0;
q=0;
for i=0:m
p=p+(factorial(2*m-i)*factorial(m)*s^i)/factorial(2*m)*factorial(m-
i)*factorial(i);
q=q+(factorial(2*m-i)*factorial(m)*(-s)^i)/factorial(2*m)*factorial(m-
i)*factorial(i);
end;
r=p/q;
s=taylor(exp(-s)*r-1, s, 150); %taylor expansion
coeff=vpa(sym2poly(sym(s)),250); % c_i
x=sym('x');
sum1=0;
l=1;
for j=(2*m+1):(150+2*m)
sum1=sum1+abs(coeff(l))*x^j;
l=l+1;
end;
bound=vpa((-log(1-sum1))/x,250);
n=fzero(bound,3);
just the last part is important. i think there is something wrong with my use of fzero.. when i want to calculate this, i get this error:
>> theta(2)
??? Error using ==> fzero at 181
If FUN is a MATLAB object, it must have an feval method.
Error in ==> theta at 27
n=fzero(bound,3);

Réponses (2)

Walter Roberson
Walter Roberson le 27 Fév 2013

0 votes

You cannot use fzero() on symbolic objects.
If you are going to use symbolic objects, use solve(), or use
feval(symengine, 'numeric::solve', bound, 3)

5 commentaires

Vicky
Vicky le 28 Fév 2013
what if i want to use fzero; what should i change? thank you.
Walter Roberson
Walter Roberson le 28 Fév 2013
If you want to use fzero then you are going to have substantial difficulty in obtaining 250 digits of output.
Vicky
Vicky le 28 Fév 2013
what about if i use feval(symengine, 'numeric::solve', bound, 3), like You wrote; im using Matlab version 7.9.0 (R2009b), so it doesnt work... how should i rewrite it?
Vicky
Vicky le 28 Fév 2013
or if i can use fsolve, where there is an initial point, what i would like. How to form that...

Connectez-vous pour commenter.

Carlos
Carlos le 28 Fév 2013

0 votes

You can use solve instead of fzero

Question posée :

le 27 Fév 2013

Community Treasure Hunt

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

Start Hunting!

Translated by