# How does my calculator calculate the roots for a cubic polynomial?

For example, many calculators come equipped with the quadratic formula, and so you can give them $A,B,C$ coefficients, and they will show you out the solution using the formula $$x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$

My calculator however finds $x$ when we have $x^3$ too, and this time it asks for $A,B,C,D$.

I was wondering how exactly it did this? Is there a cubic power "formula"? My calculator even calculates irrational roots so I'm not sure how exactly it can do this without a formula.

• There is a formula. It's called Cardano's formula, en.wikipedia.org/wiki/Cubic_function#Cardano.27s_method – Mastrem Jun 17 '17 at 17:25
• I think it rather uses methodes from Numerical Analysis. – user392395 Jun 17 '17 at 17:26
• Something like Newton-Raphson – user392395 Jun 17 '17 at 17:27
• @Fightclub1995 newton takes a few iterations, so I don't think so – K Split X Jun 17 '17 at 17:29
• We have never seen your calculator. – Will Jagy Jun 17 '17 at 17:52

There are formulas for the cubic and quartic. However it is impossible to find a solution to every quintic function. This took many years to figure out.

I would strongly recommend understanding how the bisection method works for functions. This provides a "numerical solution" instead of a formula which provides a "analytic solution".

There are may numerical techniques that can approximate values that can not be solved directly. Even quintic equations which sometimes don't have analytic solutions, can be solved with numerical solutions.

Edit:

Here is an example of bisection method.This quintic is not solvable: $f(x) = x^5 - x - 1$. But notice $f(1) = - 1$ and $f(2) = 29$ are opposite signs.

bottom <- 1
top <- 2
middle <- (top + bottom) / 2
while top - bottom > 0.0000001 do
if f(middle) > 0 then
top <- middle
else
bottom <- middle
end_if
middle <- (top + bottom) / 2
end_while


Running through the algorithm by hand you will notice that top - bottom is getting smaller and smaller but top and bottom are of opposite signs the whole time and surround a root.

"Cardano's method" solves the "reduced" cubic $x^3+ bx= c$ where b and c are real numbers. The basic idea is: For any numbers u and v, $(u+ v)^3= u^3+ 3u^2v+ 3uv^2+ v^3$ and $3(u+ v)= 3u+ 3v$ so that $(u+ v)^3- 3uv(u+ v)= u^3+ v^3$.

So, given any two numbers, u and v, taking b= -3uv and $c= u^3- v^3$ we can construct the cubic equation $x^3+ bx= c$ that has solution $x= u+ v$. Now, what about the other way? If we know b and c, can we solve $u^3- v^3= c$ and $-3uv= c$ for u and v and so find x?

Yes, of course! From $-3uv= b$ we have $v= -\frac{b}{3u}$ so that $u^3- v^3= c$ becomes $u^3-\frac{b^3}{3^3u^3}= c$ and, multiplying by $u^3$, $u^6- \left(\frac{b}{3}\right)^3= cu^3$ which we can write as $(u^3)^2- cu^3- \left(\frac{b}{3}\right)^3= 0$, a quadratic equation in $u^3$.

Using the quadratic formula $u= \frac{c\pm\sqrt{c^2+ 4\frac{b^3}{3^3}}}{2}= \frac{c}{2}\pm\sqrt{\left(\frac{c}{2}\right)^2+ \left(\frac{b}{3}\right)^3}$

Then $v= -\frac{b}{3u}$ gives v so we can find x= u+ v.

There is a formula.