Post Reply 
Cubic and Quartic Formulae
08-06-2015, 05:35 AM
Post: #1
Cubic and Quartic Formulae
Hello everyone,

I am just wondering if anyone has a program / application to find the exact roots of cubic and quartic polynomials.

I'm well aware that the calculator can solve them, but they provide decimal, approximate answers.

These formulae have been known since the 1500s. I wish the HP Prime and TI calculators provided exact solutions.

Only linear (trivial) and quadratic equations provide exact answers for all values of a, b, c.

Cubic formula:
https://en.wikipedia.org/wiki/Cubic_func..._for_roots

Quartic formula:
https://upload.wikimedia.org/wikipedia/c...ormula.svg

I'm a math teacher and I would like to show my students exact answers of these polynomials rather than just decimal approximations.

Thanks.
Find all posts by this user
Quote this message in a reply
08-06-2015, 05:42 AM
Post: #2
RE: Cubic and Quartic Formulae
Quite clearly you can see what I mean when I type: solve(x^3+x+1=0,x)
You receive a decimal value approximately -0.68...

However, there is obviously an exact solution given that it is a cubic polynomial.
You can find this on wolfram alpha at: http://www.wolframalpha.com/input/?i=sol...3D0%2Cx%29

I never understood why calculators with this capability gave approximate answers as opposed to exact.

I mean when computing (-1)^(1/3), you get the principal complex root as opposed to -1. I'm sure the ability is there to put this feature in. Maple does it flawlessly.
Find all posts by this user
Quote this message in a reply
08-06-2015, 09:01 AM
Post: #3
RE: Cubic and Quartic Formulae
There are a few reasons. Check again the closed-form solutions. You want 3 or 4 several line expressions with nested radicals as answers on a calculator screen. That's not very useful, besides it would only look nice (not really) for integer or rational coefficients. That's the same reason why closed form eigenvalues are either trivial or you don't really want to see them.

And then, in the numerical world people don't use (or shouldn't be using) those expressions as they are numerically unstable. There are quite a few much better methods.

The interesting part about them is that they do exist and they are algebraic expressions, yet the quintic doesn't have one of this kind (Abel-Ruffini theorem). I guess you won't be using calculators to introduce Galois theory.


TI have actually given details on the nifty algorithm they used in their numerical polynomial root finder, which appeared first on the TI 85:

ftp://ftp.ti.com/pub/graph-ti/calc-apps/...lyroot.txt

Taking into account the constraints of the machine it was designed for and its intended use, all of this makes sense to me.
Find all posts by this user
Quote this message in a reply
08-06-2015, 09:07 AM (This post was last modified: 08-06-2015 09:08 AM by Gerald H.)
Post: #4
RE: Cubic and Quartic Formulae
But note this:

http://www.hpcalc.org/search.php?query=galois
Find all posts by this user
Quote this message in a reply
08-06-2015, 09:20 AM
Post: #5
RE: Cubic and Quartic Formulae
(08-06-2015 09:07 AM)Gerald H Wrote:  But note this:

http://www.hpcalc.org/search.php?query=galois

And now I have to take that remark back... The things people do for their calculators (obviating the existence of computers and the ephemeral quality of life) never cease to amaze me.
Find all posts by this user
Quote this message in a reply
08-06-2015, 12:01 PM
Post: #6
RE: Cubic and Quartic Formulae
If you are showing exact formula for 3rd or 4th order equations to your students, you should really emphasize that they should in fact never be used. Numerically, it's much more precise to run iteratives methods to find root approximations. Symbolically, it's way more efficient to use algebraic extensions of Q (rootof in Xcas, unfortunately not available to the user on the Prime, not my choice...).
Xcas has a small user program (comments are in French) to demonstrate Cardan formula that should be easy to adapt to the Prime
Code:

