fsolve stopped because the problem appears regular
Mostrar comentarios más antiguos
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 comentarios
Yuanhao Zhu
el 30 de Jul. de 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
el 30 de Jul. de 2021
Respuesta aceptada
Más respuestas (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 comentario
Jiali
el 13 de Ag. de 2021
Categorías
Más información sobre Assumptions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
