Azzera filtri
Azzera filtri

using fzero to find root of nonlinear equation

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
Matt J
Matt J il 5 Ott 2012
Modificato: Matt J il 5 Ott 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 il 10 Ott 2012
I have checked that. Yes you're right Matt. Thanks.. I have to fix the formula.

Accedi per commentare.

Risposta accettata

Matt Fig
Matt Fig il 5 Ott 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 Commento
endah
endah il 10 Ott 2012
Modificato: endah il 10 Ott 2012
Yes, the value is infinite everywhere , seems the problem is in my formula..Thanks !

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by