From owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org  Wed Aug 24 15:57:14 2016
Return-Path: <owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom8
Delivered-To: sc22wg5-dom8@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id BF31E35872B; Wed, 24 Aug 2016 15:57:14 +0200 (CEST)
Delivered-To: sc22wg5@open-std.org
Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48])
	(using TLSv1 with cipher AES128-SHA (128/128 bits))
	(No client certificate requested)
	by www.open-std.org (Postfix) with ESMTP id D562D3568F8
	for <sc22wg5@open-std.org>; Wed, 24 Aug 2016 15:57:11 +0200 (CEST)
Received: by mail-wm0-f48.google.com with SMTP id q128so203003171wma.1
        for <sc22wg5@open-std.org>; Wed, 24 Aug 2016 06:57:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=bris-ac-uk.20150623.gappssmtp.com; s=20150623;
        h=date:from:message-id:to:subject:reply-to:in-reply-to;
        bh=vihC15relBO/HqM11BrgpLQ15skrswTw8y3ZAtiqVSs=;
        b=JzybshRR0CUOkuF2tc44RQkz9n9+obtTysex80R2T9QwqFL3ui81+4ssgvwqwamys3
         0OhyqOMcZ6REvsptvVqGMOGXVAwkR6Pn1zfL5Oe1lkZvKUjqmvmXfUF+YeDko4c3vUWv
         g0iU1ZJoVJ29dMg2g1SqHSOxMeDo7OOv/CHYsDkM7XDsuPmHinqK1P2+Q87JSKwi78vD
         EQ7l2Lg3xknRUMX0+8RTCOj3fQxnYZINlhps5pmmW2qLgJWe3Kykvm71kmoFLDbJu4EN
         uv9G2FcV1KtB9w22KR8o3WL+5Gd959poZ+GyuuwgTXDu93Hih4YA3VBNBWhOjruprYiE
         2D/A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:message-id:to:subject:reply-to
         :in-reply-to;
        bh=vihC15relBO/HqM11BrgpLQ15skrswTw8y3ZAtiqVSs=;
        b=P9rOw8qxiVKHaolgd7sNJr+63v/uVsWRfiIiiHHPz41mkOTP4VFOl2dkKvYzRULacn
         IljNVTlUeQqVKIB1neUopdqs9Wq/fkvZosjTGPIiiGKY4nvUwE21mbDlBd2Nmx16Gtbx
         6KoX8VuiwhQx84LRfqaMurL7EvmqqHaivzGlxW8PbULiH0aeCJOtt/C77Kky2bDHXHz0
         sQpFjOj5UUItbg8wdVray8W2Hmm1AhiyJsmsG4D2xN7hoZr5S3HdY6JYdrmtwci9Vxsl
         vqIpitd8o5fw2CwveZmnWRUIjC4kqo7UjNsMTvtpUi41Du/hMac3evknA8nQ20BTA1vM
         ZiOg==
X-Gm-Message-State: AEkooutGsChCC0fpj6RPFrCS/V5jOfwHCETapAXze0XBm+MuSJ2Ca0GtNrrszoDeRr5huR+T
X-Received: by 10.194.78.74 with SMTP id z10mr2822075wjw.68.1472047030607;
        Wed, 24 Aug 2016 06:57:10 -0700 (PDT)
Received: from mech-as222.men.bris.ac.uk (mech-as222.men.bris.ac.uk. [137.222.170.4])
        by smtp.gmail.com with ESMTPSA id q65sm10739652wmd.24.2016.08.24.06.57.09
        for <sc22wg5@open-std.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 24 Aug 2016 06:57:10 -0700 (PDT)
Received: from mech-as222.men.bris.ac.uk (localhost [127.0.0.1])
	by mech-as222.men.bris.ac.uk (8.15.2/8.15.2) with ESMTP id u7ODv9mv083791
	for <sc22wg5@open-std.org>; Wed, 24 Aug 2016 14:57:09 +0100 (BST)
	(envelope-from mexas@mech-as222.men.bris.ac.uk)
Received: (from mexas@localhost)
	by mech-as222.men.bris.ac.uk (8.15.2/8.15.2/Submit) id u7ODv9Lk083790
	for sc22wg5@open-std.org; Wed, 24 Aug 2016 14:57:09 +0100 (BST)
	(envelope-from mexas)
Date: Wed, 24 Aug 2016 14:57:09 +0100 (BST)
From: Anton Shterenlikht <mexas@bris.ac.uk>
Message-Id: <201608241357.u7ODv9Lk083790@mech-as222.men.bris.ac.uk>
To: sc22wg5@open-std.org
Subject: Re: (j3.2006) (SC22WG5.5780) edits to clarify SQRT treatment of negative zero, for comments
Reply-To: mexas@bris.ac.uk
In-Reply-To: <bf0ff08d-c545-63fe-968a-4bf04bfb2142@oracle.com>
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

>From: Robert Corbett <robert.corbett@oracle.com>
>>
>> and negative zero [394:31-395:3], and SQRT(X)
>> is mathematically equivalent to EXP( 0.5 * LOG(X) ).
>
>They are not mathematically equivalent when X is zero.
>In that case, SQRT(X) is well-defined, but the expression
>EXP( 0.5 * LOG(X) ) is mathematical nonsense, because the
>log of zero is undefined.

The real part of log of zero is well defined - it is minus infinity.
Hence exp( log(x) ) is also well defined - it is zero.

With ieee 754, when infinity is a valid numerical
value, the two expressions are computationally
equivalent too. 3 out of 3 compilers agree with me:

complex :: z
z = cmplx( 0.0, 0.0 )
write (*,*) log( z )
write (*,*) exp( log( z ) )
end

gives:

 (-Infinity,0.)
 (0.,0.)

Yes, log of zero is not allowed by [394:28-29].
Perhaps this restriction should be relaxed,
e.g. as was suggested in F03/0042:
 http://j3-fortran.org/doc/meeting/210/16-006.txt 
- for real X, when X is zero, LOG(X) is minus infinity
  for both positive and negative zero X.
- for complex X, when X is zero, the real part of LOG(X)
  is minus infinity, the imaginary part of LOG(X) is
  a processor dependent value between -pi and +pi.

Such addition would help write portable
complex algebra programs for systems supporting ieee 754.

Anton
