fsolve stopped because the problem appears regular
Afficher commentaires plus anciens
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 commentaires
Yuanhao Zhu
le 30 Juil 2021
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
le 30 Juil 2021
Réponse acceptée
Plus de réponses (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
1 commentaire
Jiali
le 13 Août 2021
Catégories
En savoir plus sur Assumptions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
