help-octave
[Top][All Lists]

## Re: Precision of fsolve

 From: John W. Eaton Subject: Re: Precision of fsolve Date: Fri, 25 Sep 1998 01:03:20 -0500 (CDT)

```On 23-Sep-1998, Daniel Tourde <address@hidden> wrote:

| > | I am using the function fsolve like this :
| > |
| > |   y(1) = 12*((x(3)*x(1))/2)/E - nlcoef(3);
| > |   y(2) = 12*((x(3)*x(2)+x(1)*x(4))/6)/E - nlcoef(4);
| > |   y(3) = 12*((P*x(3)/2+x(4)*x(2)+x(1)*x(5))/12)/E - nlcoef(5);
| > |   y(4) = 12*((P*x(4)/2+x(5)*x(2))/20)/E - nlcoef(6);
| > |   y(5) = 12*((P*x(5))/60)/E - nlcoef(7);
| > |
| > |
| > | Some of my nlcoef values are very small (between 1e-7 and 1e-10) and it
| > | happens that the solutions send back by fsolve can be wrong due to
| > | rounding and precision errors.
| > |
| > | My question is the following :
| > |
| > | How can I increase the precision of fsolve, how can I lower the
| > | admissible error ?
| >
| > Try fsolve_options:
| >
| > ...
|
| Thanks.
|
| However, I did a test. If you take the following values for nlcoef :
|
| nlcoef =
|
|     4.9790e-07
|     4.4823e-06
|     3.5202e-05
|     1.8460e-04
|    -1.7591e-05
|     5.5634e-07
|    -5.8684e-09
|
|
| Then it gives as an answer of the system with fsolve :
|
| polcoef = fsolve("aerea_pl_nlsys6",[1,2,3,4,5]);
|
| polcoef =
|
|     1.8295e+02
|    -3.8343e+00
|     6.7378e-03
|     1.0610e-01
|    -1.8051e-02
|
|
| with E = 210000 and P = 4.
|
|
| If then I recompute the values of
|
|
| 12*((polcoef(3)*polcoef(1))/2)/E
| 12*((polcoef(3)*polcoef(2)+polcoef(1)*polcoef(4))/6)/E
| 12*((P*polcoef(3)/2+polcoef(4)*polcoef(2)+polcoef(1)*polcoef(5))/12)/E
| 12*((P*polcoef(4)/2+polcoef(5)*polcoef(2))/20)/E
| 12*((P*polcoef(5))/60)/E
|
|
| I obtain the following values :
| ans =  3.5220e-05
| ans = 0.00018461
| ans =  -1.7599e-05
| ans =  8.0401e-07
| ans =  -6.8765e-08
|
| It's quite clear that the last two ones are wrong. What can I do about
| this ? Is it simply due to precision of the computation and then, how
| can I improve it ?

I don't understand why you say the last two are clearly wrong.  The
fsolve function is trying to compute the values of x (polcoef) such
that the values of the functions you supplied are zero.  It looks to
me like the worst one is the second one, which is only 1.8e-4.

What is the info flag (the second output argument) that's returned by

Valid values and their meanings are:

-2:  input error
-1:  error encountered in user-supplied function
1:  solution converged to requested tolerance
4:  iteration limit exceeded
3:  iteration is not making good progress

jwe

```