fsolve stopped because the problem appears regular
Mostra commenti meno recenti
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 Commento
XIN
il 24 Set 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
Risposta accettata
Più risposte (1)
Walter Roberson
il 28 Ott 2017
1 voto
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.
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!