3

Is there any way of solving $ax^3+bx^2+cx+d=0$, which I know has three roots, without knowing what $a, b, c$, and $d$ equal? I've tried using the formula that uses $p, q$, and $r$, though that always just returns undefined.

An example of what the cubic equation might be is $4x^3-6x^2+1=0$.

EDIT: Saying "not knowing the terms" was a bad choice of wording. The thing is that the values of $a, b, c$, and $d$ change, so I don't want an answer that relies on factoring or something similar because they would only work on certain values of $a, b, c$, and $d$.

EDIT 2: I'm not doing this in code.

EDIT 3: Here's a simplified example of what I'm trying to do: https://www.desmos.com/calculator/gsjtv0qnwn I'm trying to find where the red equation intersects the x-axis. Black lines are also at these points. The blue line that is Cardano's Formula does not exist because $4p^3+27q^2$ is not greater than $0$.

Undefined
  • 153
  • 1
    I think your question is a bit confusing since solving $ax^3 + bx^2 + cx + d = 0$ means we are to solve for $x$ satisfying the equation given $a$, $b$, $c$, and $d$. Since the coefficients are also unknown, what is there to solve? You might want to clarify on that. – soupless Sep 06 '21 at 16:02
  • 2
    If you know what $a$, $b$, $c$, and $d$ is, then you can use Cardano's formula on that. – soupless Sep 06 '21 at 16:04
  • What I'm trying to say is that the coefficients are known, but they change, so I don't want any answers that include factoring or something like that, which would only work for some values of $a, b, c$, and $d$. I'll edit my question to clarify this. – Undefined Sep 06 '21 at 16:07
  • Google "cubic formula". It's not pretty. – K.defaoite Sep 06 '21 at 16:13
  • Cardano's formula might be what I'm looking for, but I have to try first. – Undefined Sep 06 '21 at 16:14
  • Note that Cardano's formula often involve taking cube roots of imaginary numbers. Does your programming language support that? – Trebor Sep 06 '21 at 16:20
  • No, I didn't use any code at all. I'm actually trying to do something in Desmos. The formula with $p, q$, and $r$ returns undefined because it leads to finding the square root of a negative number. – Undefined Sep 06 '21 at 16:23
  • I've added a graph of what I'm trying to do. – Undefined Sep 06 '21 at 17:07
  • It seems like you’ve already my solved this then using Cardano’s formula. – Eric Sep 06 '21 at 17:27
  • No because Cardano's formula doesn't work for when$4p^3+27q^2$ is less than $0$, which it often is in my case. I've noticed that this is actually denominated as casus irreducibilis, which my math knowledge isn't large enough to understand. – Undefined Sep 06 '21 at 17:30
  • casus irreducibilis, meaning three real irrational roots, means that one is taking a cube root of a complex number. One might think that using polar coordinates to express the comlex number, and its cube root, would somehow imporove matters. However, that just gives a new cubic to solve that remains in casus irreducibilis. Of course, if your coefficients are integers and the discriminant is a square, one gets explicit expressions of the roots using trig functions. Examples $x^3 - 3x + 1$ and $x^3 + x^2 - 2x - 1 $ – Will Jagy Sep 06 '21 at 18:01

1 Answers1

4

Using Cardano's Formula can involve imaginary cube roots, even in some cases where the roots are real. Here is a method to get the real roots without resort to complex numbers.


Identities

Start with the cubic equation $$ x^3+px^2+qx+r=0\tag1 $$ Let $x=y-\frac p3$, then $(1)$ becomes $$ y^3-\frac{p^2-3q}3\,y=-\frac{2p^3-9pq+27r}{27}\tag2 $$ Using the identities $$ \begin{align} 4\cos^3(u)-3\cos(u)&=\cos(3u)\tag{3a}\\ 4\cosh^3(u)-3\cosh(u)&=\cosh(3u)\tag{3b}\\ 4\sinh^3(u)+3\sinh(u)&=\sinh(3u)\tag{3c} \end{align} $$ and multiplying by $\frac{a^3}4$, we get $$\newcommand{\sgn}{\operatorname{sgn}} \begin{align} (a\cos(u))^3-\frac{3a^2}4(a\cos(u))&=\frac{a^3}4\cos(3u)\tag{4a}\\ (a\cosh(u))^3-\frac{3a^2}4(a\cosh(u))&=\frac{a^3}4\cosh(3u)\tag{4b}\\ (a\sinh(u))^3+\frac{3a^2}4(a\sinh(u))&=\frac{a^3}4\sinh(3u)\tag{4c} \end{align} $$


Real Solutions

Let $b=-\frac{2p^3-9pq+27r}{27}$ and $\sgn(b)=2[b\ge0]-1$ (Iverson brackets).

If $p^2=3q$, then $$ x=-\frac p3+b^{1/3}\tag5 $$ If $p^2\gt3q$, then let $a=\frac23\sgn(b)\sqrt{p^2-3q}$, and

if $\frac{4b}{a^3}\le1$, then $$ x=-\frac p3+a\cos\left(\frac13\cos^{-1}\left(\frac{4b}{a^3}\right)+\left\{0,\frac{2\pi}3,-\frac{2\pi}3\right\}\right)\tag6 $$ else if $\frac{4b}{a^3}\gt1$, then $$ x=-\frac p3+a\cosh\left(\frac13\cosh^{-1}\left(\frac{4b}{a^3}\right)\right)\tag7 $$ If $p^2\lt3q$, then let $a=\frac23\sgn(b)\sqrt{3q-p^2}$, then $$ x=-\frac p3+a\sinh\left(\frac13\sinh^{-1}\left(\frac{4b}{a^3}\right)\right)\tag8 $$

robjohn
  • 345,667