Just noticed that Wikipedia on "Del in cylindrical and spherical
coordinates" has errors in this area but "Argument (complex analysis)"
seems OK. In particular if the Cartesian, cylindrical and spherical
coordinates of the same point are (x,y,z), (rho,phi,z), (r,theta,phi)
then theta /= arctan(rho/z) if z<0, because LHS > pi/2 but RHS < 0,
and phi /= arctan(y/x) if x < 0 because RHS is in (-pi/2,pi/2) but
abs(LHS) > pi/2. Of course some textbooks of complex analysis also get
arg(x+i*y) wrong.
Fri, 19 Aug 2016, Anton Shterenlikht
wrote:
> Date: Fri, 19 Aug 2016 09:46:44 +0100
> From: Anton Shterenlikht <[log in to unmask]>
> Reply-To: Fortran 90 List <[log in to unmask]>
> To: [log in to unmask]
> Subject: Re: COMP-FORTRAN-90 Digest - 16 Aug 2016 to 17 Aug 2016 (#2016-29)
>
> Yes, and possibly the compiler version too,
> and possibly the platform, etc.
> For example on linux with ifort 16.0.2 20160204
> I don't need to specify any compiler options:
>
> implicit none
> complex :: z1 = (-4.0, -0.0), z2 = (-4.0, 0.0)
> write (*,*) log(z1), log(z2)
> write (*,*) sqrt(z1), sqrt(z2)
> write (*,*) exp(0.5 * log(z1)), exp(0.5 * log(z2))
> end
>
> The output:
>
> (1.386294,-3.141593) (1.386294,3.141593)
> (0.0000000E+00,-2.000000) (0.0000000E+00,2.000000)
> (-8.7422784E-08,-2.000000) (-8.7422784E-08,2.000000)
>
> Anyway, I believe these are the correct answers,
> on a f08 conforming processor that distinguishes +0 and -0
> (list directed output formatting, and floating point
> precision issues aside).
>
> The rules for LOG are the key, [394:31-395:3].
> The standard uses the most mainstream
> rules for the branch cut and the interpretation
> of the -pi and +pi phases,
> when +0 and -0 can be distinguished.
>
> The SQRT rule "When the real part
> of the result is zero, the imaginary
> part has the same sign as the
> imaginary part of X.", [424:7-8],
> is just a consequence of the LOG rules.
>
> My original question was
> whether SQRT distinguishes -0.
> [56:21-25] says "Processors that
> distinguish between positive and
> negative zero shall treat them
> as mathematically equivalent...
> as actual arguments to intrinsic
> procedures other than those for
> which it is explicitly specified
> that negative zero is distinguished."
> SQRT does not "explicitly specify"
> that, so it appears that it does
> not distinguish +0 and -0.
> But this is incorrect, SQRT does
> indeed distinguish +0 and -0
> (again on processors which distinguish
> +0 and -0). It must do this to be
> consistent with LOG.
>
> I suggest to replace
> the last sentence of SQRT with
> that which closely resembles the
> last sentence of LOG.
>
> I also think that "principal" in
> [424:7] means the same as
> "the real part greater than or equal to zero".
> So this seems an unnecessary repetition.
> I suggest to remove "principal" from [424:7].
>
> So:
>
> [424:6-8] replace "A result ... imaginary part of X."
> with
> "A result of type complex is the value with
> the real part greater than or equal to zero.
> If the real part of X is less
> than zero and the imaginary
> part of X is zero, then the
> imaginary part of the result is
> positive if the imaginary part of X
> is positive real zero or the
> processor does not distinguish
> between positive and negative zero,
> and negative if the imaginary
> part of X is negative real zero."
>
> Anton
>
-- John Harper, School of Mathematics and Statistics
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail [log in to unmask] phone (+64)(4)463 5276 fax (+64)(4)463 5045
|