Filter löschen
Filter löschen

using fzero to find root of nonlinear equation

3 Ansichten (letzte 30 Tage)
endah
endah am 5 Okt. 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 Kommentare
Matt J
Matt J am 5 Okt. 2012
Bearbeitet: Matt J am 5 Okt. 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 am 10 Okt. 2012
I have checked that. Yes you're right Matt. Thanks.. I have to fix the formula.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt Fig
Matt Fig am 5 Okt. 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 Kommentar
endah
endah am 10 Okt. 2012
Bearbeitet: endah am 10 Okt. 2012
Yes, the value is infinite everywhere , seems the problem is in my formula..Thanks !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by