|
Did you want to symbolicly solve these equations, or numericly solve the equation? If numericly did you want to include the imaginary results?
You could of course solve this ingeneral and then use the formulas to calculate the results... one of the roots looks like this:
x=((((-2) * b^3 + 9 * a * c * b - 27 * a^2 * d + sqrt((4 * (3 * a * c - b^2))^3 + ((-2) * b^3 + 9 * a * c * b - 27 * a^2 * d)))^2)^(1/3))/(3 * 2^(1/3) * a) - b/(3 * a) - (2^(1/3) * (3 * a * c - b^2))/(3 * a * ((-2) * b^3 + 9 * a * c * b - 27 * a^2 * d + sqrt((4 * (3 * a * c - b^2))^3 + ((-2) * b^3 + 9 * a * c * b - 27 * a^2 * d)^2))^(1/3))
(as done by mathematica anyway).
however there are lots of numerical methods to solve this much easier than the algebreic sollution.
Newton's method. x(n+1) <- x(n) - F(x(n))/F'(x(n))
or in the case x(n+1)=(ax(n)^3+bx(n)^2+cx(n)+d)/(3ax(n)^2+2bx(n)+c)
where each x(n) is an approximation of the root and x(0) is an initial guess.
Bisection Works like a binary search for the root in a interval [a, b].
If f(a)f(b ) < 0 then f(x) crosses the x-axis in this intevel
B1. define c=(a+b )/2 B2. if b-c <= some error tollerance the accept c and stop B3. else if the sign of f(b ) time the sign of f(c ) <= the a=c else b=c B4. return to step B1.
This is nice because works with any function and you don't have to calculate a derivitive and you can write a routine to search for a valid interval [a, b].
There are also the secant method, and other Fixed point interation algorithems (both Newton's and Secant methods are versions of this).
A google search on any of those should set you on the path.
This post has been edited by NickDMax: 21 Feb, 2007 - 03:58 PM
|