A cubic function has an x^{3} term, its general form is:

a x^{3} + b x^{2} + c x + d = 0

The three solutions are:

root1 = -a/3 + ((-2a^{3} + 9ab - 27c + sqrt((2a^{3} -9ab +27c)^{2} + 4(-a^{2} + 3b)^{3}))/54)^{1/3} + ((-2a^{3} + 9ab - 27c - √((2a^{3} -9ab +27c)^{2} + 4(-a^{2} + 3b)^{3}))/54)^{1/3}

root2 = -a/3 - (1 + i sqrt(3))*0.5*((-2a^{3} + 9ab - 27c + sqrt((2a^{3} -9ab +27c)^{2} + 4(-a^{2} + 3b)^{3}))/54)^{1/3} + (-1 + i sqrt(3))*0.5*((-2a^{3} + 9ab - 27c - sqrt((2a^{3} -9ab +27c)^{2} + 4(-a^{2} + 3b)^{3}))/54)^{1/3}

root3 = -a/3 + ((-2a^{3} + 9ab - 27c + sqrt((2a^{3} -9ab +27c)^{2} + 4(-a^{2} + 3b)^{3}))/54)^{1/3} + ((-2a^{3} + 9ab - 27c - √((2a^{3} -9ab +27c)^{2} + 4(-a^{2} + 3b)^{3}))/54)^{1/3}

## Methods of solution

- by factors
- by completing the cobe
- by formulae
- by graph

### Sum and difference of two cubes

(a + b)(a^{2} - ab + b^{2})

= a (a^{2} - ab + b^{2}) + b (a^{2} - ab + b^{2})

= a^{3} - a^{2}b + ab^{2} + ba^{2} - ab^{2} + b^{3}

= a^{3} + b^{3}

simarly

(a - b)(a^{2} + ab + b^{2}) = a^{3} - b^{3}

## Using Symmetry

Instead of using the equation:

a x^{3} + b x^{2} + c x + d = 0

= 0

we can use the equation:

(x - x_{1})*(a' x^{2} + b' x + c') = 0

where x is our variable and x_{1}, a', b' and c' are constants.

which has solutions at:

x = x_{1} and

In other words, can we use this to reduce the cubic to a quadratic in this way? First we have to multiply out the terms to see if its a general cubic:

(x - x_{1})*(a' x^{2} + b' x + c') = (a' x^{3} + b' x^{2} + c' x ) - x_{1}*a' x^{2} - x_{1}* b' x - x_{1}* c')

= a' x^{3} + (b' - x_{1}*a')x^{2} + (c' - x_{1}* b') x - x_{1}* c')

Therefore:

- a = a'
- b = b' - x
_{1}*a - c = c' - x
_{1}* b' - d = - x
_{1}* c'

So, puting this in terms of the original equation,

- a' = a
- b' = b + x
_{1}*a = b - d*a/c' - c' = c + x
_{1}* b' = c - d*(b - d*a)/c' - x
_{1}= -d/c'

so:

c'^{2} - c*c' + d*(b - d*a) = 0

c' = (c± √(c^{2} - 4*d*(b - d*a)))/2

substituting in above gives:

- a' = a
- b' = b + x
_{1}*a = b - d*a/(c± √(c^{2}- 4*d*(b - d*a)))/2 - c' = (c± √(c
^{2}- 4*d*(b - d*a)))/2 - x
_{1}= -d/(c± √(c^{2}- 4*d*(b - d*a)))/2

## Program

There are a number of open source programs that can solve polynomial equations. I have used Axiom, how to install Axiom here.

To get a numeric solution for a given equation we can use complexSolve as shown here:

complexSolve(2*x^3+3*x^2+4*x+5 = 0,1.e-10)

I have put user input in red:

(1) -> complexSolve(2*x^3+3*x^2+4*x+5 = 0,1.e-10) (1) |

Or we can find a formula for, say, a quadratic equation using radicalSolve as shown here (unfortunately attempts to display large equations using fixed spacing do not really work so I have swiched the ouptut to LaTeX but its still too big):