The fsolve function fails to give me an answer for seven unknowns. What should I do?
조회 수: 2 (최근 30일)
이전 댓글 표시
x0=[1;1;1;1;1;1;1];
x=fsolve(@nle,x0)
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
Matt J
2022년 4월 19일
편집: Matt J
2022년 4월 19일
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).
답변 (2개)
Walter Roberson
2022년 4월 19일
편집: Walter Roberson
2022년 4월 19일
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)
digits(50)
sol = vpasolve(eqns)
X = subs(x, sol)
double(nle(X))
nle(double(X))
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
댓글 수: 0
Alex Sha
2022년 4월 19일
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
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!