Why 0 ** 0 equals 1 in python
Why does 0 ** 0
equal 1
in Python? Shouldn't it throw an exception, like 0 / 0
does?
python math
|
show 4 more comments
Why does 0 ** 0
equal 1
in Python? Shouldn't it throw an exception, like 0 / 0
does?
python math
9
Since x^0 = 1...
– Anders Lindahl
Jan 19 '13 at 12:39
6
Because it should equal 1?
– Martijn Pieters♦
Jan 19 '13 at 12:41
8
@AndersLindahl: Calculus teaches us that 0^0 is an indeterminate form. Hence why the OP is asking.
– Michael Foukarakis
Jan 19 '13 at 12:42
3
+1: For enlightening me.
– Abhijit
Jan 19 '13 at 12:50
5
@AndersLindahl, oh please, I could say that 0^x = 0...
– kaspersky
Jan 19 '13 at 12:50
|
show 4 more comments
Why does 0 ** 0
equal 1
in Python? Shouldn't it throw an exception, like 0 / 0
does?
python math
Why does 0 ** 0
equal 1
in Python? Shouldn't it throw an exception, like 0 / 0
does?
python math
python math
edited Jan 19 '13 at 12:39
Jon Clements♦
101k19178221
101k19178221
asked Jan 19 '13 at 12:37
kasperskykaspersky
2,43422042
2,43422042
9
Since x^0 = 1...
– Anders Lindahl
Jan 19 '13 at 12:39
6
Because it should equal 1?
– Martijn Pieters♦
Jan 19 '13 at 12:41
8
@AndersLindahl: Calculus teaches us that 0^0 is an indeterminate form. Hence why the OP is asking.
– Michael Foukarakis
Jan 19 '13 at 12:42
3
+1: For enlightening me.
– Abhijit
Jan 19 '13 at 12:50
5
@AndersLindahl, oh please, I could say that 0^x = 0...
– kaspersky
Jan 19 '13 at 12:50
|
show 4 more comments
9
Since x^0 = 1...
– Anders Lindahl
Jan 19 '13 at 12:39
6
Because it should equal 1?
– Martijn Pieters♦
Jan 19 '13 at 12:41
8
@AndersLindahl: Calculus teaches us that 0^0 is an indeterminate form. Hence why the OP is asking.
– Michael Foukarakis
Jan 19 '13 at 12:42
3
+1: For enlightening me.
– Abhijit
Jan 19 '13 at 12:50
5
@AndersLindahl, oh please, I could say that 0^x = 0...
– kaspersky
Jan 19 '13 at 12:50
9
9
Since x^0 = 1...
– Anders Lindahl
Jan 19 '13 at 12:39
Since x^0 = 1...
– Anders Lindahl
Jan 19 '13 at 12:39
6
6
Because it should equal 1?
– Martijn Pieters♦
Jan 19 '13 at 12:41
Because it should equal 1?
– Martijn Pieters♦
Jan 19 '13 at 12:41
8
8
@AndersLindahl: Calculus teaches us that 0^0 is an indeterminate form. Hence why the OP is asking.
– Michael Foukarakis
Jan 19 '13 at 12:42
@AndersLindahl: Calculus teaches us that 0^0 is an indeterminate form. Hence why the OP is asking.
– Michael Foukarakis
Jan 19 '13 at 12:42
3
3
+1: For enlightening me.
– Abhijit
Jan 19 '13 at 12:50
+1: For enlightening me.
– Abhijit
Jan 19 '13 at 12:50
5
5
@AndersLindahl, oh please, I could say that 0^x = 0...
– kaspersky
Jan 19 '13 at 12:50
@AndersLindahl, oh please, I could say that 0^x = 0...
– kaspersky
Jan 19 '13 at 12:50
|
show 4 more comments
2 Answers
2
active
oldest
votes
Wikipedia has interesting coverage of the history and the differing points of view on the value of 0 ** 0
:
The debate has been going on at least since the early 19th century. At that time, most mathematicians agreed that
0 ** 0 = 1
, until in 1821 Cauchy listed0 ** 0
along with expressions like0⁄0
in a table of undefined forms. In the 1830s Libri published an unconvincing argument for0 ** 0 = 1
, and Möbius sided with him...
As applied to computers, IEEE 754 recommends several functions for computing a power. It defines pow(0, 0)
and pown(0, 0)
as returning 1
, and powr(0, 0)
as returning NaN
.
Most programming languages follow the convention that 0 ** 0 == 1
. Python is no exception, both for integer and floating-point arguments.
1
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
add a comment |
consider x^x
:
Using limits we can easily get to our solution and rearranging x^x
we get :
x^x= exp(log(x^x))
Now , we have from:
lim x->0 exp(log(x^x))= exp(lim x->0 xlog(x)) = exp(lim x->0 log(x)/(x^-1))
Applying L'Hôpital
rule , we get :
exp(lim x^-1/(-x^-2)) = exp(lim x->0 -x) = exp(0) = 1=x^x
But according to Wolfram Alpha 0**0
is indeterminate and following explanations were obtained by them :
0^0 itself is undefined. The lack of a well-defined meaning for this
quantity follows from the mutually contradictory facts that a^0 is
always 1, so 0^0 should equal 1, but 0^a is always 0 (for a>0), so 0^0
should equal 0. It could be argued that 0^0=1 is a natural definition
since lim_(n->0)n^n=lim_(n->0^+)n^n=lim_(n->0^-)n^n=1.
However, the limit does not exist for general complex values of n. Therefore, the choice of
definition for 0^0 is usually defined to be indeterminate."
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
great answer :P
– Mitul Shah
May 8 '14 at 8:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14414430%2fwhy-0-0-equals-1-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Wikipedia has interesting coverage of the history and the differing points of view on the value of 0 ** 0
:
The debate has been going on at least since the early 19th century. At that time, most mathematicians agreed that
0 ** 0 = 1
, until in 1821 Cauchy listed0 ** 0
along with expressions like0⁄0
in a table of undefined forms. In the 1830s Libri published an unconvincing argument for0 ** 0 = 1
, and Möbius sided with him...
As applied to computers, IEEE 754 recommends several functions for computing a power. It defines pow(0, 0)
and pown(0, 0)
as returning 1
, and powr(0, 0)
as returning NaN
.
Most programming languages follow the convention that 0 ** 0 == 1
. Python is no exception, both for integer and floating-point arguments.
1
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
add a comment |
Wikipedia has interesting coverage of the history and the differing points of view on the value of 0 ** 0
:
The debate has been going on at least since the early 19th century. At that time, most mathematicians agreed that
0 ** 0 = 1
, until in 1821 Cauchy listed0 ** 0
along with expressions like0⁄0
in a table of undefined forms. In the 1830s Libri published an unconvincing argument for0 ** 0 = 1
, and Möbius sided with him...
As applied to computers, IEEE 754 recommends several functions for computing a power. It defines pow(0, 0)
and pown(0, 0)
as returning 1
, and powr(0, 0)
as returning NaN
.
Most programming languages follow the convention that 0 ** 0 == 1
. Python is no exception, both for integer and floating-point arguments.
1
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
add a comment |
Wikipedia has interesting coverage of the history and the differing points of view on the value of 0 ** 0
:
The debate has been going on at least since the early 19th century. At that time, most mathematicians agreed that
0 ** 0 = 1
, until in 1821 Cauchy listed0 ** 0
along with expressions like0⁄0
in a table of undefined forms. In the 1830s Libri published an unconvincing argument for0 ** 0 = 1
, and Möbius sided with him...
As applied to computers, IEEE 754 recommends several functions for computing a power. It defines pow(0, 0)
and pown(0, 0)
as returning 1
, and powr(0, 0)
as returning NaN
.
Most programming languages follow the convention that 0 ** 0 == 1
. Python is no exception, both for integer and floating-point arguments.
Wikipedia has interesting coverage of the history and the differing points of view on the value of 0 ** 0
:
The debate has been going on at least since the early 19th century. At that time, most mathematicians agreed that
0 ** 0 = 1
, until in 1821 Cauchy listed0 ** 0
along with expressions like0⁄0
in a table of undefined forms. In the 1830s Libri published an unconvincing argument for0 ** 0 = 1
, and Möbius sided with him...
As applied to computers, IEEE 754 recommends several functions for computing a power. It defines pow(0, 0)
and pown(0, 0)
as returning 1
, and powr(0, 0)
as returning NaN
.
Most programming languages follow the convention that 0 ** 0 == 1
. Python is no exception, both for integer and floating-point arguments.
edited Jan 3 at 7:22
tripleee
94.7k13133187
94.7k13133187
answered Jan 19 '13 at 12:43
NPENPE
356k67759889
356k67759889
1
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
add a comment |
1
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
1
1
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
I always thought that 0 ^ 0 is undefined, just like division by 0, but never thought it could be so tricky. I think the explanation on wikipedia is very good, also explaining why other people think it should be 1, and it also covers the answer to my question, related to Python.
– kaspersky
Jan 19 '13 at 13:05
add a comment |
consider x^x
:
Using limits we can easily get to our solution and rearranging x^x
we get :
x^x= exp(log(x^x))
Now , we have from:
lim x->0 exp(log(x^x))= exp(lim x->0 xlog(x)) = exp(lim x->0 log(x)/(x^-1))
Applying L'Hôpital
rule , we get :
exp(lim x^-1/(-x^-2)) = exp(lim x->0 -x) = exp(0) = 1=x^x
But according to Wolfram Alpha 0**0
is indeterminate and following explanations were obtained by them :
0^0 itself is undefined. The lack of a well-defined meaning for this
quantity follows from the mutually contradictory facts that a^0 is
always 1, so 0^0 should equal 1, but 0^a is always 0 (for a>0), so 0^0
should equal 0. It could be argued that 0^0=1 is a natural definition
since lim_(n->0)n^n=lim_(n->0^+)n^n=lim_(n->0^-)n^n=1.
However, the limit does not exist for general complex values of n. Therefore, the choice of
definition for 0^0 is usually defined to be indeterminate."
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
great answer :P
– Mitul Shah
May 8 '14 at 8:59
add a comment |
consider x^x
:
Using limits we can easily get to our solution and rearranging x^x
we get :
x^x= exp(log(x^x))
Now , we have from:
lim x->0 exp(log(x^x))= exp(lim x->0 xlog(x)) = exp(lim x->0 log(x)/(x^-1))
Applying L'Hôpital
rule , we get :
exp(lim x^-1/(-x^-2)) = exp(lim x->0 -x) = exp(0) = 1=x^x
But according to Wolfram Alpha 0**0
is indeterminate and following explanations were obtained by them :
0^0 itself is undefined. The lack of a well-defined meaning for this
quantity follows from the mutually contradictory facts that a^0 is
always 1, so 0^0 should equal 1, but 0^a is always 0 (for a>0), so 0^0
should equal 0. It could be argued that 0^0=1 is a natural definition
since lim_(n->0)n^n=lim_(n->0^+)n^n=lim_(n->0^-)n^n=1.
However, the limit does not exist for general complex values of n. Therefore, the choice of
definition for 0^0 is usually defined to be indeterminate."
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
great answer :P
– Mitul Shah
May 8 '14 at 8:59
add a comment |
consider x^x
:
Using limits we can easily get to our solution and rearranging x^x
we get :
x^x= exp(log(x^x))
Now , we have from:
lim x->0 exp(log(x^x))= exp(lim x->0 xlog(x)) = exp(lim x->0 log(x)/(x^-1))
Applying L'Hôpital
rule , we get :
exp(lim x^-1/(-x^-2)) = exp(lim x->0 -x) = exp(0) = 1=x^x
But according to Wolfram Alpha 0**0
is indeterminate and following explanations were obtained by them :
0^0 itself is undefined. The lack of a well-defined meaning for this
quantity follows from the mutually contradictory facts that a^0 is
always 1, so 0^0 should equal 1, but 0^a is always 0 (for a>0), so 0^0
should equal 0. It could be argued that 0^0=1 is a natural definition
since lim_(n->0)n^n=lim_(n->0^+)n^n=lim_(n->0^-)n^n=1.
However, the limit does not exist for general complex values of n. Therefore, the choice of
definition for 0^0 is usually defined to be indeterminate."
consider x^x
:
Using limits we can easily get to our solution and rearranging x^x
we get :
x^x= exp(log(x^x))
Now , we have from:
lim x->0 exp(log(x^x))= exp(lim x->0 xlog(x)) = exp(lim x->0 log(x)/(x^-1))
Applying L'Hôpital
rule , we get :
exp(lim x^-1/(-x^-2)) = exp(lim x->0 -x) = exp(0) = 1=x^x
But according to Wolfram Alpha 0**0
is indeterminate and following explanations were obtained by them :
0^0 itself is undefined. The lack of a well-defined meaning for this
quantity follows from the mutually contradictory facts that a^0 is
always 1, so 0^0 should equal 1, but 0^a is always 0 (for a>0), so 0^0
should equal 0. It could be argued that 0^0=1 is a natural definition
since lim_(n->0)n^n=lim_(n->0^+)n^n=lim_(n->0^-)n^n=1.
However, the limit does not exist for general complex values of n. Therefore, the choice of
definition for 0^0 is usually defined to be indeterminate."
edited Jan 19 '13 at 13:23
Ashwini Chaudhary
179k35325391
179k35325391
answered Jan 19 '13 at 12:59
Pj_Pj_
771414
771414
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
great answer :P
– Mitul Shah
May 8 '14 at 8:59
add a comment |
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
great answer :P
– Mitul Shah
May 8 '14 at 8:59
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
You also could show that lim x->0 C/x = Inf (where C is some constant), but still, division by zero is undefined. So, C/x, when x->0 isn't the same as C/0. The same principle apply for x^x, you showed it is 1 when x->0, but that doesn't tell anything about the actual 0^0.
– kaspersky
Jan 19 '13 at 18:40
great answer :P
– Mitul Shah
May 8 '14 at 8:59
great answer :P
– Mitul Shah
May 8 '14 at 8:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14414430%2fwhy-0-0-equals-1-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
9
Since x^0 = 1...
– Anders Lindahl
Jan 19 '13 at 12:39
6
Because it should equal 1?
– Martijn Pieters♦
Jan 19 '13 at 12:41
8
@AndersLindahl: Calculus teaches us that 0^0 is an indeterminate form. Hence why the OP is asking.
– Michael Foukarakis
Jan 19 '13 at 12:42
3
+1: For enlightening me.
– Abhijit
Jan 19 '13 at 12:50
5
@AndersLindahl, oh please, I could say that 0^x = 0...
– kaspersky
Jan 19 '13 at 12:50