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.
Amina Enkhbold
Amina Enkhbold 2021 年 11 月 28 日
Thank you for your helpful response!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpecial Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by