Solving general cubic in CAS

themadmathematician shared this idea 8 years ago
Answered

It would be really nice if CAS could be made to solve a general cubic as well as the specific cubics soluble with the SolveCubic-command. i.e. Solve[a x^3 + b x^2 + c x + d = 0]. Currently, it can only handle those cases which are easily factored. I realize it takes a bit of programming with if-clauses, but it should be doable. Wolfram Alpha will do it, but trying to apply the solutions, the formulas given fail when I change the parameters because different discriminants/roots turn positive/negative.


What I'm trying to do is find the 4th-degree polynomial passing through 3 given extreme-points. This gives 6 equations for 5 parameters, so I have to relax the conditions and settle for two extreme points and perhaps the y-value of the third one. Haven't yet concidered those cases when there is only one extreme point but attacking this problem involves solving general third degree polynomial equations. Which it seems I can't. Pity. Any suggestions are welcome.

Comments (7)

photo
1

You don't need to solve a cubic equation, just a pair of simultaneous equations to get


    {k = (((-12) * b) + (12 * d)) / (a^(4) - ((2 * a^(3)) * c) - ((2 * a^(3)) * e) + (((6 * a^(2)) * c) * e) + ((2 * a) * c^(3)) - (((6 * a) * c^(2)) * e) - c^(4) + ((2 * c^(3)) * e)), cc = ((a^(4) * d) - (((2 * a^(3)) * c) * d) - (((2 * a^(3)) * d) * e) + ((((6 * a^(2)) * c) * d) * e) + (((2 * a) * b) * c^(3)) - ((((6 * a) * b) * c^(2)) * e) - (b * c^(4)) + (((2 * b) * c^(3)) * e)) / (a^(4) - ((2 * a^(3)) * c) - ((2 * a^(3)) * e) + (((6 * a^(2)) * c) * e) + ((2 * a) * c^(3)) - (((6 * a) * c^(2)) * e) - c^(4) + ((2 * c^(3)) * e))}


http://tube.geogebra.org/ma...

photo
1

Thanks - That was really helpful :D

photo
1

Do you think it's possible to get a quintic through 3 stationary points?


Here's my first attempt - went a bit wrong :)

http://tube.geogebra.org/st...

photo
1

Do you think it's possible to get a quintic through 3 stationary points?


