#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2005
    Posts
    54
    Rep Power
    12

    Calculating a square root using exponentiation (**)


    This is really a math question rather than a Python question, and I feel very dense for not being able to figure it out. I'm reading a book on Python and it introduces the math library as a source of useful functions, like sqrt. Then it says, as an aside, "We could have taken the square root using exponentiation **. (Can you see how?)"

    Unfortunately, I can't see how. Can anyone help me?

    Thanks.

    Eric
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Joensuu, Finland
    Posts
    471
    Rep Power
    69
    Originally Posted by EJF
    Unfortunately, I can't see how. Can anyone help me?
    Kinda basic math.

    Code:
    >>> 256**(1/2)
    16.0
    >>> import math
    >>> math.sqrt(256)
    16.0

    Comments on this post

    • b49P23TIvg agrees : (works in python3) also, math.exp(math.log(256)/2)
    My armada: Debian GNU/Linux 8 (desktop, home laptop, work laptop), Raspbian GNU/Linux 8 (nameserver), Ubuntu 14.04.3 LTS (HTPC), PC-BSD 10.2 (testbed), Android 4.2.1 (tablet)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2005
    Posts
    54
    Rep Power
    12
    Originally Posted by SuperOscar
    Kinda basic math.

    Code:
    >>> 256**(1/2)
    16.0
    >>> import math
    >>> math.sqrt(256)
    16.0
    Thanks, SuperOscar. Boy do I feel stupid.

    Eric

IMN logo majestic logo threadwatch logo seochat tools logo