Borrar filtros
Borrar filtros

using fzero to find root of nonlinear equation

3 visualizaciones (últimos 30 días)
endah
endah el 5 de Oct. de 2012
Dear Matlab user,
I try to find root of highly nonlinear equation as in
T=1;
r=0.1;
d=0.3;
sigma=0.2;
p=5545.17744447956;
b=(r-d-0.5*(sigma^2))/(sigma^2);
b2=b^2;
q1=-b+sqrt(b2+(r+p)*(2/sigma^2));
q2=-b-sqrt(b2+(r+p)*(2/sigma^2));
x=fzero(@(x) x.^q2*(r+p-r.*q1+d.*q1)./q1./(r+p)./(d+p)+ x.*d.*(1-q1)./(p.^q2)./q1./(d+p)+ r./(p.^(1+q2))./(r+p),[0.01 10000],optimset('Display','off'));
but it doesn't work. Would anyone help me with this ? Thanks alot.
Regards,
Endah
  2 comentarios
Matt J
Matt J el 5 de Oct. de 2012
Editada: Matt J el 5 de Oct. de 2012
You have some expressions in there that aren't finite:
>> d.*(1-q1)./(p.^q2)./q1./(d+p)
ans =
-Inf
>> r./(p.^(1+q2))./(r+p)
ans =
Inf
Also q1 and q2 are very large exponents. That's going to create numerical issues.
endah
endah el 10 de Oct. de 2012
I have checked that. Yes you're right Matt. Thanks.. I have to fix the formula.

Iniciar sesión para comentar.

Respuesta aceptada

Matt Fig
Matt Fig el 5 de Oct. de 2012
To highlight what Matt J said in a comment, you have a problem with your function definition:
F = @(x) x.^q2*(r+p-r.*q1+d.*q1)./q1./(r+p)./(d+p)+ x.*d.*(1-q1)./(p.^q2)./q1./(d+p)+ r./(p.^(1+q2))./(r+p);
x = .1:.01:1000; % The range over which you are looking for a root.
all(isnan(F(x))) % F is not-a-number everywhere on this range!
ans =
1
  1 comentario
endah
endah el 10 de Oct. de 2012
Editada: endah el 10 de Oct. de 2012
Yes, the value is infinite everywhere , seems the problem is in my formula..Thanks !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by