Solving non linear system of equations
조회 수: 8 (최근 30일)
이전 댓글 표시
Hello!I have some troubles while solving the non-linear system.
http://saveimg.ru/show-image.php?id=19f0894034eb37dc9fef4a7a088c2a55 this is a link to my system, which I need to solve against V and sigma_v
I wrote the following code in mm-file
function y = mm(x,D,r,delta_t,S,sigma_s)
d1=(log(x(2)/D)+(r-0.5*x(1)*x(1)*delta_t))/(x(1)*sqrt(delta_t));
d2=d1-x(1)*sqrt(delta_t);
y=((sigma_s*S-normcdf(d1,0,1)*x(1)*x(2))^2+(S-x(2)*normcdf(d1,0,1)-D*exp(-r*delta_t)*normcdf(d2,0,1))^2);
and I use the following command:
x=fminsearch('mm(x,5000000,0.0071,2548,74513269760,0.000665992)',[10 0.0001])
but the answer is 10 0.00001 which is not correct
So I'd be glad if someone shows me a mistake, which I made
Thx in advance!
댓글 수: 0
답변 (2개)
Teja Muppirala
2011년 5월 7일
Wow. Now this is really like finding a needle in a haystack.
But FMINSEARCH can find it if you just give it a better starting condition, and enough function evaluations:
opts = optimset('tolfun',0,'tolx',0,'maxfun',Inf,'display','iter');
xmin = fminsearch(@(x)mm(x,5000000,0.0071,2548,74513269760,0.000665992),[0.0001 1e10],opts)
This gives you the answer:
xmin(1) = 6.659920000005961e-004
xmin(2) = 7.451326975993047e+010
The difficulty was in finding a good initial condition. How did I do it? By making a giant plot over logarthmic space:
jvec = linspace(-10,20,201);
kvec = linspace(-10,20,201);
A = zeros(numel(jvec),numel(kvec));
for jj = 1:numel(jvec)
for kk = 1:numel(kvec)
A(jj,kk) = mm(10.^[jvec(jj) kvec(kk)],5000000,0.0071,2548,74513269760,0.000665992);
end
end
figure
imagesc(kvec,jvec,log10(A)); colorbar;
댓글 수: 0
terance
2011년 5월 7일
댓글 수: 1
Teja Muppirala
2011년 5월 7일
Your results are the same as mine. This is just a difference in how many digits are displayed. If you do
format long
and then view the result, it is the same. Also, because the numbers are very differently scaled, it helps to view them one at a time
xmin(1)
xmin(2)
On the plot, red means high and blue means low, just as the colorbar indicates. I just looked for where there were blue areas (and actually I replotted that graph several times, changing the limits and zooming in a little each time until I was pretty certain where a good initial condition was).
참고 항목
카테고리
Help Center 및 File Exchange에서 Time and Frequency Domain Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!