fsolve problem

John W. Eaton jwe at bevo.che.wisc.edu
Wed Feb 20 12:19:59 CST 2008


On 20-Feb-2008, Rolf Fabian wrote:

| 
| 
| John W. Eaton wrote:
| > 
| > On 20-Feb-2008, Rolf Fabian wrote:
| > 
| > | 
| > | For functions like e.g.
| > |      F = "x(1).^19 + x(2).^19 - 1"
| > | fsolve returns output x == input x0 as well as successful
| > | iteration  flag (info =1) despite the fact that
| > | fval(1) > 10^15 which is definitely far from zero.
| > | 
| > | BTW 
| > | Why is 'fval' not a scalar ?
| > 
| > Because Octave's fsolve expects to be solving square systems.  It
| > should detect this and fail.
| > 
| > jwe
| > 
| > 
| 
| 
| Your answer confuses me a bit because e.g. the following example works
| perfectly
| as expected ( apart from the 'extra' output of fval and the transposition of
| output x)
| even though it is not 'square':
| 
| octave-3.0.0.exe:> [x,fval,info]  =  fsolve( F = "x(1).^5+x(2).^5 - 1",  x0=
| rand(1,2) )
| x =
|    0.999989047698090
|    0.140505453056555
| 
| fval =
|    2.22044604925031e-016
|    4.69821032358962e-294
| 
| info =  1
| 
| octave-3.0.0.exe:> x0
| x0 =
|    0.934687064878899   0.140505560616182
| 
| octave-3.0.0.exe:> eval(F)
| ans = 2.22044604925031e-016

I guess this one just happens to work out.  It is certainly not
because the software is designed to solve this problem.

Ultimately, fsolve calls hybrd1 (or hybrj1, if you are providing a
Jacobian):

C     SUBROUTINE HYBRD1
C
C     THE PURPOSE OF HYBRD1 IS TO FIND A ZERO OF A SYSTEM OF
C     N NONLINEAR FUNCTIONS IN N VARIABLES BY A MODIFICATION
C     OF THE POWELL HYBRID METHOD. THIS IS DONE BY USING THE
C     MORE GENERAL NONLINEAR EQUATION SOLVER HYBRD. THE USER
C     MUST PROVIDE A SUBROUTINE WHICH CALCULATES THE FUNCTIONS.
C     THE JACOBIAN IS THEN CALCULATED BY A FORWARD-DIFFERENCE
C     APPROXIMATION.

So I don't think it is intended to solve problems like yours.  Given
that, I think fsolve should detect that your function returns a vector
with a size different from X0 and fail with an error message.

jwe



More information about the Bug-octave mailing list