0

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?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • @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... – მამუკა ჯიბლაძე Jul 18 '17 at 05:14
  • 1
    @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? – მამუკა ჯიბლაძე Jul 18 '17 at 05:38
  • 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. – m_goldberg Jul 18 '17 at 06:05
  • @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? – მამუკა ჯიბლაძე Jul 18 '17 at 06:18
  • 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. – m_goldberg Jul 18 '17 at 07:11
  • @m_goldberg Actually my 11.0.1.0 does color them (the head is red and the rest pale grey). Besides, if you paste them here through four spaces, they automatedly get more color coding distinctions than just chunks of code, so I wonder why is that feature there if they should not be entered like that... – მამუკა ჯიბლაძე Jul 18 '17 at 07:17

1 Answers1

5

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.

Kiro
  • 1,521
  • 8
  • 19
  • 1
    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). – J. M.'s missing motivation Jul 30 '17 at 03:52
  • 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. – Kiro Jul 31 '17 at 05:35