Manual Descripton of fsolve

View: New views
2 Messages — Rating Filter:   Alert me  

Manual Descripton of fsolve

by Rolf Fabian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

fsolve arguments have changed since Octave 3.0.0 to
[ x, fval, info ] = fsolve ( fcn, x0 )

but in the example in the manual ( page 231-232 A4-version )
still the old version is used twice:

"[ x, info ] = fsolve ( @f, [1; 2] )" and
"[ x, info ] = fsolve ({@f, @jacobian}, [1;2] )"

Furthermore, the new output argument 'fval' is not
explained / mentioned at all.


Rolf Fabian
< r dot fabian at jacobs-university dot de >


Rolf Fabian
<r dot fabian at jacobs-university dot de>

Manual Descripton of fsolve

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10-Jan-2008, Rolf Fabian wrote:

|
| fsolve arguments have changed since Octave 3.0.0 to
| [ x, fval, info ] = fsolve ( fcn, x0 )
|
| but in the example in the manual ( page 231-232 A4-version )
| still the old version is used twice:
|
| "[ x, info ] = fsolve ( @f, [1; 2] )" and
| "[ x, info ] = fsolve ({@f, @jacobian}, [1;2] )"
|
| Furthermore, the new output argument 'fval' is not
| explained / mentioned at all.

OK, I checked in the following change for both cvs head and the 3.0
branch.  The values of info are still not compatible with Matlab, but
there are some plans to fix that for 3.1.

jwe



src/ChangeLog:

2008-01-10  John W. Eaton  <jwe@...>

        * DLD-FUNCTIONS/fsolve.cc (Ffsolve): Doc fix.
        (hybrd_info_to_fsolve_info): Swap return values for -1 and -2 inputs.


Index: doc/interpreter/nonlin.txi
===================================================================
RCS file: /cvs/octave/doc/interpreter/nonlin.txi,v
retrieving revision 1.6
diff -u -u -r1.6 nonlin.txi
--- doc/interpreter/nonlin.txi 13 Oct 2007 00:52:12 -0000 1.6
+++ doc/interpreter/nonlin.txi 11 Jan 2008 02:38:40 -0000
@@ -79,7 +79,7 @@
 @code{f} defined above,
 
 @example
-[x, info] = fsolve (@@f, [1; 2])
+[x, fval, info] = fsolve (@@f, [1; 2])
 @end example
 
 @noindent
@@ -91,6 +91,11 @@
   0.57983
   2.54621
 
+fval =
+
+  -5.7184e-10
+   5.5460e-10
+
 info = 1
 @end example
 
@@ -141,7 +146,7 @@
 Using this Jacobian is done with the following code
 
 @example
-[x, info] = fsolve (@{@@f, @@jacobian@}, [1; 2]);
+[x, fval, info] = fsolve (@{@@f, @@jacobian@}, [1; 2]);
 @end example
 
 @noindent
Index: src/DLD-FUNCTIONS/fsolve.cc
===================================================================
RCS file: /cvs/octave/src/DLD-FUNCTIONS/fsolve.cc,v
retrieving revision 1.34
diff -u -u -r1.34 fsolve.cc
--- src/DLD-FUNCTIONS/fsolve.cc 10 Dec 2007 21:01:49 -0000 1.34
+++ src/DLD-FUNCTIONS/fsolve.cc 11 Jan 2008 02:38:44 -0000
@@ -65,11 +65,10 @@
   switch (info)
     {
     case -1:
-      info = -2;
       break;
 
     case 0:
-      info = -1;
+      info = -2;
       break;
 
     case 1:
@@ -228,6 +227,24 @@
 and an initial starting point @var{x0}, @code{fsolve} solves the set of\n\
 equations such that @code{f(@var{x}) == 0}.\n\
 \n\
+On return, @var{fval} contains the value of the function @var{fcn}\n\
+evaluated at @var{x}, and @var{info} may be one of the following values:\n\
+\n\
+@table @asis\n\
+\n\
+@item -2\n\
+Invalid input parameters.\n\
+@item -1\n\
+Error in user-supplied function.\n\
+@item 1\n\
+Relative error between two consecutive iterates is at most the\n\
+specified tolerance (see @code{fsolve_options}).\n\
+@item 3\n\
+Algorithm failed to converge.\n\
+@item 4\n\
+Limit on number of function calls reached.\n\
+@end table\n\
+\n\
 If @var{fcn} is a two-element string array, or a two element cell array\n\
 containing either the function name or inline or function handle. The\n\
 first element names the function @math{f} described above, and the second\n\

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave