Message Boards Message Boards

0
|
2340 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Setting $0^0$ to 1

Posted 1 year ago

Can Mathematica or one of its sessions set $0^0$ to $1$? I wish to use the combinatoric $0^0==1$ in Mathematica's internal calculations instead of it generating an Indeterminate error. I do know that Limit[x^x, x -> 0] is 1.

POSTED BY: Daniel Geisler
2 Replies

Building on Hans's idea, one can use WithCleanup to localized the redefinition of Power to a single execution:

runInCombinatorialMode // ClearAll;
runInCombinatorialMode // Attributes = {HoldAll};
runInCombinatorialMode[code_] := WithCleanup[
   Unprotect@Power;
   0^0 = 1;
   Protect@Power
   ,
   code,
   Unprotect@Power;
   0^0 =.;
   Protect@Power
   ];

runInCombinatorialMode[
 vec = Range[0, 4];
 Total[vec^vec]
 ]
(*  289  *)
0^0

Power::indet: Indeterminate expression 0^0 encountered.

(*  Indeterminate *)
POSTED BY: Michael Rogers
Posted 1 year ago

You could unprotect Power and add the definition for $ 0^0 $. The definition will only be in effect during the current Mathematica session.

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

Test it:

In[3]:= 0^0
Out[3]= 1
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract