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.
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
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 *)