fsolve exitflag -2, 9 equations 9 variables
이전 댓글 표시
The way I am solving it:
function h = tst(x)
h(1)= x(7) - 50;
h(2)= x(2) + 20;
h(3)= x(3) + 40;
h(4) = -(1.29e9) * (x(4) * abs(x(4))) + 1e10*( x(7)^2 - x(8)^2 );
h(5) = -(1.29e9) * (x(5) * abs(x(5))) + 1e10*( x(8)^2 - x(9)^2 );
h(6) = -(1.29e9) * (x(6) * abs(x(6))) + 1e10*( x(9)^2 - x(7)^2 );
h(7) = x(1) + x(6) - x(4) ;
h(8) = x(2) + x(4) - x(5) ;
h(9) = x(3) + x(5) - x(6) ;
end
and I am trying to solve it like:
x0 = abs(randn(9, 1))
fun = @(x) tst(x);
options = optimoptions('fsolve','Display','iter','MaxIterations',2000,...
'MaxFunctionEvaluations',3000,'TolFun',1e-30,'TolX',1e-30)
[x_sol,fval,exitflag,output]= fsolve(fun,x0, options)
my fval is:
0 0 0 -0.0027 0.0006 0.0022 0 -0.0000 0
And this is the message:
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.
So what is the problem here? Why this cannot be solved?
채택된 답변
추가 답변 (3개)
Walter Roberson
2022년 6월 2일
0 개 추천
If you use the symbolic toolbox, you can work stepwise to solve except for the 4th and 6th equation, solving for variables except x4 and x8. At that point you have to start taking branches of solutions and solving each branch. There is at least one exact solution.
댓글 수: 10
Daniel H.
2022년 6월 2일
Torsten
2022년 6월 2일
It can help if this system is representative for the large scale problem. So does the large scale problem have a similar structure to your toy problem ?
Daniel H.
2022년 6월 2일
Walter Roberson
2022년 6월 2일
is there a particular reason you have x4*abs(x4) instead of sign(x4) * x4^2 ? Can we assume real variables only?
Daniel H.
2022년 6월 2일
Daniel H.
2022년 6월 2일
Daniel H.
2022년 6월 2일
Actually, sign(x4) wouldn't be undefined, but they don't give the same results:
x4=complex(rand,rand);
sign(x4) * x4^2
x4*abs(x4)
Daniel H.
2022년 6월 2일
Daniel H.
2022년 6월 3일
0 개 추천
댓글 수: 1
Walter Roberson
2022년 6월 3일
Tolerances are only meaningful if the values of the expression can be distinguished within the given tolerance. That requires that eps() of the value of the expression is less than the tolerance. In order for eps() of a value to be less than 1e-30, the value must have absolute magnitude less than 1e-15 or so. But instead your values are in the range of 1e9 which can only be distinguished down to roughly 1e-5
Daniel H.
2022년 6월 3일
0 개 추천
댓글 수: 3
Walter Roberson
2022년 6월 3일
편집: Walter Roberson
2022년 6월 3일
MATLAB stores (most) numbers as IEEE 754 Double Precision, which is industry standard and which is what is built in to the hardware of your CPU (GPU might not follow some of the obscure behaviors.)
IEEE 754 uses 1 sign bit, 11 exponent bits, and 52 bits of precision, but the choice of exponent effectively gives you one more bit of precision. The representation is sign*(2^53 + 52 bit unsigned integer)/2^53 * 2^(exponent - 1024). Two values that differ by less than 2^-53 times the effect of the exponent cannot be distinguished with this format. That works out to approximately 1.6*10^-16 * 2^floor(log2(abs(number)). Each doubling of the input keeps the same relative precision but loses a bit of absolute precision.
You have values in the range of 5e9. In order to be able to distinguish 10^-30 over that range, I calculate that you would need about 130 bits of precision. Even if you were using 128 bit extended precision numbers, that would not be enough.
Walter Roberson
2022년 6월 3일
편집: Walter Roberson
2022년 6월 7일
MATLAB does not store numbers in decimal, with the exception of the symbolic toolbox (and even that is a bit questionable, with some hints that it chains together groups of 2^30)
Daniel H.
2022년 6월 7일
카테고리
도움말 센터 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!