0
$\begingroup$

Occasionally I encounter messages like

Power::indet: Indeterminate expression (0. + 0. I)^0 encountered.

(or just 0^0). I believe I can safely declare these to be 1 for all of my purposes. Is there a way to build this in?

$\endgroup$
  • $\begingroup$ @MichaelE2 Oh I see thanks. Could not find that for some reason, I honestly tried searching for 0^0. Let us mark it as duplicate. Although I already learned from the answer below some additional possibilities, but still... $\endgroup$ – მამუკა ჯიბლაძე Jul 18 '17 at 5:14
  • 1
    $\begingroup$ @m_goldberg The way it was before your edit looked nicer with all that color-coding, are there specific reasons why your version is better? $\endgroup$ – მამუკა ჯიბლაძე Jul 18 '17 at 5:38
  • $\begingroup$ The formatting I applied to the error message is the formatting we have been using for such on this site for all the years I have been a member. The idea is that messages should be distinct from code. $\endgroup$ – m_goldberg Jul 18 '17 at 6:05
  • $\begingroup$ @m_goldberg I see. Pity. I wonder if somebody could be asked to extend color coding to messages too. Besides, it is just a random choice of convention which ones should go with four spaces and which with >!, no? $\endgroup$ – მამუკა ჯიბლაძე Jul 18 '17 at 6:18
  • $\begingroup$ Messages issued in Mathematica do not have color coding. Messages are are mixture of text and code. It is probably more trouble that it would be worth to try to get lexical scanner to distinguish what is text and what is code. $\endgroup$ – m_goldberg Jul 18 '17 at 7:11
4
$\begingroup$

Operator overloading is one way.

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

You should add also the cases like Power[0.,0.]. When you want to clear your own definitions, Unprotect, Clear, Protect.

|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ It should of course be stressed that you do this only if you know what you're doing (e.g. combinatorial as opposed to analytic operations). $\endgroup$ – J. M.'s technical difficulties Jul 30 '17 at 3:52
  • $\begingroup$ I 100 % agree with you. While the list of things you should do even if you don't know what you are doing is very short, this one might have deserved an explicit warning. $\endgroup$ – Kiro Jul 31 '17 at 5:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.