| home | contents | send comment | send link | add bookmark |

Cubic Root Calculator

by Stephen R. Schmitt

0 = x3 + x2 + x +

Apply rounding
No rounding

x1 = + j

x2 = - j

x3 =


Contents

  1. About
  2. The source code
  3. Discussion

About

This calculator computes complex and real roots for any cubic polynomial. It applies the Lin-Bairstow algorithm which iteratively solves for the roots starting from random guesses for a solution. The calculator is designed to solve for the roots of a cubic polynomial with the form:

    x3 + a·x2 + b·x + c = 0
The program is operated by entering the coefficients for the cubic polynomial to be solved, selecting the rounding option desired, and then pressing the Calculate button. All entries are cleared by pressing the Clear button. If the value of c is zero (which means that one root is zero), the program returns an error message:
cannot solve
In this case, the cubic polynomial can be reduced to a quadratic which is easily solved. It is possible for the initial random guesses used by the algorithm to cause it to be unstable; the above error message will result in this instance. Each time the algorithm is started, a new set of initial random guesses will be generated - another trial may result in a solution.

Return to Contents


The source code

The Java Script source code for this program can be viewed by using the View|Source command of your web browser.

You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitablility of this source code for your use.

Return to Contents


Discussion

A polynomial, P(x), has a factor of (x - r) if and only if P(r) = 0. Then r is said to be a zero of the polynomial.

Every cubic polynomial, P(x), has a factorization of the form:

    P(x) = (x - r1)(x - r2)(x - r3) = 0
where the roots, ri, can be duplicates.

If P(x) has real coefficients (as in this calculator), and if x is a complex zero of P(x), then the complex conjugate of x is also a zero of P(x). A cubic polynomial can have three real zeros, or one real zero and one pair of complex zeros.

Reference

Elementary Mathematical Analysis

Return to Contents


AbCd Classics - free on-line books


Copyright © 2004, Stephen R. Schmitt