# Could I define 0^0 to be 1? [duplicate]

Many occasions, where I need to work numerically with functions. For a variable strictly between 0 and 1, during the optimization, it could become 0.^0 or 0^0, which then become indeterminate.

Is there a way to define this 0^0=1?

What are the possible down side of defining such relationship?

Thanks!

## marked as duplicate by Mr.Wizard♦Oct 27 '14 at 5:44

With the help of @Michael E2 in my question

Case $\frac{0}{0}$

In this case,you can define your function like this:

func1[a_,b_]:=0 /;b==0
func1[a_,b_]:=a/b


Test

func1[0, 0]

1


Case$0.^0$

So you can use the /; to avoid $0.^0$

func2[x_,0]:=1/;x==0||x==0.
func2[x_,y_:0]:=x^y


Test

 func2[0, 0]

1

 func2[0., 0]

1


Yes, by doing this (similar to this):

Unprotect[Power];
Power[0|0., 0|0.] = 1;
Protect[Power];


If you want to revert to normal:

Unprotect[Power];
ClearAll[Power];
Protect[Power];


The downside is that it doesn't make sense mathematically, and from a false premise you could reach a false conclusion. You better constrain your function in some other way. Try reading on conditional definitions here: Condition

• Thanks! That should solve all my numerical optimization problems! – Chen Stats Yu Oct 26 '14 at 22:54
• I did try to contain, say using Exp[x], which should be >0. But during the optimization, I still get 0.0^0. – Chen Stats Yu Oct 26 '14 at 22:57
• @chen, maybe you can try changing Power[0, 0] = 1 to Power[0|0., 0|0.] = 1. – kglr Oct 27 '14 at 0:04
• $0^0=1$ does make sense mathematically. Just because $\lim\limits_{(x,y)\to(0,0)}x^y$ is indeterminate does not mean that $0^0$ should be left undefined. In most practical cases, $0^0=1$ is what is wanted. We should simply note that $x^y$ is not continuous at $(0,0)$. – robjohn Dec 14 '15 at 6:33
• Can one define 0 Log[0] = 1? – H. Kenan Mar 8 at 10:58