Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
November 15th, 2012, 01:21 PM
 EJF
Contributing User

Join Date: Sep 2005
Posts: 54
Time spent in forums: 11 h 11 m 59 sec
Reputation Power: 9
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
November 15th, 2012, 01:30 PM
 SuperOscar
Contributing User

Join Date: Jul 2007
Location: Joensuu, Finland
Posts: 420
Time spent in forums: 1 Week 18 h 25 m 2 sec
Reputation Power: 66
Quote:
 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```
b49P23TIvg agrees: (works in python3) also, math.exp(math.log(256)/2)
__________________
My armada: openSUSE 13.1 (home desktop, home laptop), Ubuntu 13.04 (work laptop), FreeBSD 9.2 (server), Mythbuntu 12.04 LTS (HTPC), Bodhi Linux 2.0 & Windows 7 Ultimate (test desktop), Android 4.1.2 (tablet)

#3
November 15th, 2012, 02:31 PM
 EJF
Contributing User

Join Date: Sep 2005
Posts: 54
Time spent in forums: 11 h 11 m 59 sec
Reputation Power: 9
Quote:
 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

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Calculating a square root using exponentiation (**)