fsolve problem appears regular
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Masset Olivier
el 2 de Jun. de 2017
Respondida: John D'Errico
el 2 de Jun. de 2017
Hello, I have a system of 2 equations defined in a function file: It takes a vector x =[x1 x2] and gives back F a vector.
function F = stepoli(x)
num = xlsread('constants.xlsx');
lam = num(2,:)*1d-9;
Ai = num(1,:)*1d6;
rg = num(5,:);
m = 39.948*6.02214086d-26;
T = 600;
k = 1.38064852*1d-23;
for i = 1:8
l(i) = (lam(i)^3)/(8*pi)*Ai(i)*rg(i)*sqrt(m/(2*pi*k*T)); %l around 1d-15
end
R = [ 1.4 1.2];
F(1) = 1-l(1)*1d-3*x(1)+l(2)*x(2) - R(1)*(1-l(2)*x(2)*1d-3 +l(1)*x(1) - l(1)*x(1)*l(2)*x(2)*1d-3);
F(2) = 1-l(4)*1d-3*x(2)+l(5)*x(2) - R(2)*(1-l(5)*x(2)*1d-3 +l(4)*x(1) - l(4)*x(1)*l(5)*x(2)*1d-3);
end
Then in a script i have
g = @stepoli;
x0 = [10d15 10d15];
x = fsolve(g,x0)
If as x0 I input a solution, it does say it is one. However, as soon as I start from a very close point, it returns:
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 default value of the function tolerance.
And doesn't do any step. Do you know if the problem comes from this gradient or from elsewhere? Maybe you do have some optimization advices. Thanks for reading.
0 comentarios
Respuesta aceptada
John D'Errico
el 2 de Jun. de 2017
How can anyone give you a valid answer if we don't know what is in your variables? What is in num?
My guess is this is a dynamic range problem. Your numbers seem to have a huge range, but double precision arithmetic is pretty limited in that respect. So I would STRONGLY recommend that you look at the computations from the standpoint of 16 digit computations. It may be that a careful scaling of the units in this problem will suffice. Of course, you could always go the symbolic route, and look for solutions that way.
By the way, you should recognize that 10d15 is equivalent to 1d16. Or do you think that you were trying to start at 10^15? You have written the number 10^16, not 15.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!