[J3] [SC22WG5.6473] raising a negative real value to a real power is prohibited
Van Snyder
van.snyder at sbcglobal.net
Wed Aug 23 17:47:53 UTC 2023
On Wed, 2023-08-23 at 05:58 -0700, Robert Corbett via J3 wrote:
> The restriction allows exponentiation to be implemented using
>
> exp(y*log(x))
> Computing the log of a negative number adds complexity to the
> implementation.
It's not just that it "adds complexity." The logarithm of a negative
number is complex, i.e., log(-abs(x)) = cmplx(log(abs(x)),4*atan(1.0)).
So if x and y are real, exp(y*log(x)) is complex. That is "the result
is not defined by the arithmetic." The second sentence is
"explanatory," for some definition of "explanatory," but rather opaque
if you haven't remembered your first-year calculus.
> Bob Corbett
>
> > On Aug 23, 2023, at 5:22 AM, Jeff Hammond via J3 <
> > j3 at mailman.j3-fortran.org> wrote:
> >
> >
> >
> >
> >
> > @font-face { font-family: "Cambria Math"; }
> > @font-face { font-family: Calibri; }
> > @font-face { font-family: "Times New Roman (Body CS)"; }
> > @font-face { font-family: LMSans10; }
> > @font-face { font-family: LMRoman10; }
> > p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm; font-size:
> > 11pt; font-family: Calibri, sans-serif; }
> > .MsoChpDefault { font-size: 10pt; font-family: Calibri, sans-serif;
> > }
> > @page WordSection1 { size: 612pt 792pt; margin: 72pt; }
> > div.WordSection1 { page: WordSection1; }
> >
> >
> >
> > Do I understand the following text correctly, that is, that the
> > following program is prohibited, even though it perfectly well-
> > defined mathematically?
> > “10.1.5.2.4 Evaluation of numeric intrinsic operations
> >
> > The execution of any numeric operation whose result is not defined
> > by the arithmetic used by the processor is prohibited. Raising a
> > negative real value to a real power is prohibited.”
> > program main
> > implicit none
> > real :: x, y
> > x = -2.0
> > y = 2.0
> > print*,x**y
> > end program main
> >
> > The first sentence is completely reasonable and seems sufficient to
> > cover the problematic cases. I do not understand why the second
> > sentence is necessary.
> >
> > Thanks,
> >
> > Jeff
> >
> >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230823/af70291a/attachment.htm>
More information about the J3
mailing list