- You will see updates in your activity feed.
- You may receive emails, depending on your notification preferences.

- 122 questions asked
- 14 answers
- 2 accepted answers
- reputation: 8

- 122 questions asked
- 14 answers
- 2 accepted answers
- reputation: 8

Accepted Answer by Matt J

- 145 questions asked
- 6,016 answers
- 2,629 accepted answers
- reputation: 14,482

22 views (last 30 days)

22 views (last 30 days)

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)

- 145 questions asked
- 6,016 answers
- 2,629 accepted answers
- reputation: 14,482

Answer by Matt J
on 7 Jul 2019

- 145 questions asked
- 6,016 answers
- 2,629 accepted answers
- reputation: 14,482

Edited by Matt J
on 7 Jul 2019

- 145 questions asked
- 6,016 answers
- 2,629 accepted answers
- reputation: 14,482

Accepted Answer

What do you mean by plugging the solution into the same equations ?

what does this residual norm mean ?

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 ?

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 ?

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

I feel part of the problem that I don't get good results is at zero point :

but what about the rest ?

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.

Thats simply not true They are the SAME equations!!!!!

I wouldn't commit such an obvious mistake!!!!!!!!!!!!!!!!!!!!

Honestly: How do you think anybody can help you from the information you've given us so far ?

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

If you insert

fun(x)

after the line

[x,fval,exitflag,output] = fsolve(fun,x0init,options);

what do you get ?

236.3596 -165.1109 5.0631 294.1734 286.7896 33.6382 179.1413 -109.6156 76.8316

this is what I get

These are the errors in the equations for the x-vector fsolve returns as solution.

You are so correct, so may I ask how do I correct the errors ?

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 ?

I wouldn't commit such an obvious mistake!!!!!!!!!!!!!!!!!!!!

Hah! This is me gloating!!!!

positive voted

so about my last question in multistart ?

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.

I don't know why the other time it gave me big numbers or I did not notice the 1e-8 value

This is the contradiction I am facing !!

by the way

the

funx = fun(x)

after the x is calculated

I don't understand you. so when should I call fun(x) ?

so I am back to my question :

should I trust the fun(x) , or MATLAB output Error ???

I answered you 6h ago:

"Sorry I certainly don't believe you more than the correctness of FSOLVE output of 1.44467e+07."

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.

@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

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

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply TodayUnable to complete the action because of changes made to the page. Reload the page to see its updated state.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- 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)

## 16 Comments

## Walter Roberson (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722233

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722242

## Walter Roberson (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722265

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722270

## Walter Roberson (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722277

## Bruno Luong (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722278

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722280

## Bruno Luong (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722281

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722283

## Bruno Luong (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722285

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722286

## Bruno Luong (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722288

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722294

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722300

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722318

## farzad (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/470568-why-do-i-get-no-solution-found-in-fsolve-despite-the-results-match-my-nonlinear-equations#comment_722385

Sign in to comment.