Clear Filters
Clear Filters

using fzero to find root of nonlinear equation

3 views (last 30 days)
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 Comments
Matt J
Matt J on 5 Oct 2012
Edited: Matt J on 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 on 10 Oct 2012
I have checked that. Yes you're right Matt. Thanks.. I have to fix the formula.

Sign in to comment.

Accepted Answer

Matt Fig
Matt Fig on 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 Comment
endah
endah on 10 Oct 2012
Edited: endah on 10 Oct 2012
Yes, the value is infinite everywhere , seems the problem is in my formula..Thanks !

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!