Nonlinear equations using fsolve leads into exceeding the iteration limit and solver stops prematurely.

조회 수: 1 (최근 30일)
Hello all, I am solving nonlinear 5 equations and 5 unknowns. However, I am running into a problem:
Solver stopped prematurely.
fsolve stopped because it exceeded the iteration limit,
options.MaxIterations = 4.000000e+02.
function F = root1(x)
psi = -2;
ffr = 1.01;
F(1) = 1/(1+psi) * (psi + ((1+x(3))/(1+x(2)))^(x(5)/(1-x(5))));
F(2) = sum(x(1)*(1+x(3))) - 1;
F(3) = ffr - (1+x(3))*(1-x(5))/x(5)*(1 + psi*((1+x(3))/(1+x(2)))^(x(5)/(1-x(5))));
F(4) = 1 + x(4)/(1-x(4))*(psi*x(1) - 1 - psi);
F(5) = x(4)*(1+psi)/(1+x(4)*psi);

답변 (1개)

Walter Roberson
Walter Roberson 2021년 11월 26일
There is no solution.
F(5) involves only x(4) times something, and that has to equal 0. But for finite x(4) the only solution is x(4)=0. Then when you substitute that into F(4) then unless you get into a 0/0 form, the x(4)=0 multiplying by something else gives 0, leaving F(4)=1. But 1 can never equal 0 as needed for fsolve.
So no solution unless you get into infinite values or want to start dealing with 0/0
Question: why bother writing sum() in F(2)?
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 11월 26일
F(2) = sum(x(1)*(1+x(3))) - 1;
x(1) is a scalar, 1 is a scalar, x(3) is a scalar, -1 is a scalar... it is not obvious why you would have a summation ?
I cannot answer about the loops because you have not specified the sizes of the variables, or what the loop is over.
The x that will be received when fsolve() is called will be the same size() as the x0 that is passed in to fsolve(). If you want to deal with columns then vectorize over the appropriate dimension
function F = root1(x)
psi = -2;
ffr = 1.01;
F(1, :) = 1./(1+psi) .* (psi + ((1+x(:,3))./(1+x(:,2))).^(x(:,5)./(1-x(:,5))));
F(2, :) = x(:,1).*(1+x(:,3))) - 1;
F(3, :) = ffr - (1+x(:,3)) .* (1-x(:,5)) ./ x(:,5) .* (1 + psi.*((1+x(:,3))./(1+x(:,2))).^(x(:,5)./(1-x(:,5))));
F(4, :) = 1 + x(:,4)./(1-x(:,4)) .* (psi*x(:,1) - 1 - psi);
F(5. :) = x(:,4) .* (1+psi) ./ (1+x(:,4).*psi);
Though unless you change the equations you will still have problems with the equations being inconsistent.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Special Functions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by