On Apr 18, 8:52 am, Michael Hoffman <[EMAIL PROTECTED]> wrote: > lucidparadox wrote: > > I'm currently new to Python and I haven't been able to find the > > operator/math function to find the square root or even the x root of a > > number. > > For square root, use math.sqrt(y) > > For x root use y**(1/x) > > > I'm rewriting a program that I wrote in BASIC that does the > > math of a quadratic equation (user puts in a, b, and c values) and > > tells the user whether it has 1 root, 2 roots, or no real roots and > > displays the roots if it has real roots. > > In floating point arithmetic, the naive way of calculating both roots > always using the formula (-b +/- sqrt(b**2 - 4*a*c))/2*a will give you > inaccurate results sometimes. See > <http://www.cse.uiuc.edu/eot/modules/floating_point/quadratic_formula/>. > > For a better formula, see how r_1 and r_2 are defined in > <http://en.wikipedia.org/wiki/Quadratic_equation#Alternative_formula>. > -- > Michael Hoffman
Thanks. As of right now I'm just trying to familiarize myself with the syntax of Python. Actually I should have thought of y**(1/x). I'm currently a freshman in college so the alternative formula hasn't been introduced to me yet. Thanks for the pointers though. Dan Collins -- http://mail.python.org/mailman/listinfo/python-list