Results 1 to 4 of 4

Math Help - Finding roots of cubic polynomial based off the discriminant (in C#)

  1. #1
    Junior Member
    Joined
    Jan 2010
    Posts
    47

    Finding roots of cubic polynomial based off the discriminant (in C#)

    OK, so I'm writing an ASP.NET MVC (in C#) web application that solves for the roots of quadratic, cubic and quartic polynomials.

    Now, I've done the quadratic portion, just because the math for that equation is so simple, basing it off of conditionals related to the discriminant, and the plugging values into the quadratic formula accordingly.

    Now, cubics are a little different..

    I have found the discriminant via this Wikipedia article. and set up a conditional based on the discriminant equaling, or being greater than or less than 0.

    So, according to the article, if the discriminant:

    < 0; 1 real root; 2 imaginaries
    = 0; 1 real root with a multiplicity of 2; and 1 regular real root
    > 0; 3 real roots

    So, now that I have found that out, I need to decide what to calculate in my program. If you read the part of the article in the link that I have just described above, what follows next kind of confuses me.

    It looks like it reads that if the discriminant is > 0 (and therefore there are 3 distinct real roots) to use this formula:

    (2b3 − 9abc + 27a2d)2 − 4(b2 − 3ac)3 = − 27a2

    However, that doesn't quite make sense since it isn't equal to an x value at all.



    Does anyone know how to compute the real roots based on the discriminant being equal to, greater than or less than 0?

    I need some help!

    Thanks!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Master Of Puppets
    pickslides's Avatar
    Joined
    Sep 2008
    From
    Melbourne
    Posts
    5,234
    Thanks
    27
    The job of the discriminant is to give you the nature of the roots only.

    You can compute them using the cubic formula which is in the article you have mentioned above.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Jan 2010
    Posts
    47
    Quote Originally Posted by pickslides View Post
    The job of the discriminant is to give you the nature of the roots only.

    You can compute them using the cubic formula which is in the article you have mentioned above.
    Yes, I understand that.

    However, like with quadratics, the discriminant allows me to figure out how many roots I need to solve for, and instead of returning NaN, I can return something more human-readable to the end-user, such as "No real solution" or something like that.



    That is the formula you are referencing, correct?

    Then what is this:


    (2b3 − 9abc + 27a2d)2 − 4(b2 − 3ac)3 = − 27a2Δ > 0

    Mentioned right before that image?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Junior Member
    Joined
    Jan 2010
    Posts
    47
    Oh, I just realized that with the image from Wikipedia I included above, they use the imaginary unit (i) for the second and third root. Double checking with the article, it states that the formula in that image is for when there are two imaginary roots. Therefore, when the discriminant is less than 0, I can use the formula described above as the x1 root.

    Then, it looks like this:

    (2b3 − 9abc + 27a2d)2 − 4(b2 − 3ac)3 = − 27a2Δ > 0

    Is for when the discriminant is >= 0. Now, what I don't get is why are they including Δ > 0 when it could be Δ = 0 as well. (in this case, the article uses Δ to refer to the value of the discriminant).

    So, if the above formula is for when the discriminant is >= to 0, then why is there no x, and why is -27a2 on the right side of the equation?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 2
    Last Post: April 15th 2011, 12:54 PM
  2. Roots of a Cubic Polynomial
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: October 10th 2009, 05:10 PM
  3. Polynomial cubic roots
    Posted in the Algebra Forum
    Replies: 3
    Last Post: June 30th 2009, 04:35 AM
  4. polynomial cubic roots
    Posted in the Algebra Forum
    Replies: 1
    Last Post: June 26th 2009, 08:47 PM
  5. Roots of a cubic polynomial
    Posted in the Algebra Forum
    Replies: 4
    Last Post: April 3rd 2009, 12:32 PM

Search Tags


/mathhelpforum @mathhelpforum