Re: problem about exponent



On Oct 17, 11:34 am, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx>
wrote:
Mike wrote:
I have a problem about the output from following
program (I use IMSL and also IVF):

(snip)

SUBROUTINE FCN (N, X, F)
use p
INTEGER N
REAL X(N), F(N)
F(1) = X(1)-a
F(2) = (X(2)-b)**1.5    !<===   the exponent 1.5 is varied and tested.
F(3) = X(3)-7.0
print *,'fnc',a,b
RETURN
END SUBROUTINE FCN

(snip)

a=1.;b=3.;
CALL NEQBF (FCN, X, XGUESS=XGUESS,FVEC=FVEC)

(snip)

The output is Na Na Na.
I have also tested the exponent as denoted above .  If the exponent is
1., the answer is 1, 3, 7.
If the exponent is 2., the answer is 1, 2.996, 7.
If the exponent is 2.5, the answer is 1, 2.122, 7.
Why?  I expect the answer should be independent of the exponent.

Root finders will want to evaluate the function on both sides
of the root.  Since X**1.5 is undefined for negative X, it
won't be able to do that.

Note that X**2.0 and X**1.0 are also undefined for negative X.

X**1 and X**2 are defined for negative X.

-- glen

Thank you for your reminder.
I get the correct answer, after I set variables as real(8).
But I still can get correct answer, for exponent of 2.0.
Besides, do you know if there is a root finder (in IMSL or elsewhere)
which can evade this kind of undefined condition?


Mike
.



Relevant Pages