The fsolve function fails to give me an answer for seven unknowns. What should I do?

2 vues (au cours des 30 derniers jours)
x0=[1;1;1;1;1;1;1];
x=fsolve(@nle,x0)
No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance.
x = 7×1
1 1 1 1 1 1 1
function f=nle(x)
f(1)= x(2)+x(3)+x(5)+x(7)+1587.8938-2800;
f(2)= 2*x(1) + 2*x(4) + 4*x(5)+1817.9113-4400-48.14;
f(3)= x(2) +2*x(3)+x(4)+585.4646-1600+24.07+19.94;
f(4)=2*x(6)+1573.649-100-74.9744;
f(5)=((x(1)^3)*(x(2))/(x(4)*x(5)))-(5.2234*10^33);
f(6)=(x(1)*x(3))/(x(2)*x(4))-(4.6061*10^10);
f(7)=((x(1)*x(2))/x(4))-(4.1158*10^32);
end
  1 commentaire
Matt J
Matt J le 19 Avr 2022
Modifié(e) : Matt J le 19 Avr 2022
It's possible there is no solution. Why do you think there should be?
If there is a solution, however, several x(i) would have to be on the order of 10^10, judging from equations 5 through 7. It is not good to formulate optimization problems with variables of such large magnitude. I suggest you reconsider the units in which you have chosen to measure the x(i).

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 19 Avr 2022
Modifié(e) : Walter Roberson le 19 Avr 2022
There are mathematical solutions, but double precision cannot reach those solutions.
Notice with digits(50) that the 5th output value (you will need to scroll) is about 1E-05. With the default digits(32) the value is about 1E+15 or so -- even 32 digits is not enough to resolve the system.
format long g
syms x [1 7]
eqns = nle(x)
eqns = 
digits(50)
sol = vpasolve(eqns)
sol = struct with fields:
x1: 88.233931460201283710282518149426763331107348145629 x2: -4467770999326980136382.0315551256836825387566296681 x3: 2233885499663490068676.2784775633207291694293047308 x4: -0.00000000095779435379389596111080314505826669240700645930622 x5: 613.44020927037825959638078723860473810708968811973 x6: -699.337299999999943611328490078449249267578125 x7: 2233885499663490068304.4190682919846381118707891956
X = subs(x, sol)
X = 
double(nle(X))
ans = 1×7
1.0e+00 * 2.07665869880716e-36 -2.27745961462445e-36 1.93072104155493e-36 1.42741035237468e-55 -3.19052891243316e-05 -5.97882421853985e-29 -5.34240349073323e-07
nle(double(X))
ans = 1×7
1.0e+00 * -1212.1062 -5.82645043323282e-13 -970.525400000958 5.6843418860808e-14 2.30584300921369e+18 7.62939453125e-06 0
function f=nle(x)
f(1)= x(2)+x(3)+x(5)+x(7)+1587.8938-2800;
f(2)= 2*x(1) + 2*x(4) + 4*x(5)+1817.9113-4400-48.14;
f(3)= x(2) +2*x(3)+x(4)+585.4646-1600+24.07+19.94;
f(4)=2*x(6)+1573.649-100-74.9744;
f(5)=((x(1)^3)*(x(2))/(x(4)*x(5)))-(5.2234*10^33);
f(6)=(x(1)*x(3))/(x(2)*x(4))-(4.6061*10^10);
f(7)=((x(1)*x(2))/x(4))-(4.1158*10^32);
end

Alex Sha
Alex Sha le 19 Avr 2022
Just doing some equivalent deformation (change division into multiplication), for example,
form:
f(5)=((x(1)^3)*(x(2))/(x(4)*x(5)))-(5.2234*10^33);
f(6)=(x(1)*x(3))/(x(2)*x(4))-(4.6061*10^10);
f(7)=((x(1)*x(2))/x(4))-(4.1158*10^32);
to:
f(5)=(x(1)^3)*(x(2))-(x(4)*x(5))*(5.2234*10^33);
f(6)=(x(1)*x(3))-(x(2)*x(4))*(4.6061*10^10);
f(7)=(x(1)*x(2))-x(4)*(4.1158*10^32);
multi-solutions will be get:
1:
x1: 0
x2: 183.614772826468
x3: 393.455313586766
x4: 0
x5: 657.557175
x6: -699.3373
x7: -22.5210614132339
2:
x1: 0
x2: 185.160969290733
x3: 392.682215354633
x4: 0
x5: 657.557175
x6: -699.3373
x7: -23.294159645367

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by