Answer: yes (if you increase the CAS timeout). I think I'll stop there :)


    {k = ((((-10) * a^(4)) * d) + ((10 * a^(4)) * f) + (((20 * a^(3)) * c) * d) - (((20 * a^(3)) * c) * f) + (((20 * a^(3)) * d) * e) - (((20 * a^(3)) * e) * f) - ((((60 * a^(2)) * c) * d) * e) + ((((60 * a^(2)) * c) * e) * f) - (((20 * a) * b) * c^(3)) + ((((60 * a) * b) * c^(2)) * e) - ((((60 * a) * b) * c) * e^(2)) + (((20 * a) * b) * e^(3)) + (((20 * a) * c^(3)) * f) - ((((60 * a) * c^(2)) * e) * f) + ((((60 * a) * c) * d) * e^(2)) - (((20 * a) * d) * e^(3)) + ((10 * b) * c^(4)) - (((20 * b) * c^(3)) * e) + (((20 * b) * c) * e^(3)) - ((10 * b) * e^(4)) - ((10 * c^(4)) * f) + (((20 * c^(3)) * e) * f) - (((20 * c) * d) * e^(3)) + ((10 * d) * e^(4))) / ((a^(6) * c^(3)) - (((3 * a^(6)) * c^(2)) * e) + (((3 * a^(6)) * c) * e^(2)) - (a^(6) * e^(3)) - ((3 * a^(5)) * c^(4)) + (((6 * a^(5)) * c^(3)) * e) - (((6 * a^(5)) * c) * e^(3)) + ((3 * a^(5)) * e^(4)) + ((3 * a^(4)) * c^(5)) - (((15 * a^(4)) * c^(3)) * e^(2)) + (((15 * a^(4)) * c^(2)) * e^(3)) - ((3 * a^(4)) * e^(5)) - (a^(3) * c^(6)) - (((6 * a^(3)) * c^(5)) * e) + (((15 * a^(3)) * c^(4)) * e^(2)) - (((15 * a^(3)) * c^(2)) * e^(4)) + (((6 * a^(3)) * c) * e^(5)) + (a^(3) * e^(6)) + (((3 * a^(2)) * c^(6)) * e) - (((15 * a^(2)) * c^(4)) * e^(3)) + (((15 * a^(2)) * c^(3)) * e^(4)) - (((3 * a^(2)) * c) * e^(6)) - (((3 * a) * c^(6)) * e^(2)) + (((6 * a) * c^(5)) * e^(3)) - (((6 * a) * c^(3)) * e^(5)) + (((3 * a) * c^(2)) * e^(6)) + (c^(6) * e^(3)) - ((3 * c^(5)) * e^(4)) + ((3 * c^(4)) * e^(5)) - (c^(3) * e^(6))), p = (((3 * a^(5)) * d) - ((3 * a^(5)) * f) - (((5 * a^(4)) * c) * d) + (((5 * a^(4)) * c) * f) - (((5 * a^(4)) * d) * e) + (((5 * a^(4)) * e) * f) + ((((10 * a^(3)) * c) * d) * e) - ((((10 * a^(3)) * c) * e) * f) + (((5 * a) * b) * c^(4)) - ((((10 * a) * b) * c^(3)) * e) + ((((10 * a) * b) * c) * e^(3)) - (((5 * a) * b) * e^(4)) - (((5 * a) * c^(4)) * f) + ((((10 * a) * c^(3)) * e) * f) - ((((10 * a) * c) * d) * e^(3)) + (((5 * a) * d) * e^(4)) - ((3 * b) * c^(5)) + (((5 * b) * c^(4)) * e) - (((5 * b) * c) * e^(4)) + ((3 * b) * e^(5)) + ((3 * c^(5)) * f) - (((5 * c^(4)) * e) * f) + (((5 * c) * d) * e^(4)) - ((3 * d) * e^(5))) / (((5 * a^(4)) * d) - ((5 * a^(4)) * f) - (((10 * a^(3)) * c) * d) + (((10 * a^(3)) * c) * f) - (((10 * a^(3)) * d) * e) + (((10 * a^(3)) * e) * f) + ((((30 * a^(2)) * c) * d) * e) - ((((30 * a^(2)) * c) * e) * f) + (((10 * a) * b) * c^(3)) - ((((30 * a) * b) * c^(2)) * e) + ((((30 * a) * b) * c) * e^(2)) - (((10 * a) * b) * e^(3)) - (((10 * a) * c^(3)) * f) + ((((30 * a) * c^(2)) * e) * f) - ((((30 * a) * c) * d) * e^(2)) + (((10 * a) * d) * e^(3)) - ((5 * b) * c^(4)) + (((10 * b) * c^(3)) * e) - (((10 * b) * c) * e^(3)) + ((5 * b) * e^(4)) + ((5 * c^(4)) * f) - (((10 * c^(3)) * e) * f) + (((10 * c) * d) * e^(3)) - ((5 * d) * e^(4))), cc = (((a^(6) * c^(3)) * f) - ((((3 * a^(6)) * c^(2)) * e) * f) + ((((3 * a^(6)) * c) * d) * e^(2)) - ((a^(6) * d) * e^(3)) - (((3 * a^(5)) * c^(4)) * f) + ((((6 * a^(5)) * c^(3)) * e) * f) - ((((5 * a^(5)) * c^(2)) * d) * e^(2)) + ((((5 * a^(5)) * c^(2)) * e^(2)) * f) - ((((6 * a^(5)) * c) * d) * e^(3)) + (((3 * a^(5)) * d) * e^(4)) + (((3 * a^(4)) * c^(5)) * f) - ((((15 * a^(4)) * c^(3)) * e^(2)) * f) + ((((15 * a^(4)) * c^(2)) * d) * e^(3)) - (((3 * a^(4)) * d) * e^(5)) - ((a^(3) * c^(6)) * f) - ((((6 * a^(3)) * c^(5)) * e) * f) + ((((15 * a^(3)) * c^(4)) * e^(2)) * f) - ((((15 * a^(3)) * c^(2)) * d) * e^(4)) + ((((6 * a^(3)) * c) * d) * e^(5)) + ((a^(3) * d) * e^(6)) + ((((5 * a^(2)) * b) * c^(5)) * e^(2)) - ((((15 * a^(2)) * b) * c^(4)) * e^(3)) + ((((15 * a^(2)) * b) * c^(3)) * e^(4)) - ((((5 * a^(2)) * b) * c^(2)) * e^(5)) + ((((3 * a^(2)) * c^(6)) * e) * f) - ((((5 * a^(2)) * c^(5)) * e^(2)) * f) + ((((5 * a^(2)) * c^(2)) * d) * e^(5)) - ((((3 * a^(2)) * c) * d) * e^(6)) - ((((3 * a) * b) * c^(6)) * e^(2)) + ((((6 * a) * b) * c^(5)) * e^(3)) - ((((6 * a) * b) * c^(3)) * e^(5)) + ((((3 * a) * b) * c^(2)) * e^(6)) + ((b * c^(6)) * e^(3)) - (((3 * b) * c^(5)) * e^(4)) + (((3 * b) * c^(4)) * e^(5)) - ((b * c^(3)) * e^(6))) / ((a^(6) * c^(3)) - (((3 * a^(6)) * c^(2)) * e) + (((3 * a^(6)) * c) * e^(2)) - (a^(6) * e^(3)) - ((3 * a^(5)) * c^(4)) + (((6 * a^(5)) * c^(3)) * e) - (((6 * a^(5)) * c) * e^(3)) + ((3 * a^(5)) * e^(4)) + ((3 * a^(4)) * c^(5)) - (((15 * a^(4)) * c^(3)) * e^(2)) + (((15 * a^(4)) * c^(2)) * e^(3)) - ((3 * a^(4)) * e^(5)) - (a^(3) * c^(6)) - (((6 * a^(3)) * c^(5)) * e) + (((15 * a^(3)) * c^(4)) * e^(2)) - (((15 * a^(3)) * c^(2)) * e^(4)) + (((6 * a^(3)) * c) * e^(5)) + (a^(3) * e^(6)) + (((3 * a^(2)) * c^(6)) * e) - (((15 * a^(2)) * c^(4)) * e^(3)) + (((15 * a^(2)) * c^(3)) * e^(4)) - (((3 * a^(2)) * c) * e^(6)) - (((3 * a) * c^(6)) * e^(2)) + (((6 * a) * c^(5)) * e^(3)) - (((6 * a) * c^(3)) * e^(5)) + (((3 * a) * c^(2)) * e^(6)) + (c^(6) * e^(3)) - ((3 * c^(5)) * e^(4)) + ((3 * c^(4)) * e^(5)) - (c^(3) * e^(6)))}

