Re: Mathematics in Python are not correct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Luis Zarrabeitia

    Re: Mathematics in Python are not correct

    On Thursday 08 May 2008 06:54:42 pm wxPythoner@gmai l.com wrote:
    The problem is that Python parses -123**0 as -(123**0), not as
    (-123)**0.
    Actually, I've always written it as (-123)**0. At least where I'm from,
    exponentiation takes precedence even over unary "-". (to get a power of -123,
    you must write $(-123)^0$ [latex])

    Though not an authoritative source, wikipedia also uses the (-x)^y notation:


    Btw, there seems to be a math problem in python with exponentiation. ..
    >>0**0
    1

    That 0^0 should be a nan or exception, I guess, but not 1.

    [just found out while trying the poster's example]

    --
    Luis Zarrabeitia (aka Kyrie)
    Fac. de Matemática y Computación, UH.

  • Dan Bishop

    #2
    Re: Mathematics in Python are not correct

    On May 8, 6:14 pm, Luis Zarrabeitia <ky...@uh.cuwro te:
    On Thursday 08 May 2008 06:54:42 pm wxPytho...@gmai l.com wrote:
    >
    The problem is that Python parses -123**0 as -(123**0), not as
    (-123)**0.
    >
    Actually, I've always written it as (-123)**0. At least where I'm from,
    exponentiation takes precedence even over unary "-". (to get a power of -123,
    you must write $(-123)^0$ [latex])
    FWIW, my TI-89 evaluates it as -1.
    Though not an authoritative source, wikipedia also uses the (-x)^y notation:http://en.wikipedia.org/wiki/Exponen...s_of_minus_one
    >
    Btw, there seems to be a math problem in python with exponentiation. ..
    >
    >0**0
    >
    1
    >
    That 0^0 should be a nan or exception, I guess, but not 1.
    >
    [just found out while trying the poster's example]
    Technically correct, but 0**0 == 1 is actually pretty useful. For one
    thing, it lets you create a Vandermonde matrix without making 0 a
    special case.

    Comment

    • Arnaud Delobelle

      #3
      Re: Mathematics in Python are not correct

      Dan Bishop <danb_83@yahoo. comwrites:
      On May 8, 6:14 pm, Luis Zarrabeitia <ky...@uh.cuwro te:
      >On Thursday 08 May 2008 06:54:42 pm wxPytho...@gmai l.com wrote:
      >>
      The problem is that Python parses -123**0 as -(123**0), not as
      (-123)**0.
      >>
      >Actually, I've always written it as (-123)**0. At least where I'm from,
      >exponentiati on takes precedence even over unary "-". (to get a power of -123,
      >you must write $(-123)^0$ [latex])
      >
      FWIW, my TI-89 evaluates it as -1.
      >
      >Though not an authoritative source, wikipedia also uses the (-x)^y
      >notation:http://en.wikipedia.org/wiki/Exponen...s_of_minus_one
      >>
      >Btw, there seems to be a math problem in python with exponentiation. ..
      >>
      >>0**0
      >>
      >1
      >>
      >That 0^0 should be a nan or exception, I guess, but not 1.
      >>
      >[just found out while trying the poster's example]
      >
      Technically correct, but 0**0 == 1 is actually pretty useful. For one
      thing, it lets you create a Vandermonde matrix without making 0 a
      special case.
      If we want Binomial expansion to work sanely, we need 0^0 = 1, e.g:

      (x+0)^2 = 1*x^2*0^0 + 2*x*0 + 1*x^0*0^2
      = x^2

      Therefore 0^0 = 1

      Also, x^y (for x, y natural numbers) can be defined as the number of
      functions from Y to X where |X|=x and |Y|=y. As there is exactly one
      function from the empty set to the empty set, 0^0 = 1.

      The arguments for making 0^0 = 0 are weak, it is a bit more convincing
      to want it to be undefined (as (0,0) is a point of discontinuity of
      (x,y) -x^y).
      --
      Arnaud

      Comment

      Working...