Question 456779
<font face="Times New Roman" size="+2">


Either share the particular "common algorithm" with which you are dealing, or go ask this question on a Computer Science website.


In general though, if your coefficients are a, b, and c, then the cases would be:


1.  a = 0; the code should return a message to the user that this is not a quadratic.


2.  b = 0, but a and c not equal to zero and the signs on a and c are opposite:  the code should return an answer *[tex \Large \pm\sqrt{-\frac{c}{a}}]


3.  b = 0,  but a and c not equal to zero and the signs on a and c are the same:  the code should return either "No solution over the reals" or an answer of *[tex \Large \pm\,i\sqrt{\frac{c}{a}}] depending on whether the algorithm is designed to handle complex number roots or not.


4.  b = 0 and c = 0, then x = 0.


5.  a, b, and c non-zero, then:


5a.  if *[tex \Large b^2\ -\ 4ac\ =\ 0], then *[tex \Large x\ =\ -\frac{b}{2a}] and the single root has a multiplicity of 2.


5b.  if *[tex \Large b^2\ -\ 4ac\ >\ 0], then *[tex \Large x\ =\ \frac{-b\ \pm\ \sqrt{b^2\ -\ 4ac}}{2a}]


5c.  if *[tex \Large b^2\ -\ 4ac\ <\ 0], then the algorithm should return either "No solution over the reals" or an answer of *[tex \Large x\ =\ \frac{-b\ \pm\ i\sqrt{-b^2\ +\ 4ac}}{2a}] depending on whether the algorithm is designed to handle complex number roots or not.


John
*[tex \LARGE e^{i\pi} + 1 = 0]
My calculator said it, I believe it, that settles it
<div style="text-align:center"><a href="http://outcampaign.org/" target="_blank"><img src="http://cdn.cloudfiles.mosso.com/c116811/scarlet_A.png" border="0" alt="The Out Campaign: Scarlet Letter of Atheism" width="143" height="122" /></a></div>
</font>