help-octave
[Top][All Lists]

## Use of fsolve

 From: Daniel Tourde Subject: Use of fsolve Date: Thu, 01 Oct 1998 18:08:46 +0200

```Hello,

I would like to use the fsolve solution for solving non-linear equations
where sometimes, solutions or constant are very small:

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

Where some of my nlcoef values are very small (between 1e-7 and 1e-10).
It happens that the solutions given by fsolve can be wrong due to
rounding and precision errors.

It is possible to increase the tolerance of fsolve by using the
fsolve_options:

octave:1> fsolve_options

*** fsolve_options:

fsolve_options (KEYWORD, VALUE)

Set or show options for fsolve.  Keywords may be abbreviated
to the shortest match.

Options for fsolve include:

keyword                                  value
-------                                  -----

tolerance                                1.49012e-08

octave:2> fsolve_options ("tol", 1e-12)
octave:3> fsolve_options ("tol")
ans =  1.0000e-12

I know the existence of some flags provided by fsolve:

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

It happens during my computation that sometimes flag 3 or flag 4 are
raised. And of course, this is when I got wrong results.

Then my question is the following: How can I change the iteration limit
within fsolve. How can I improve the precision of Octave in its
globality ? In a word, what is the best way to get rid of flag 4 and
flag 3 ?

Daniel Tourde

--
*********************************************************************