cardan(P,x):={
  local b,p,q,d,V,u,v,x1,x2,x3,n,j;
  j:=exp(2*i*pi/3);
  V:=symb2poly(P,x);
  n:=size(V);
  if (n!=4){
    throw(afficher(P)+" n'est pas de degre 3");
  }
  // Reduction de l'equation
  V:=V/V[0];
  b:=V[1];
  V:=ptayl(V,-b/3);
  p:=V[2];
  q:=V[3];
  // on est ramen← ¢ x^3+p*x+q=0
  // x=u+v -> u^3+v^3+(3uv+p)(u+v)+q=0
  // On pose uv=-p/3 donc u^3+v^3=-q et u^3 et v^3 sont solutions
  // de u^3 v^3 = -p^3/27 et u^3+v^3=-q
  // donc de x^2+q*x-p^3/27=0
  d:=q^2/4+p^3/27;
  if (d==0){
    // racine double
    return solve(P,x); 
  }
  d:=sqrt(d);
  u:=(-q/2+d)^(1/3);
  v:=-p/3/u;
  x1:=u+v-b/3;
  x2:=u*j+v*conj(j)-b/3;
  x3:=u*conj(j)+v*j-b/3;
  return [x1,x2,x3];
}:;
BTW, there is a Galois Field command on the Prime. Try GF(2,8) for example, then you can work in the non-prime field with 256 elements.
Find all posts by this user
Quote this message in a reply
08-06-2015, 01:42 PM
Post: #7
RE: Cubic and Quartic Formulae
(08-06-2015 09:01 AM)Manolo Sobrino Wrote:  There are a few reasons. Check again the closed-form solutions. You want 3 or 4 several line expressions with nested radicals as answers on a calculator screen. That's not very useful, besides it would only look nice (not really) for integer or rational coefficients. That's the same reason why closed form eigenvalues are either trivial or you don't really want to see them.

And then, in the numerical world people don't use (or shouldn't be using) those expressions as they are numerically unstable. There are quite a few much better methods.

The interesting part about them is that they do exist and they are algebraic expressions, yet the quintic doesn't have one of this kind (Abel-Ruffini theorem). I guess you won't be using calculators to introduce Galois theory.


TI have actually given details on the nifty algorithm they used in their numerical polynomial root finder, which appeared first on the TI 85:

ftp://ftp.ti.com/pub/graph-ti/calc-apps/...lyroot.txt

Taking into account the constraints of the machine it was designed for and its intended use, all of this makes sense to me.

Actually, I do introduce calculators when speaking about Galois Theory. I teach differential equations, Calculus 3, Calculus 2, and Pre-Calculus. I explain that there are certain forms of quintics (and higher degrees) that can be solved numerically. I have a chart in my classroom regarding this.

Additionally, parisse noted that it's more practical to use approximations. I disagree with this. It's in fact a portion of the Ti-nSpire CAS (and the TI-89 for that matter) I prefer to the HP Prime. For instance (if we are talking about degrees), one can find sin(36), sin (18), sin(54), and sin(72) exactly. This angles are incredibly useful for architecture or engineering. One can apply half-angle, addition/subtraction, and double angle formulae to receive every whole number degree divisible by 3.

But it gets better. One can find the numerical value of sin(1) by applying the cubic formula. One can solve equations like sin(3x) = 3sin(x) - 4sin^3(x) by letting x = 1 and find the exact answers.

Additionally, if decide to take logarithms of these numbers (like sin(1) because logarithms of numbers close to 0+ diverge to -inf), we will see that our error will be huge if we use approximations. If we use exact answers (by simply using the copy/paste commands), our answers will be significantly more accurate, if not exact.
Find all posts by this user
Quote this message in a reply
08-06-2015, 07:19 PM
Post: #8
RE: Cubic and Quartic Formulae
Very interesting! Thanks for the comments.

(08-06-2015 01:42 PM)LCieParagon Wrote:  For instance (if we are talking about degrees), one can find sin(36), sin (18), sin(54), and sin(72) exactly. This angles are incredibly useful for architecture or engineering. One can apply half-angle, addition/subtraction, and double angle formulae to receive every whole number degree divisible by 3.

If I am remembering my math from ages ago correctly, you can always find an exact angle if you go out far enough... how would you decide at which point it is useful to find an exact angle or not? Would something like this be implemented by generating a collection of "interesting" values of finer and finer resolution until you were happy with the capability?


