What are the formulas to find the roots in a quadratic, cubic, and quartic equation? Notation: sqrt(h) means square root of h. cbrt(h) means cube root of h. Quadratic (standard form): x^2 + ax + b = 0 x = (-a/2 + sqrt ( (a/2)^2 - b)) or x = (-a/2 - sqrt ( (a/2)^2 - b)) These formulae are derived as follows: (x + a/2)^2 = x^2 + a x + (a/2)^2 x^2 + a x + b = 0 (x^2 + a x + b) + (a/2)^2 = (a/2)^2 x^2 + a x + (a/2)^2 + b = (a/2)^2 (x + (a/2) )^2 + b = (a/2)^2 (x + (a/2) )^2 = (a/2)^2 - b x + (a/2) = sqrt( (a/2)^2 - b) or x + (a/2) = - sqrt( (a/2)^2 - b) Thus we have x = (-a/2 + sqrt ( (a/2)^2 - b)) or x = (-a/2 - sqrt ( (a/2)^2 - b)) ========== Cubic (standard form): x^3 + mx^2 + nx + r = 0 can be reduced to an equation of 6th power as follows: First make the substitution x = w - m/3 (w - m/3)^3 + m (w - m/3)^2 + n (w - m/3) + r = 0 w^3 - 3 [m/3] w^2 + 3 [ m^2/9] w - m^3/27 + m w^2 -2[m^2 /3 ] w + m^3/9 + n w - n m / 3 + r = 0 w^3 + [ n - m^2 / 3 ] w + [r - n m /3 + 2 m^3 / 27 ] = 0 Let p = [n - m^2 / 3] Let q = [r - nm/3 + 2 m^3/27] w^3 + p w + q = 0 Every cubic equation has at least one real root. A real root of w^3 + p w + q = 0 is given by w = cbrt( -(q/2) + sqrt( (q/2)^2 + (p/3)^3) ) +cbrt( -(q/2) - sqrt( (q/2)^2 + (p/3)^3 ) This formula is derived as follows: Let w = u + v (u + v)^3 + p(u+v) + q = 0 u^3 + 3 u^2 v + 3 u v^2 + v^3 + p(u+v) + q = 0 u^3 + v^3 + 3 u v (u+v) + p (u + v) + q = 0 u^3 + v^3 + (3 u v + p) ( u + v) + q = 0 When we set w = u + v we imposed only one condition on the values of u and v. We are free to impose any other condition on u and v to determine their values. So, we impose the condition that 3 u v + p = 0 3 u v = - p u = (-p/3)/v Then we substitute back into previous equation u^3 + v^3 + (3 u v + p) + q = 0 u^3 + v^3 + q = 0 - (p/3)^3 / v^3 + v^3 + q = 0 Multiply by v^3 v^6 + q v^3 - (p/3)^3 = 0 solve the quadratic in v^3 v^3 = -q/2 + sqrt( (q/2)^2 + (p/3)^3 ) or v^3 = -q/2 - sqrt( (q/2)^2 + (p/3)^3 ) Notice that the sum of these two roots is - q. That is, since u^3 + v^3 + q = 0, u^3 + v^3 = -q It is now clear that we can take u^3 = -q/2 + sqrt( (q/2)^2 + (p/3)^3 ) and v^3 = -q/2 - sqrt( (q/2)^2 + (p/3)^3 ) Thus w = u + v = cbrt( -q/2 + sqrt( (q/2)^2 + (p/3)^3 ) ) + cbrt( -q/2 + sqrt( (q/2)^2 + (p/3)^3 ) ) These formulas have the interesting property that the discriminant ( (q/2)^ + (p/3)^3) is negative if all three roots are nonzero real numbers. This formula is most easily evalueated when two of the roots are complex numbers. When all the roots are real, the formula requires us to take the cube roots of complex numbers. This can be done by using the formula cbrt( r[cos (A) + i sin (A) ]) = cbrt(r) [ cos(A/3) + i sin(A/3) ] Having solved, w^3 + p w + q = 0, we can find one real root from the original equation, call it s, by s = w - m/3 Having found one real root of this equation, we can reduce the original cubic to quadratic by dividing x^3 + m x^2 + n x + r by x - s. ====== Quartic (standard form): Solution provided by J Lee Jaap +1 757/865-7093 employed by, not necessarily speaking for, AS&M Inc, Hampton VA 23666-1340 x^4 + ax^3 + bx^2 + cx + d = 0 can be "reduced" by the substitution x = y - a/4 to the form 1) y^4 + ey^2 + fy + g = 0 Rearrange: y^4 = -ey^2 - fy - g Build a square on the left side, adding a temporary unknown "z": 2) (y^2 + z)^2 = y^2 (2z - e) - fy + (z^2 - g) Completing the square on the right-hand side gives the relationship (f / (2 (2z - e)))^2 = (z^2 - g) / (2z - e) Rearranging this in terms of z gives the "cubic resolvent": 8z^3 - 4ez^2 -8gz + eg - f^2 = 0 Solve for z, yielding 3 solutions. Back-substitute into eqn 2, which can be re-written (y^2 + z)^2 = k^2 (y - t)^2, where k^2 = 2z - e and t = f / (2 (2z - e)). Then y^2 + z = +- k (y - t) This yields 4 possible solutions for y for each of 3 values for z. Substitute all 12 possibles into eqn 1 to find the 4 true solutions. Then back-substitute to get the 4 x values. ========== Aside from any typos, these are the solutions. Of course, some of this can be optimized if programmed, but I've tried to include all the steps needed to see _why_ the solution works. It's trivial to see that the quadratic and the cubic can be reduced by a "x = y + k" substitution, to get rid of the next-to-leading term (quadratic: x = y - a/2; cubic: x = y - a/3). This can simplify some of the work. Cheers. --