solving a cubic eq




On Fri, 17 Apr 2009, Stavros Macrakis wrote:

< I am not aware of a function called poly_discriminant in Maxima or for
< that matter a function by some other name that calculates polynomial
< discriminants?  That said, the formulae are straightforward and you
< can easily write it yourself, something like
< 
< disc3(p,var) :=  /* cubic case only  -- no input validation */
<   block( [a,b,c,d],
<          p: rat(p,var),
< 	 a: ratcoef(p,var,3),
< 	 b: ratcoef(p,var,2),
< 	 c: ratcoef(p,var,1),
< 	 d: ratcoef(p,var,0),
< 	 b^2*c^2 -4*a*c^3 -4*b^3*d -27*a^2*d^2 +18*a*b*c*d )$
< 	
<                 -s

The discriminant of a polynomial f can be expressed in terms of the
resultant of f and f' (see http://en.wikipedia.org/wiki/Discriminant).

Here's code in maxima to implement it:
(%i1) degree(f,x) := hipow(f,x)$

(%i2) discriminant(f,x) := block([n:degree(f,x),fp,d,an],
 fp : diff(f,x),
 an : coeff(f,x,n),
 w : mod(n,4),
 w : w*(w-1)/2,
 d : (-1)^w/an,
 d : d*resultant(f,fp,x)
)$

(%i3) f : y^3 + p*y+q$

(%i4) discriminant(f,y);

(%o4) -27*q^2-4*p^3

(%i5) f : a*x^2+b*x+c$

(%i6) discriminant(f,x);

(%o6) b^2-4*a*c




< 
< On Fri, Apr 17, 2009 at 11:25 AM, andre maute <andre.maute at gmx.de> wrote:
< > On Friday 17 April 2009, Stavros Macrakis wrote:
< >> In this cubic, all three roots are real, but cannot be expressed with
< >> real radicals, even in principle. See
< >> http://en.wikipedia.org/wiki/Casus_irreducibilis . ?They *can* be
< >> expressed as real expressions involving trigonometric functions, which
< >> is what rectform does for you.
< >>
< >> That said, I wonder why you want the roots expressed as symbolic
< >> expressions. ?I suppose there must be some application where
< >> (8*cos(atan(sqrt(2101)/(69*sqrt(3)))/3)-sqrt(3))/sqrt(3) is more
< >> useful than 3.584428340330492, but usually the latter is what you
< >> really want, in which case why not calculate it directly using
< >> realroots or allroots (which, unlike solve, work for *all*
< >> polynomials, not just those which reduce to the quartic case or
< >> simpler by factorization or polynomial decomposition).
< >
< > I still use Maxima 5.15.0,
< > and I cannot find poly_discriminant in the html documentation
< > poly_discriminant is nice to detect the casus irreducibilis
< >
< > Andre
< > _______________________________________________
< > Maxima mailing list
< > Maxima at math.utexas.edu
< > http://www.math.utexas.edu/mailman/listinfo/maxima
< >
< 
< _______________________________________________
< Maxima mailing list
< Maxima at math.utexas.edu
< http://www.math.utexas.edu/mailman/listinfo/maxima
< 
< 
-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.