Speaking of the nspire, why would doing something like sin(73) in degrees helpfully convert it to "cos(17)"? Simply moving to a smaller angle in the trig function, or is that a common thing?

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-07-2015, 06:08 AM
Post: #9
RE: Cubic and Quartic Formulae
(08-06-2015 01:42 PM)LCieParagon Wrote:  Additionally, parisse noted that it's more practical to use approximations. I disagree with this. It's in fact a portion of the Ti-nSpire CAS (and the TI-89 for that matter) I prefer to the HP Prime. For instance (if we are talking about degrees), one can find sin(36), sin (18), sin(54), and sin(72) exactly. This angles are incredibly useful for architecture or engineering. One can apply half-angle, addition/subtraction, and double angle formulae to receive every whole number degree divisible by 3.
You misunderstood what I wrote. I did not say it's more practical to use approximations than exact formula. I said that for *both* numerical and symbolic computations, it's very inefficient to use Cardan or Ferrari formula. For numerical, because the expressions are huge and will introduce a lot of rounding errors instead of just one or two with an interative method. For symbolics, it's much much more efficient to work in Q[X]/M[X] where Q[X] is polynomial over the rationals and M is the minimal (irreducible) polynomial of an algebraic number than to work with embedded square roots, cubic roots, etc.
Find all posts by this user
Quote this message in a reply
08-07-2015, 10:39 AM (This post was last modified: 08-07-2015 01:45 PM by Manolo Sobrino.)
Post: #10
RE: Cubic and Quartic Formulae
Did you really try that or it's just guessing? It's a dead end. Putting aside the fact that the whole endeavour is a bit futile, the root of the equation that gives you the value of sin(1°) (I don't understand what makes Pi/180 so appealing) has cube roots of a complex number with parts made up of square roots of sums of square roots of some integers. Unfortunately, the "full Reals" Cardan root is not the good one. How do you get a standard pretty closed form for that without the closed forms of values of trigonometric functions with very ugly arguments... that you don't have?

Well, you could just write it down and so be it. After some cranking, a form happens to be:

\begin{equation}
sin\left(1°\right)=\frac{2 \sqrt[3]{2} \left(-1+i \sqrt{3}\right)-\left(1+i \sqrt{3}\right)
\left(-\sqrt{8-\sqrt{3}-\sqrt{15}-\sqrt{10-2 \sqrt{5}}}+i
\sqrt{8+\sqrt{3}+\sqrt{15}+\sqrt{10-2 \sqrt{5}}}\right)^{2/3}}{4\ 2^{2/3}
\sqrt[3]{-\sqrt{8-\sqrt{3}-\sqrt{15}-\sqrt{10-2 \sqrt{5}}}+i
\sqrt{8+\sqrt{3}+\sqrt{15}+\sqrt{10-2 \sqrt{5}}}}}
\end{equation}

I can't resist the version with prettier numbers:

\begin{equation}
sin\left(1°\right)=\frac{-2+2 i \sqrt{3}-\left(1+i \sqrt{3}\right) \left(-\sqrt{4-\sqrt{7+\sqrt{5}+\sqrt{6
\left(5+\sqrt{5}\right)}}}+i \sqrt{4+\sqrt{7+\sqrt{5}+\sqrt{6
\left(5+\sqrt{5}\right)}}}\right)^{2/3}}{4 \sqrt{2}
\sqrt[3]{-\sqrt{4-\sqrt{7+\sqrt{5}+\sqrt{6 \left(5+\sqrt{5}\right)}}}+i
\sqrt{4+\sqrt{7+\sqrt{5}+\sqrt{6 \left(5+\sqrt{5}\right)}}}}}
\end{equation}

(Mathematica principal roots.) Yes, the imaginary part is zero.

It is a closed form, but can we compute with just easy radicals of real numbers? No. What did we improve? Nothing.

Of course, with such a closed expression for sin(1°) there are equally computationally inefficient straightforward ways to get such closed expressions for every degree. Those things might look lovely, but what's the point? (No Tim, selling calculators is not a valid point Smile. I'm staying out of the Nspire thing so I don't really get the gist of your question.)


When Bernard talks about Algebra (and Maths in general) I always take notes. This is a great forum, not only about calculators. Sometimes the mood is a bit too upfront if you're not used to it, but you know these issues are so highly controversial... Smile


(edit - fixed some behaviour of the Mathematica TeX parser... Using the roots of i, there are shorter ones indeed:

\begin{equation}
sin\left(1°\right)=\frac{1}{4} (-1)^{59/180} \left(i-2 (-1)^{8/45}+\sqrt{3}\right)
\end{equation}

Eventually you'd get the trivial WAlpha expressions that come straight from the definition of sin (1°) in terms of complex exponentials.

\begin{equation}
sin\left(1°\right)=-\frac{1}{2} (-1)^{89/180} \left(\sqrt[90]{-1}-1\right)
\end{equation}
Find all posts by this user
Quote this message in a reply
08-08-2015, 02:37 AM
Post: #11
RE: Cubic and Quartic Formulae
(08-06-2015 07:19 PM)Tim Wessman Wrote:  Very interesting! Thanks for the comments.

(08-06-2015 01:42 PM)LCieParagon Wrote:  For instance (if we are talking about degrees), one can find sin(36), sin (18), sin(54), and sin(72) exactly. This angles are incredibly useful for architecture or engineering. One can apply half-angle, addition/subtraction, and double angle formulae to receive every whole number degree divisible by 3.

If I am remembering my math from ages ago correctly, you can always find an exact angle if you go out far enough... how would you decide at which point it is useful to find an exact angle or not? Would something like this be implemented by generating a collection of "interesting" values of finer and finer resolution until you were happy with the capability?


Speaking of the nspire, why would doing something like sin(73) in degrees helpfully convert it to "cos(17)"? Simply moving to a smaller angle in the trig function, or is that a common thing?

You are both correct and incorrect at the same time. You can never get to sin(1) this way. You can get to sin (3/2) by utilizing the half-angle formula. sin(1) is to be calculated using the cubic formula. At first glance, it would seem that sin(1) has an imaginary component, but the imaginary part is exactly 0.

Additionally, you wrote sin(73) which does in fact = cos(17). It really just depends on which you prefer. Once again there is an exact answer to this. It's not pretty, and must be calculated using the cubic formula.
Find all posts by this user
Quote this message in a reply
08-08-2015, 02:44 AM
Post: #12
RE: Cubic and Quartic Formulae
(08-07-2015 10:39 AM)Manolo Sobrino Wrote:  Did you really try that or it's just guessing? It's a dead end...

If you solve: sin(3x) = 3sin(x) - 4sin^3(x) by letting x = 1, you can find the value of sin(1) which you listed above. Like I said, Maple computes this value flawlessly. I don't see why a calculator can't do the same. This calculator has more than the capabilities of doing so.

I've also noticed approximations with certain products and sums that one can derive from using residues from complex analysis.

For instance,
[Image: trfABUu.jpg]
Our HP Prime has no ability to compute such things. I use residues frequently in my graduate studies.
Find all posts by this user
Quote this message in a reply
08-08-2015, 06:20 AM
Post: #13
RE: Cubic and Quartic Formulae
Xcas and the Prime can compute sum(1/(a^2+n^2),n,0,inf), just try!
I will just not implement Cardan/Ferrari formula in the giac kernel because they are useless as explained earlier, you are of course free to adapt my Xcas program for 3rd order equation if you really want Cardan formula on the Prime.
Find all posts by this user
Quote this message in a reply
08-15-2015, 10:05 AM
Post: #14
RE: Cubic and Quartic Formulae
(08-06-2015 01:42 PM)LCieParagon Wrote:  One can find the numerical value of sin(1) by applying the cubic formula. One can solve equations like sin(3x) = 3sin(x) - 4sin^3(x) by letting x = 1 and find the exact answers.

Did you ever consider to use this formula to solve a cubic equation using trigonometry?

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)