Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

making 0^0=1 and not indet

55 views
Skip to first unread message

Affan

unread,
Dec 27, 2008, 7:02:33 AM12/27/08
to
I have another question. One of the terms in my formulation involves
computing 0^0. This indeterminate form is widely accepted to be equal
to 1 and if this form was used all of my equation can be solved
separately (without having to worry about some corner case). Is there
some way to force mathematica to use 0^0=1?


Thanks

Affan

Sjoerd C. de Vries

unread,
Dec 29, 2008, 6:33:12 AM12/29/08
to
Unprotect[Power];
Power[0, 0] = 1;
Protect[Power];

Cheers -- Sjoerd

Raffy

unread,
Dec 29, 2008, 6:34:58 AM12/29/08
to
Unprotect[Power];
Power /: 0^0 = 1;
Protect[Power];

Jens-Peer Kuska

unread,
Dec 29, 2008, 6:36:33 AM12/29/08
to
Hi,

Unprotect[Power]
Power[0, 0] = 1
Protect[Power]

the correct way is to use Limit[] and not this
brutal method. But with the code above,

{0^0, Sin[0]^0, Sin[0]^Sin[0]}

work as expected.

Regards
Jens

Steven Siew

unread,
Dec 29, 2008, 6:37:05 AM12/29/08
to
Try this

Mathematica 5.2 for Students: Microsoft Windows Version
Copyright 1988-2005 Wolfram Research, Inc.

In[1]:=
Out[1]= {stdout}

In[2]:= (* Write your mathematica code below *)

In[3]:= 0^0

0
Power::indet: Indeterminate expression 0 encountered.

Out[3]= Indeterminate

In[4]:= FullForm[Hold[0^0]]

Out[4]//FullForm= Hold[Power[0, 0]]

In[5]:= Power[0,0]

0
Power::indet: Indeterminate expression 0 encountered.

Out[5]= Indeterminate

In[6]:= Unprotect[Power];

In[7]:= Power[0,0]=1

Out[7]= 1

In[8]:= Power[0.,0.]=1.

Out[8]= 1.

In[9]:= Protect[Power];

In[10]:= Power[0,0]

Out[10]= 1

In[11]:= 0^0

Out[11]= 1

In[12]:= Power[0.,0.]

Out[12]= 1.

In[13]:= (* End of mathematica code *)

In[14]:= Quit[];

Bob Hanlon

unread,
Dec 29, 2008, 6:38:41 AM12/29/08
to
f1[n_ /; n == 0, x_ /; x == 0] = 1;
f1[n_, x_] := x^n;

f2[n_, x_] := If[n == x == 0, 1, x^n];

f3[n_, x_] := (x + DiscreteDelta[n, x])^n;

f4[n_, x_] := (x + KroneckerDelta[0, n, x])^n;

And @@
Flatten[
Table[
f1[n, x] == f2[n, x] == f3[n, x] == f4[n, x],
{n, 0, 3}, {x, -3, 3}]]

True

Bob Hanlon

dreeves

unread,
Dec 29, 2008, 6:38:52 AM12/29/08
to
This will redefine 0^0 for both integers and machine-precision
numbers:

Unprotect[Power];
0^0 = 1;
0^0. = 1;
0.^0 = 1;
0.^0. = 1;
Protect[Power];

Random plug: I think StackOverflow.com would be a nice forum for
questions like this. It's a pretty amazing resource for general
programming questions. There's not a lot of mathematica specific
stuff there yet (though there's some).

Szabolcs Horvát

unread,
Dec 29, 2008, 6:39:35 AM12/29/08
to

It's always difficult to answer these questions if you give no concrete
examples where the problem appears.

Of course you can always do

Unprotect[Power]
0^0 = 1

Protect[Power]

Will it solve your problem? I don't know.
Will it mess up anything else in Mathematica? I don't know that either,
but I certainly wouldn't feel comfortable with it.

--
Szabolcs

Peter Pein

unread,
Dec 29, 2008, 6:41:53 AM12/29/08
to
Affan schrieb:

In[1]:=
Unprotect[Power];
Power /: 0^0 := 1;
Protect[Power];

(Pi - x)^Sin[x] /. x -> Pi

Out[4]=
1

works, but don't forget to restart the kernel, after these calculations
(or Unprotect[Power] again, let DownValues[Power]={} and Protect[Power]).

Peter

Jean-Marc Gulliet

unread,
Dec 29, 2008, 6:42:35 AM12/29/08
to
Affan wrote:

The expression 0^0 is represented internally as Power[0, 0] so you could
add a new rule to the built-in function *Power* as follows:

Unprotect[Power];
Power[0, 0] = 1;

Protect[Power];

For instance,

In[1]:= 0^0
FullForm[HoldForm[0^0]]


Unprotect[Power];
Power[0, 0] = 1;

Protect[Power];
0^0

During evaluation of In[1]:= Power::indet: Indeterminate expression 0^0
encountered.

Out[1]= Indeterminate

Out[2]//FullForm= HoldForm[Power[0,0]]

Out[6]= 1

Also, the short tutorial "Modifying Built-in Functions" might be worth
reading (in addition to the help pages for Protect/Unprotect):

http://reference.wolfram.com/mathematica/tutorial/ModifyingBuiltInFunctions.html

tutorial/ModifyingBuiltInFunctions

Regards,
-- Jean-Marc

0 new messages