Tuesday, December 26, 2006

mathematical musings

Quadratic equation - in program, it is said that we do not need to test if the discriminant is less than 0, why is this. -- "Thus the roots are distinct, if and only if the discriminant is non-zero, and the roots are real, if and only if the discriminant is non-negative." Thus, if the discriminant is negative, the values returned will not be real numbers, and thus will not be able to be presented by the program? No, because we have tested if the result is positive, and if the absolute value of it is less than 0. If it has failed those two tests, it is a negative number and thus will produce non-real roots (complex).

Other:
positive and negative number facts

0 Comments:

Post a Comment

<< Home