Thanks
Affan
Cheers -- Sjoerd
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
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[];
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
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).
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
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
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