photo
1

I had a lot of fun with this kind of thing a few years ago, see http://web.mat.bham.ac.uk/C...


There are some matrix methods which I think are a bit more interesting than the CAS output you've posted here ;-). Sorry Michael!


I've created the quintic GGB sheet along these lines, but really struggled with the dot product of two vector/1-D matrices so I did a nasty hack at the end to create the function. I hope all this makes sense?


Chris

https://ggbm.at/569223

photo
1

http://www.math.vanderbilt.... has one possibility, Possibly you checked it...


Tony

photo
1

Oh, yes Cardano's formula (and the related one such as in the link) for solving a cubic doesn't always work for non-real coefficients of the polynomial! This is a real trap for the CAS designer....


[...] most publications containing the Cardano solution of a cubic equation do not mention that his formula is not always correct for non-real coefficients. Consequently this formula has been misused by many people, including some computer algebra implementers, such as me. The consequences can be disastrous. (Stoutemyer2011)


The problem is to do with "which root" to take. Babbage said something about this as well:


It is by no means uncommon with algebraical authors, when they have led their readers through a process which terminates in an equation, to select that root which gives the answer they require, without explaining the signification of the other roots that are equally comprised in it; and this incomplete mode of solution, which is censurable from revealing only a part of the truth, has in some instances caused the most interesting circumstances attending a question to be entirely overlooked. (Babbage 1827)


I think some of the best explanations are in the older algebra text books from the late 1800s. See for example, Chapt. XII of Todhunter1885. The complete text of these older books is relatively easy to find online.


References


@ARTICLE{Babbage1827,

AUTHOR = "Babbage, C.",

TITLE = "On the influence of Signs in Mathematical Reasoning",

JOURNAL = "Transactions of the Cambridge Philosophical Society",

YEAR = "1827",

volume = "II",

part = "II",

pages = "325--377",

}


@BOOK{Todhunter1885,

AUTHOR = {Todhunter, I.},

TITLE = {Theory of Equations},

PUBLISHER = {MacMillian and Co.},

YEAR = {1885},

}


@ARTICLE{Stoutemyer2011,

AUTHOR = {Stoutemyer, D.~R.},

TITLE = {Ten commandments for good default expression simplification},

JOURNAL = {Journal of Symbolic Computation},

YEAR = {2011},

volume = {46},

number = {7},

pages = {859--887},

month = {July},

}

#doi:10.1016/j.jsc.2010.08.017


I hope this helps!

© 2023 International GeoGebra Institute