Results 1 to 5 of 5

Thread: Signs of X^2 + p*X + q = 0

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409

    Signs of X^2 + p*X + q = 0

    How can i find wheather the roots of the square equation (X^2 + p*X + q = 0) are positive or negative. (without solving the equation).
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Member
    Join Date
    Apr 2001
    Location
    Emden, Germany
    Posts
    63
    the equation solves always like:

    x = -p/2 +- Sqrt((p/2)^2-q)

    so just check the expression in the root. If it is negative, you'll have to deal with imaginary numbers or in other words, there are no real solutions to your equation.
    WIN 2000 Prof. / WIN 98 / WIN 95, IE6.0, Mathematica 4.0
    Visual Studio Enterprise 6.0 sp5

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Real or Complex?

    If the roots are complex, it is not clear what you mean by positive or negative.

    For real roots, it helps to know that q is the product of the roots, and -p is their sum.

    If q is negative, one root is positive and one is negative.

    If q is positive, both roots have the same sign, which is the opposite of the sign of p.
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  4. #4
    Member
    Join Date
    Apr 2001
    Location
    Emden, Germany
    Posts
    63
    ok, let's try it again.
    you never can say whether a squareroot is positive or negative. it is always both. think about
    (-2)^2=2^2
    sqareroot just undos the operation of ^2, but because the result of ^2 is always positive then information about the sign is lost. thus you usually have in quadratic equations the following two solutions:

    x1 = -p/2 + Sqrt((p/2)^2-q)
    x2 = -p/2 - Sqrt((p/2)^2-q)

    let's use s= (p/2)^2-q, means the expression in the squareroot

    in case of s=0 you will have one solution (x1=x2)
    in case of s<0 there are only imaginary results (=no real solutions)
    in case of s>0 you will always have two solutions which you have to check for sign

    you can also write the quadratic equation as follows:
    x^2+px+q=0=(x-x1)*(x-x2)
    from this you get
    q=x1*x2
    -p=x1+x2
    deducting further:
    if q has a positive sign, both solutions x1 and x2 must have the same sign, else there will be one positive and one negative solution.
    in case q is positive (x1 and x2 have the same sign) you can check the sign of them by taking a look at p: if p is positive, both have negative sign, else positive.
    (which is somewhat the same as guv wrote, just with the mathematical background)

    hope i didn't mix up the signs, i am close to braindead!
    ... and next time we'll show algebraic La Place transformations in visual basic (just kidding! but i could really use that)
    WIN 2000 Prof. / WIN 98 / WIN 95, IE6.0, Mathematica 4.0
    Visual Studio Enterprise 6.0 sp5

  5. #5

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    OK, thanks for the replies.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width