Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math/cmplx: cmplx.Pow(0, x) not consistent with math.Pow(0, x) #7583

Closed
gopherbot opened this issue Mar 19, 2014 · 7 comments
Closed

math/cmplx: cmplx.Pow(0, x) not consistent with math.Pow(0, x) #7583

gopherbot opened this issue Mar 19, 2014 · 7 comments
Milestone

Comments

@gopherbot
Copy link

by spoon.reloaded:

cmplx.Pow(x, y) always returns 0 when x = 0, regardless of the value of y. Although this
is correct for positive real y, it is not necessarily a good choice for other values of
y.

cmplx.Pow(0, 0) should be 1, for consistency with math.Pow(0, 0).

cmplx.Pow(0, negative real number) should be +Inf, for consistency with math.Pow(0,
negative number).

cmplx.Pow(0, non-real number) I am not really sure about.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.3.

@gopherbot
Copy link
Author

Comment 2 by rayneolivetti:

> cmplx.Pow(0, 0) should be 1, for consistency with math.Pow(0, 0).
I don't understand the "for consistency with math package" argument here. It would
mathematically be wrong. z^w when z and w -> 0 is undefined. Similar goes for
cmplx.Log(0), it should rather return NaN.

@gopherbot
Copy link
Author

Comment 3 by rayneolivetti:

See also http://www.wolframalpha.com/input/?i=0^0

@gopherbot
Copy link
Author

Comment 4 by rayneolivetti:

The math package is also wrong.
Imagine you're plotting this: math.Pow(math.Exp(-1/x),x). For all values, including x=0,
the value should be 1/e, of course, but instead we get 1 (and this has nothing to do
with rounding errors, unlike, say, for x=1e-3).
A non-answer (NaN) is probably better than a wrong answer in general.

@gopherbot
Copy link
Author

Comment 5 by rayneolivetti:

The math package is also wrong.
Imagine you're plotting this: math.Pow(math.Exp(-1/x),x). For all values, including x=0,
the value should be 1/e, of course, but instead we get 1 (and this has nothing to do
with rounding errors, unlike, say, for x=1e-3).
A non-answer (NaN) is probably better than a wrong answer in general.

@ianlancetaylor
Copy link
Contributor

Comment 6:

There is a long history (and controversy) of math.Pow(0, 0) == 1.  Wikipedia's summary
is at http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero .  This
issue is not about math.Pow, which isn't going to change.  This issue is about
cmplx.Pow.  I tend to agree that cmplx.Pow(0, 0) should be NaN.

@robpike
Copy link
Contributor

robpike commented Mar 25, 2014

Comment 7:

This issue was closed by revision a9014ba.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants