anonymous
  • anonymous
Exercise 2.5 works, I think, but with some parameters it complains that there's a 'math domain error' import math def roots (a,b,c): x = (math.sqrt(b**2 - 4*a*c)-b)/2 y = (-b - math.sqrt(b**2 - 4*a*c)-b)/2 print "x=",x print "y=", y
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
schrodinger
  • schrodinger
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
You have to test the value of the discriminant before taking the square root. Alternatively, if you can to do the optional part and have it produce complex root. Takes a little bit of extra effort. The sqrt function is still limited to non-negative values. So take the sqrt of the absolute value and multiply by "1J"

Looking for something else?

Not the answer you are looking for? Search for more explanations.