Given a cubic equation, how can you determine a range that contains all roots without solving?

2k Views Asked by At

I am trying to code an algorithm that does not use the cubic formula in order to determine a cubic function $(ax^{3} + bx^{2} + cx + d)$ roots. I came across an algorithm (https://rosettacode.org/wiki/Roots_of_a_function#Java) where a range is given for where the roots may lie. From then, the algorithm searches inbetween this range. (If anyone knows the name of this algorithm that will also be a massive help!)

However, I would like to improve this somehow by calculating a suitable range for the algorithm to search within so that this does not rely on input and so that many different coefficients can be input and an effective range can be chosen. Is there any way to do this reasonably quickly, looking at coefficients and not actually solving it? I'm not looking for you to write the program for me, just to point me to a way to do this. Thank you :D

2

There are 2 best solutions below

2
On

Well here is something. Maybe not efficient.

$f(x) = ax^3 + bx^2 + cx +d $ will have the same roots as $-ax^2 - bx^2 - cx - d$ so we might as well assume $a > 0$.

Solve for $3ax^2 + 2bx + c = 0$

$x_1,x_2 = -\frac {2b \pm \sqrt{b^2 - 3ac}}{3a}$

if $b^2 \le 3ac$ there is only 1 root. If $f(x_1) > 0$ and $f(x_2) < 0$ (vice versa if $a < 0$). There will be 3 roots: One in $(-\infty, x_1)$, one in $(x_1, x_2)$ and one in $(x_2, \infty)$.

Other wise there is only one root.

So you have three or one ranges which will have exactly one root.

Just guess a bunch of $x$ values within these ranges to fine tune. If $f(x)$ and $f(y)$ are on opposite sides of zero the root will be between them. Otherwise it will not be.

===

0
On

If $|x| > 1$ and $|x| > (|b|+|c|+|d|)/|a|$, then

$|ax^3| > (|b|+|c|+|d|)|x^2| > |bx^2| + |cx| + |d| \ge |bx^2+cx+d|$

and so $|f(x)| \ge |ax^3| - |bx^2+cx+d| > 0$.

This shows that the roots $x$ of $f$ satisy $|x| \le \max \{1, (|b|+|c|+|d|)/|a| \}$