fsolve stopped because the problem appears regular
Ältere Kommentare anzeigen
Hi,
I am trying to solve a simple problem but somehow stuck with the output:
fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the default value of the function tolerance.
Would appreciate some help!
function F = root2d(x)
F(1) = (39*x(1)^2*x(2)^2)/100 - (x(2)^2)/5 - 2*x(1)^2 + 1;
F(2) = (39*x(1)^2*x(2)^2)/100 - (7*x(2)^2)/25 - (14*x(1)^2)/5 + 49/25
And my script says
fun = @root2d;
x0 = [0,0];
x = fsolve(fun,x0)
Thanks a lot in advance!
1 Kommentar
XIN
am 24 Sep. 2022
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance.
<stopping criteria details
Question: Why am I having this problem with kmv in matlab? My percentage data are turned into numerical values, but after calculating, my asset value and Equity's value are exactly the same, and the asset value volatility is all 1. I find it so strange.
1、kmvbatch.m
m=xlsread('data1.xlsx',1,'A1:F36')
for i=1:36
r=m(i,4);%
EquityTheta = m(i,1);
E = m(i,2);
D = m(i,3);
T=1;
[Va,AssetTheta] = KMVOptSearch(E,D,r,T,EquityTheta)
m(i,5)=Va;
m(i,6)=AssetTheta;
end
m %
xlswrite('2.csv',m)
2、kmvfun.m
function F=KMVfun(EtoD,r,T,EquityTheta,x)
d1=(log(x(1)*EtoD)+(r+0.5*x(2)^2)*T)/(x(2)*sqrt(T));
d2=d1-x(2)*sqrt(T);
F=[x(1)*normcdf(d1)-exp(-r*T)*normcdf(d2)/EtoD-1;
normcdf(d1)*x(1)*x(2)-EquityTheta];
end
3、kmvoptsearch
function [Va,AssetTheta]=KMVOptSearch(E,D,r,T,EquityTheta)
EtoD=E/D;
x0=[1,1];
VaThetaX=fsolve(@(x)KMVfun(EtoD,r,T,EquityTheta,x),x0);
Va=VaThetaX(1)*E;
AssetTheta=VaThetaX(2);
end
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 28 Okt. 2017
1 Stimme
Use any starting point whose components have absolute value 1E-7 or higher (approximately).
There are 8 solutions to those equations and your starting point [0 0] is in the middle of all of them; the algorithm cannot figure out which direction to head (the algorithm does not make random choices.) Using a non-zero starting point places one of the solutions closer and allows it to be found.
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!