이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Why do I get no solution found in Fsolve despite the results match my nonlinear equations ?
조회 수: 8 (최근 30일)
이전 댓글 표시
farzad
2019년 7월 7일
Hi All
I am solving a set of Non Linear equations. when I put the solution results in each of my equations, the result is zero or very close to zero ( 1e-15 as residual)
the options I use :
options = optimoptions(@fsolve,'Display','iter','MaxFunEvals',1e6,'MaxIter',1e6,'TolFun',1e-1,'DerivativeCheck','on','Diagnostics','on');
but on the message board I get the no solution found, that does not change with any tolerance value :
Here I put a copy of the last iterations and the message :
23 72 1.44467e+07 0.000238419 1.4 0.000238
24 73 1.44467e+07 0.000238419 1.4 0.000238
25 77 1.44467e+07 5.96046e-05 0.325 5.96e-05
26 78 1.44467e+07 5.96046e-05 0.325 5.96e-05
27 82 1.44467e+07 1.49012e-05 0.147 1.49e-05
28 86 1.44467e+07 1.49012e-05 0.0306 1.49e-05
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
selected value of the function tolerance.
fsolve stopped because the sum of squared function values, r, has gradient with
relative norm 3.057666e-02; this is less than options.OptimalityTolerance = 1.000000e-01.
However, r = 1.444675e+07, exceeds sqrt(options.FunctionTolerance) = 3.162278e-01.
Optimization Metric Options
norm(grad r) = 3.06e-02 OptimalityTolerance = 1e-01 (selected)
r = 1.44e+07 sqrt(FunctionTolerance) = 3.2e-01 (selected)
댓글 수: 16
farzad
2019년 7월 8일
That's for sure not possible, very sorry.
I wish this problem is common and there is already a solution or procedure to verify the problem
I think the higher number of Nonlinear equations, the more divergent become the MATLAB output messages comparing with actual situation.
at the moment Matlab is giving an unreal output message
Walter Roberson
2019년 7월 8일
That's for sure not possible, very sorry.
Then we cannot be of assistance to you. You will need to hire someone that you can put under non-disclosure agreement.
I wish this problem is common and there is already a solution or procedure to verify the problem
The problem is common, and the solution is to repair your equations.
farzad
2019년 7월 8일
The equations are the exact analytical definition of the problem
what do you intend by repairing ?
Walter Roberson
2019년 7월 8일
If fsolve is telling you that the residual is about 1E15 and your code says that the function value is about 1e-15 then your testing code is wrong, or else your equations are numerically unstable, or you have a serious loss of precision.
Bruno Luong
2019년 7월 8일
편집: Bruno Luong
2019년 7월 8일
What is the first guess x0 you provide to FSOLVE?
Yes if the problem is very-non linear or non-differentiable or ill-condition FSOLVE might converge toward a local minimum or not converge at all.
But as you do not show any code it's just anyone guess that you'll get as diagnostic.
farzad
2019년 7월 8일
Bruno my first guess is taken from some experimental data that I know they fit in the equations. So yes the whole problem is being ill conditioned and hard to differentiate. WhatsApp do you do generally to improve this case?
Bruno Luong
2019년 7월 8일
편집: Bruno Luong
2019년 7월 8일
I asked for the first-guess of fit parameter x0, not the data.
If FSOLVE tells function value is as large as 1.44467e+07 then I doubt the data fits well the model as you claim (and this has nothing to do with non-linearity, since the function value reflects the maching - residual as MATT told you). Or your implementation is incorrect.
farzad
2019년 7월 8일
To test the results, I simply run each of the equations. Their value come very small
Bruno Luong
2019년 7월 8일
Sorry I certainly don't believe you more than the correctness of FSOLVE output of 1.44467e+07.
Your implementation or/and test is wrong.
farzad
2019년 7월 8일
Ok, apart from the method I mentioned, what's is your proposed method of implementation?
Bruno Luong
2019년 7월 8일
We can't advise the method if you refrain to provide any detail/desciption of the problem to be solved.
farzad
2019년 7월 8일
What is the difference in evaluation if the equations are a set of 3rd orders or a set of 2nd order equations?
farzad
2019년 7월 8일
@Bruno :
if you have 3 or 5 or 6 second order equations ,once you have the x matrix as the results of the solution , and if Matlab gives that large r = 1.444675e+07 in command prompt , what would you expect to get by running ( F9) each of your equations ?
채택된 답변
Matt J
2019년 7월 7일
편집: Matt J
2019년 7월 7일
You're asking for guesses? Because you are not plugging the solution into the same equations that were given to fsolve. fsolve thinks you have a residual norm of sqrt(1.44e+07).
댓글 수: 34
farzad
2019년 7월 7일
What do you mean by plugging the solution into the same equations ?
what does this residual norm mean ?
farzad
2019년 7월 7일
if by plugging you mean tagging fun = @rood2d where your equations are and use it in Fsolve command , I have done it
Matt J
2019년 7월 7일
plugging in means substituting your results into your equations. You said you did that and it gave you residuals of 1e-15.
farzad
2019년 7월 7일
ok , So I don't understand why you should have written the first answer !!??
how is this possilbe then ?
I see my results are fine when even substituting manually in the equations
but MATLAB gives me this error !!
how come ?
farzad
2019년 7월 8일
I added the options I used and as you see the Tolerance is 1e-1
Is there anything else required to be modified ? should I change the method ?
farzad
2019년 7월 8일
Is it reasonable to use fzero when fsolve does not give good results ?
my only problem is how to make matlab read the command window message ,since there is incompatibility between the function residuals when trying the results manually and those messages of the command window
farzad
2019년 7월 8일
I feel part of the problem that I don't get good results is at zero point :
but what about the rest ?
Matt J
2019년 7월 8일
how is this possilbe then ? I see my results are fine when even substituting manually in the equations
Because you have not substituted manually into the same equations as fsolve has been given. fsolve is solving a different set of equations than what you truly intend. Why this occurs is not possible for us to know since we are blind to the code you are running.
farzad
2019년 7월 8일
Thats simply not true They are the SAME equations!!!!!
I wouldn't commit such an obvious mistake!!!!!!!!!!!!!!!!!!!!
Torsten
2019년 7월 8일
Honestly: How do you think anybody can help you from the information you've given us so far ?
Matt J
2019년 7월 8일
@farzad: Why don't you show us just the top-level code (not the objective function) that runs fsolve and the test of its output that you mention. If we are completely blind to what you are running, the only thing we can suspect are obvious mistakes.
farzad
2019년 7월 8일
편집: farzad
2019년 7월 8일
the top level code is :
[x,fval,exitflag,output] = fsolve(fun,x0init,options);
F is a matrix containing all the equations. after the code ends, I manually rewrite the equations in the command prompt obviously with all of the x components calcualted ,so once typing F after all of these eqations , this is given out :
F =
1.0e-08 *
0.2954 0.2954 0.4458 0.2325 0.2492 0.2562 0.0531 0.0342 0.5142
Also exitflag= -2
farzad
2019년 7월 8일
236.3596 -165.1109 5.0631 294.1734 286.7896 33.6382 179.1413 -109.6156 76.8316
this is what I get
Torsten
2019년 7월 8일
These are the errors in the equations for the x-vector fsolve returns as solution.
farzad
2019년 7월 8일
Specially if I am sure that my equations are analytically correct. could such an error be corrected by improving the solution by Jacobian matrix ,etc ?
Torsten
2019년 7월 8일
Since I don't know the equations you are trying to solve, the only thing that comes to mind is choosing different initial values (vector x0init) or the Multistart option.
farzad
2019년 7월 8일
do you mean this ? what should I write in the paranthesis after run(--) instead of the lines ?
[x,fval,exitflag,output,solutions] = run(___)
I mean how to plug this to @root2D where my equations are ?
Matt J
2019년 7월 8일
I wouldn't commit such an obvious mistake!!!!!!!!!!!!!!!!!!!!
Hah! This is me gloating!!!!
farzad
2019년 7월 8일
편집: farzad
2019년 7월 8일
I was wrong about the last time !!! fun(x) gives low value :
____________________________________________________________
Diagnostic Information
Number of variables: 3
Functions
Objective: rootcenter
Gradient: finite-differencing
Algorithm selected
trust-region-dogleg
____________________________________________________________
End diagnostic information
Norm of First-order Trust-region
Iteration Func-count f(x) step optimality radius
0 4 1.69272e+07 2.24e+05 1
1 8 1.64774e+07 1 2.02e+05 1
2 12 1.55628e+07 2.5 1.48e+05 2.5
3 16 1.44888e+07 6.25 2.25e+04 6.25
4 17 1.44888e+07 6.25 2.25e+04 6.25
5 21 1.44506e+07 1.5625 9.73e+03 1.56
6 22 1.44506e+07 1.5625 9.73e+03 1.56
7 26 1.44471e+07 0.390625 1.97e+03 0.391
8 27 1.44471e+07 0.390625 1.97e+03 0.391
9 31 1.44468e+07 0.0976562 876 0.0977
10 35 1.44468e+07 0.0976562 820 0.0977
11 36 1.44468e+07 0.0976562 820 0.0977
12 40 1.44468e+07 0.0244141 175 0.0244
13 41 1.44468e+07 0.0244141 175 0.0244
14 45 1.44467e+07 0.00610352 107 0.0061
15 49 1.44467e+07 0.00610352 29.7 0.0061
16 50 1.44467e+07 0.00610352 29.7 0.0061
17 54 1.44467e+07 0.00152588 10.2 0.00153
18 55 1.44467e+07 0.00152588 10.2 0.00153
19 59 1.44467e+07 0.00038147 5.32 0.000381
20 63 1.44467e+07 0.00038147 0.435 0.000381
21 64 1.44467e+07 0.00038147 0.435 0.000381
22 65 1.44467e+07 9.53674e-05 0.435 9.54e-05
23 69 1.44467e+07 2.38419e-05 0.214 2.38e-05
24 73 1.44467e+07 2.38419e-05 0.0943 2.38e-05
25 74 1.44467e+07 2.38419e-05 0.0943 2.38e-05
26 78 1.44467e+07 5.96046e-06 0.0268 5.96e-06
27 79 1.44467e+07 5.96046e-06 0.0268 5.96e-06
28 83 1.44467e+07 1.49012e-06 0.0414 1.49e-06
29 84 1.44467e+07 1.49012e-06 0.0414 1.49e-06
30 85 1.44467e+07 3.72529e-07 0.0414 3.73e-07
31 89 1.44467e+07 9.31323e-08 0.0107 9.31e-08
32 90 1.44467e+07 9.31323e-08 0.0107 9.31e-08
33 91 1.44467e+07 2.32831e-08 0.0107 2.33e-08
34 92 1.44467e+07 5.82077e-09 0.0107 5.82e-09
35 93 1.44467e+07 1.45519e-09 0.0107 1.46e-09
36 94 1.44467e+07 3.63798e-10 0.0107 3.64e-10
37 95 1.44467e+07 9.09495e-11 0.0107 9.09e-11
38 96 1.44467e+07 2.27374e-11 0.0107 2.27e-11
No solution found.
fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance squared, but the vector of function values
is not near zero as measured by the selected value of the function tolerance.
farzad
2019년 7월 8일
I don't know why the other time it gave me big numbers or I did not notice the 1e-8 value
farzad
2019년 7월 8일
This is the contradiction I am facing !!
by the way
the
funx = fun(x)
after the x is calculated
Torsten
2019년 7월 8일
funx can't be the output of fun(x) after the call to fsolve. Otherwise, it would have been printed after fsolve's iteration monitor and error message.
Matt J
2019년 7월 8일
The purpose of calling fun(x) is to test how well the result x returned by fsolve satisfies the equations. Therefore, you should call it immediately after fsolve has finished working and you must make sure that the x here is the x returned by fsolve.
farzad
2019년 7월 8일
so I am back to my question :
should I trust the fun(x) , or MATLAB output Error ???
Matt J
2019년 7월 8일
The output of fun(x) and the messages returned by fsolve should be telling you the same thing. They were telling you the same thing several Comments ago.
Bruno Luong
2019년 7월 8일
I answered you 6h ago:
"Sorry I certainly don't believe you more than the correctness of FSOLVE output of 1.44467e+07."
farzad
2019년 7월 8일
Bruno, shall we avoid this way of conversation ?
you asked me to test fun(x) and tell you the output and I did
and reported you.
farzad
2019년 7월 8일
@Matt J
why do you avoid checking my last report where I have a small fun(x)
and a big error
they are not telling the same thing
farzad
2019년 7월 8일
Sorry
I was doing something wrong
I had two fsolve loops
and I was reporting the error of the second one for the first one
sorry !
my mistake
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)