fsolve stopped because the problem appears regular
이전 댓글 표시
Dear all,
I tried to solve an equation as below, but "fsolve" failed.
since ω and data are known, only two variables x(1) and x(2) are required to be solved. However, the error message is shown as "fsolve stopped because the problem appears regular". How to resovle this issue?
clear all;
omega0=2*pi*599.585e12;
data=(2+0.5i)^2;
options=optimoptions('fsolve','Display','iter');
x=fsolve(@(x)rfpnk(x,omega0,data),[2*omega0,2*omega0],options);
function F=rfpnk(x,omega0,data)
F(1)=1-x(1)*x(2)/(omega0^2+x(1)^2)-real(data);
F(2)=omega0*x(2)/(omega0^2+x(1)^2)+imag(data);
end
댓글 수: 2
Yuanhao Zhu
2021년 7월 30일
It is likely that your optimization starting point was not chosen properly. The optimization process is guided by gradient estimation. Thus, a more reasonable starting point may solve the issue. Try a random starting point if you have no idea about what the solution would be. Or if you have a legitimate guess for your solution, you can start with a number that is close to the real solution .
Jiali
2021년 7월 30일
채택된 답변
추가 답변 (1개)
If you are going to solve for x(i) that are expected to be on the order of 1e15, you need to adjust all of fsolve's tolerance parameters (StepTolerance, FunctionTolerance, OptimalityTolerance, etc...) to reflect that. The default tolerance values expect x and f(x) to be of a much lower order of magnitude.
An easier way to fix it is to change the units of x:
clear all;
omega0=2*pi*599.585e12;
data=(2+0.5i)^2;
options=optimoptions('fsolve','Display','iter');
x=fsolve(@(x)rfpnk(1e12*x,omega0,data),[2,2],options)*1e12;
function F=rfpnk(x,omega0,data)
F(1)=1-x(1)*x(2)/(omega0^2+x(1)^2)-real(data);
F(2)=omega0*x(2)/(omega0^2+x(1)^2)+imag(data);
end
카테고리
도움말 센터 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
