| Mathematically, X**0.5 and SQRT(X) are the same, but in complex G floating
FORTRAN will call the complex exponentiation library routine for the
former and will call the complex square root routine for the latter.
Since these both involve approximations there can be a slight relative
error.
In real E and D floating, the compiler will special case exponentiation
by 0.5 to a call to SQRT, so the results are identical in that case.
- Jim
|
| I did not understand .1 at first, but it is basically correct!
While I have not looked at the routines involved, a good guess is
that you have found your way into a very general purpose exponentiation
routine, and have obtained a result that is accurate to within a
few bits (despite the way it looks). Without getting into a long
numerical analysis answer, it may be easier to understand if you
think about the answer as not an X and Y coordinate answer, but
one expressed as magnitude and angle (in the complex plane). When
viewed that way, the angle is VERY small (as it should be), but
not zero (as intuition tells us it must be). One other small comment
should be made - your -1E50 is not exact; it cannot be exactly
represented within the real*8 world. This is not part of why your
answer is the way it is, just a comment. While I doubt that you
have reason to cause the exponentiation routine to change, it is
possible to special case such arguments with a zero imaginary part,
to get a more "expected" result. However, the answer you got is
numerically almost as good - it just doesn't fit well with what
we "know" is the "real" answer!
Dave E
|