Effacer les filtres
Effacer les filtres

using fzero to find root of nonlinear equation

3 vues (au cours des 30 derniers jours)
endah
endah le 5 Oct 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 commentaires
Matt J
Matt J le 5 Oct 2012
Modifié(e) : Matt J le 5 Oct 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 le 10 Oct 2012
I have checked that. Yes you're right Matt. Thanks.. I have to fix the formula.

Connectez-vous pour commenter.

Réponse acceptée

Matt Fig
Matt Fig le 5 Oct 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 commentaire
endah
endah le 10 Oct 2012
Modifié(e) : endah le 10 Oct 2012
Yes, the value is infinite everywhere , seems the problem is in my formula..Thanks !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by