[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Scheme-reports] Definition of expt when the base is exact 0 (was Re: John Cowan's votes and rationales on the seventh ballot)
Hi Alex,
On 09/19/2012 01:40 AM, Alex Shinn wrote:
> On Wed, Sep 19, 2012 at 1:47 PM, Mark H Weaver<mhw@x> wrote:
>> On 09/18/2012 11:40 PM, Alex Shinn wrote:
>>> I prefer my earlier wording:
>>>
>>> The value of 0^z is 1 if (zero? z), 0 if (real-part z)
>>> is positive, and an error otherwise. Similarly for 0.0^z,
>>> with inexact results.
>>
>>
>> This wording has serious flaws. It suggests that for the cases specified
>> above, the exactness of the result depends only on the exactness of the
>> base. For example, it suggests that (expt 0 0.0) => 1 and (expt 0.0 0) =>
>> 1.0.
>
> If you think the wording is bad, it would be nice if you
> suggested an alternate wording. As it is, this is more
> clear than R5RS or R6RS, and I was hoping to avoid
> listing out all 12 cases of signs and exactness.
I will work on a proposed wording. It needn't be that complicated.
> I was trying to clean up the simplification "usual rules
> of inexact contagion" but we can put that back in,
> so that (expt 0 0.0) => 1.0.
>
>> On the contrary, (expt<anything> 0) should yield an exact 1
>
> I disagree, but this is just a convention, and there is
> disagreement in the community about whether even
> (* 0 x) is allowed to return exact 0 for inexact x.
I explained the rationale for (expt <anything> 0) => 1 in my reply to
John Cowan.
>> Furthermore, I challenge anyone to justify (= 1 (expt 0 0.0)), or for that
>> matter the claim that (expt 0<non-integer>) is well-defined. I'm not aware
>> of any established definition for 'expt' that can justify these claims.
>
> (expt 0 1/2) => (sqrt 0) => 0, what's the problem there?
That's a specific example that could perhaps be extended to positive
rational exponents, but I'm questioning the validity of the general rule
that (expt 0 <non-integer>) is well-defined for an arbitrary exponent
with positive real part. Consider (expt 0 pi) for example, or (expt 0
1.3+1.4i).
> More generally, there is a well-established definition
> of complex exponentiation, a simple explanation of
> which is in the wikipedia article on the topic.
>
> Given complex numbers w and z with:
>
> w = re^iθ in polar notation
> z = c + di
>
> then
>
> w^z = (r^c e^-dθ) [cod(d log(r) + cθ) + i sin(d log(r) + cθ)]
>
> Now when w is 0, then r is 0 and the factor r^c is
> only defined when c (i.e. (real-part z)) is positive.
log(r) is undefined when r is exact 0. Furthermore, you're begging the
question here. The problem is that you've started with a definition of
complex expt in terms of real expt.
We need to start with the conventional definitions of (expt w z), of
which there are two:
1. If z is an (exact?) non-negative integer, then (expt w z) may be
defined as (* w w w w ...) with 'z' copies of 'w'.
2. (expt w z) => (exp (* z (log w))).
The second definition can be used when 'w' is an _inexact_ zero, because
in that case a limit is used to evaluate (log w), which results in
-inf.0+??i, where the imaginary part is (angle w). Note that there are
potentially eight different kinds of inexact zeroes: +0.0, -0.0, +0.0i,
-0.0i, +0.0+0.0i, +0.0-0.0i, -0.0+0.0i, and -0.0-0.0i.
When 'w' is an _exact_ zero, then the second definition cannot be used
at all, because a limit is no longer appropriate, and indeed (log 0) is
an error. Therefore, we must rely on the first definition, which is
only applicable when the exponent is an (exact?) integer.
Regards,
Mark
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports