## Jupyter_Cubic_1

January 10, 2019
In [1]: F(x) = 9*x^3 - 71*x^2 - 3833*x - 425
In [2]: S = solve(F(x) == 0, x, to_poly_solve=True)
In [3]: latex(S)
Out[3]: \left[x = \left(-\frac{1}{9}\right), x = \left(-17\right), x = 25\right]

$\left[x=\left(-\frac{1}{9}\right),x=\left(-17\right),x=25\right]$

Hmmm… What manner of magic is this?

In [4]: G(x) = expand((x - 3) * (x - sqrt(2)) * (x + sqrt(2)))
In [5]: G(x)
Out[5]: x^3 - 3*x^2 - 2*x + 6
In [6]: S = solve(G(x) == 0, x, to_poly_solve=True)
In [7]: latex(S)
Out[7]: \left[x = -\sqrt{2}, x = \sqrt{2}, x = 3\right]

$\left[x=-\sqrt{2},x=\sqrt{2},x=3\right]$

Oh, I see. All the factors of the 4th term, positive or negative, could potentially be roots. If they are, then sage succeeds, because Factor Theorem next allows Sage to derive a quadratic.

In [8]: var(a, b, c)
Out[8]: (a, b, c)
In [9]: H(x) = a*x^2 + b*x + c
In [10]: S = solve(H(x) == 0, x, to_poly_solve=True)
In [11]: latex(S)
Out[11]: \left[x = -\frac{b + \sqrt{b^{2} - 4 \, a c}}{2 \, a}, x = -\frac{b - \sqrt{b^{2} - 4 \, a c}}{2 \, a}\right]

$\left[x=-\frac{b+\sqrt{{b}^{2}-4\phantom{\rule{0.3em}{0ex}}ac}}{2\phantom{\rule{0.3em}{0ex}}a},x=-\frac{b-\sqrt{{b}^{2}-4\phantom{\rule{0.3em}{0ex}}ac}}{2\phantom{\rule{0.3em}{0ex}}a}\right]$

Let’s try a cubic, that has no such rational solutions…

In [12]: F1(x) = x^3 - 3*x^2 - 2*x + 5
In [13]: S = solve(F1(x) == 0, x, to_poly_solve=True)
In [14]: latex(S)
Out[14]: \left[x = -\frac{1}{2} \, {\left(\frac{1}{18} i \, \sqrt{473} \sqrt{3} - \frac{1}{2}\right)}^{\frac{1}{3}} {\left(i \, \sqrt{3} + 1\right)} - \frac{-5 i \, \sqrt{3} + 5}{6 \, {\left(\frac{1}{18} i \, \sqrt{473} \sqrt{3} - \frac{1}{2}\right)}^{\frac{1}{3}}} + 1, x = -\frac{1}{2} \, {\left(\frac{1}{18} i \, \sqrt{473} \sqrt{3} - \frac{1}{2}\right)}^{\frac{1}{3}} {\left(-i \, \sqrt{3} + 1\right)} - \frac{5 i \, \sqrt{3} + 5}{6 \, {\left(\frac{1}{18} i \, \sqrt{473} \sqrt{3} - \frac{1}{2}\right)}^{\frac{1}{3}}} + 1, x = {\left(\frac{1}{18} i \, \sqrt{473} \sqrt{3} - \frac{1}{2}\right)}^{\frac{1}{3}} + \frac{5}{3 \, {\left(\frac{1}{18} i \, \sqrt{473} \sqrt{3} - \frac{1}{2}\right)}^{\frac{1}{3}}} + 1\right]

$\left[x=-\frac{1}{2}\phantom{\rule{0.3em}{0ex}}{\left(\frac{1}{18}i\phantom{\rule{0.3em}{0ex}}\sqrt{473}\sqrt{3}-\frac{1}{2}\right)}^{\frac{1}{3}}\left(i\phantom{\rule{0.3em}{0ex}}\sqrt{3}+1\right)-\frac{-5i\phantom{\rule{0.3em}{0ex}}\sqrt{3}+5}{6\phantom{\rule{0.3em}{0ex}}{\left(\frac{1}{18}i\phantom{\rule{0.3em}{0ex}}\sqrt{473}\sqrt{3}-\frac{1}{2}\right)}^{\frac{1}{3}}}+1,x=-\frac{1}{2}\phantom{\rule{0.3em}{0ex}}{\left(\frac{1}{18}i\phantom{\rule{0.3em}{0ex}}\sqrt{473}\sqrt{3}-\frac{1}{2}\right)}^{\frac{1}{3}}\left(-i\phantom{\rule{0.3em}{0ex}}\sqrt{3}+1\right)-\frac{5i\phantom{\rule{0.3em}{0ex}}\sqrt{3}+5}{6\phantom{\rule{0.3em}{0ex}}{\left(\frac{1}{18}i\phantom{\rule{0.3em}{0ex}}\sqrt{473}\sqrt{3}-\frac{1}{2}\right)}^{\frac{1}{3}}}+1,x={\left(\frac{1}{18}i\phantom{\rule{0.3em}{0ex}}\sqrt{473}\sqrt{3}-\frac{1}{2}\right)}^{\frac{1}{3}}+\frac{5}{3\phantom{\rule{0.3em}{0ex}}{\left(\frac{1}{18}i\phantom{\rule{0.3em}{0ex}}\sqrt{473}\sqrt{3}-\frac{1}{2}\right)}^{\frac{1}{3}}}+1\right]$

Aha, gotcha! I know this cubic has 3 real roots, which can be approximated, according to much of the same methodology: First, successively-approximate a root, then, factor down to an n-1 degree poly, then repeat…

In [15]: F1(x).roots(x, ring=CC, multiplicities=False)
Out[15]: [-1.33005873956798, 1.20163967572340, 3.12841906384458]
In [ ]: