X = Y1 - e / 3 'the cubic was reduced by substition, cH = y - e/3 'to do this we divide all coeficients in the coefs() array by the cubic term ('a') 'put the equation in the form X^3 + eX^2 + fX + g = 0 'So that if we have an equation of the form: aX^3 + bX^2 +cX + dĭim e As Double, f As Double, g As Doubleĭim p As Double, q As Double, R As Doubleĭim Y1 As Double, A As Double, B As Double 'quadratic term, and so on with the last term being the constant term. 'The first element of coefs() is the coefficient of the cubic term, the second element is the coeficient of the 'This function computes the roots of a cubic equation with coeficients contained in coefs(): Public Function getCubicRoots(coefs() As Double) As Roots As I recall, I was only interested in real positive roots. #POLYROOTS MATHCAD 14 CODE#This is the code I wrote for getting the roots of a cubic polynomial. Perhaps you might be able to find a method like this if you do not like Newton Raphson. I think there might be iterative methods for finding quadratic factors, which can then be solved using the formula for quadratic roots. There is a pitfall or two when using Newton Raphson, but they are not difficult to avoid. My current calculator has a built in polynomial roots function. I have also used it many times, doing the computations on a hand calculator. I have written programs using that method in several languages, including capabilities for getting complex roots. Why not program Newton-Raphson? It is as good or better than any other method, and not difficult to program for a general polynomial. If you check out that site, you might decide you do not want a formula for even the 3rd order polynomial. If you really want to investigate, try the following site. I do not think they are published anywhere.įighting your way through the algorithms to get a solution is bad enough. The formulae derivable from these algorithms are so messy that nobody ever uses them. It was proven over 100 years ago that such formulae cannot exist.įor 3rd & 4th order polynomials, there are algorithms leading to roots, real or complex. If (a + ib) is a root, then (a - ib) is also a root.Īs mentioned in a previous post, there is no formula for polynomials of order 5 or greater. If you do complex arithmetic, you can use the above to find complex as well as real roots. If you study the formula for above derivative a bit, you will see the rule for determining the derivative of any polynomial. Keep it up until two successive guesses are nearly equal. Use next guess to compute a better guess. NextGuess = LastGuess - Polynomial(LastGuess) / Derivative(LastGuess) Polynomial(x) = ax^4 + bx^3 + cx^2 + dx + e Note that even order polynomials might not have any real roots, while odd order polynomials always have at least one real root.Ī good successive approximation method is Newton-Raphson, which works as follows (Fourth order polynomial used as example). Over 100 years ago, it was proven that there could be no formula for fifth & higher order polynomials. Even before hand calculators and computers, it was easier to use some successive approximation method. The formulae for third and fourth order polynomials are so complicated that nobody uses them except students who are taking certain mathematics courses. The formula for a quadratic (ax^2 + bx + c = 0) is the following.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |