fsolve problem

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

fsolve problem

by Rolf Fabian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 ?
What is the meaning of the 2nd element of 'fval'?

Why is a column vector x returned
despite the fact that initialization is
done by a row vector ?

Cannot find anything about those
questions in documentation.

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


Follow by:
octave-3.0.0.exe:> computer, version
i686-pc-msdosmsvc
ans = 3.0.0

octave-3.0.0.exe:> format long
octave-3.0.0.exe:> [x,fval,info]  =  fsolve( F="x(1).^19+x(2).^19 - 1", x0= rand(1,2)*10)
x =
   4.48467415438827
   6.75774358978933

fval =
   5.83998986277861e+015          # < --- !!!
   4.69824018802541e-294

info =  1                                     # < --- !!!

octave-3.0.0.exe:> eval(F)
ans = 5.83998986277861e+015   # < --- !!!

octave-3.0.0.exe:> x0
x0 =
   4.48467415438827   6.75774358978933

octave-3.0.0.exe:> x0.' - x
ans =
   0
   0
Rolf Fabian
<r dot fabian at jacobs-university dot de>

fsolve problem

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: fsolve problem

by Rolf Fabian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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

Re: fsolve problem

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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