- If y is scalar, then you should be using fzero, not fsolve.
- If you use fsolve, use optimset and not optiimoptions for your options.
- Do not set TolX and TolFun to values less than about 1e-14 (see Tolerances and Stopping Criteria).
- I suggest that you plot your function. You might get an idea of where the root is, and can center the function around that point.
- If your root is near where normcdf is near 1, then for more accuracy you might want to reformulate your computations to use normcdf(_,'upper').
Scaling and centering a complicate equation
11 views (last 30 days)
Show older comments
Hi,
I have a somehow complicate equation in my matlab code which I try to solve by fsolve. I read a lot about some troubles with fsolve as long as the equation is not centered and rightly scaled.
Now, my equation is not that simple and therefore scaling and centering is a real challenge for me:
r = 0.046
p = 0.6760;
normk = 1.0804
y1 = 0.88;
y2 = 0.88;
Oz = 10000;
gamma = (y2/(1-y2))*(r+0.5*(normk^2))*T+0.5*((y2/(1-y2))^2)*(normk^2)*T;
%solve problem
d1e = @(y) (log((p/y))+(r-0.5*(normk^2))*(T))/(normk*sqrt(T));
d2e = @(y) d1e(y) + (normk*sqrt(T))/(1-y2);
WO0 = @(y) Oz*exp(-r*(T))*normcdf(d1e(y))+(((B*y2)/y)^(1/(1-y2)))*exp(gamma) *normcdf(d2e(y)) - Oz;
options = optimoptions('fsolve','TolX',1e-20,'TolFun',1e-20,'Display','iter','MaxFunEvals',10000000,'MaxIter',10000000);
[y,fval] = fsolve(WO0,1,options)
As you can see, I solve for y and the equation is not linear. The problem for centering is especially the normcdf. Has anyone got an idea? I appreciate every bit of input :)
Thank you.
0 Comments
Answers (1)
Alan Weiss
on 11 Aug 2014
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!