Results 1 to 17 of 17

Thread: [RESOLVED] Quadratic function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    Resolved [RESOLVED] Quadratic function

    i need to transform the quadratic function into a one line math problem so i can just stick in a, b, and c into 3 different text boxes and then press a button and calculate it based on what a, b, and c are.

    i hope i posted this in the write place but if i didn't then can a mod please move it.
    Attached Images Attached Images  

  2. #2
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: Quadratic function

    Code:
    xa = (-b + Sqr(((b * b) - (4 * a * c)))) / (2 * a)
    xb = (-b - Sqr(((b * b) - (4 * a * c)))) / (2 * a)
    Its in 2 lines as you need to get the plus and the minus values of x.

  3. #3
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Quadratic function

    It's not always that simple. Specifically, if the discriminant (b2 - 4ac) is negative, you will get an error with the Sqr() function.
    Code:
      Dim a As Double, b As Double, c As Double, d As Double
      Dim x1 As Double, x2 As Double
      Dim realpart As Double, imaginarypart As Double
      Dim message As String
      
      ' Insert code to:
      ' 1) get values for a, b, and c
      ' 2) ensure that a <> 0
      
      d = b * b - 4 * a * c
      If d = 0 Then
        ' There is one real solution:
        x1 = -b / (a + a)
        message = "x = " & CStr(x1)
      ElseIf d > 0 Then
        ' There are two real solutions:
        x1 = (-b + Sqr(d)) / (a + a)
        x2 = (-b - Sqr(d)) / (a + a)
        message = "x = " & CStr(x1) & vbCrLf & "x = " & CStr(x2)
      Else ' d < 0
        ' There are two complex solutions:
        realpart = -b / (a + a)
        imaginarypart = Sqr(-d) / Abs(a + a)
        message = "x = " & CStr(realpart) & " + " & CStr(imaginarypart) & "i" & vbCrLf
        message = message & "x = " & CStr(realpart) & " - " & CStr(imaginarypart) & "i"
      End If
      MsgBox message

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    Re: Quadratic function

    Thank you logophobic with a little tweaking your code worked great.

  5. #5
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: Quadratic function

    Hi, I was just wondering if you could tell me what a quadratic function is for, and what it does?

    Cheers
    Icyculyr

  6. #6
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Quadratic function

    It tells you the solution(s) to a quadratic equation, in the form of:

    ax^2 + bx + c = 0

  7. #7
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: Quadratic function

    The solutions are simply where it crosses the x-axis. Of course you get ones which don't cross the x-axis and in that case the discriminant (the Sqrt(b^2-4ac) part) is negative. And as you know you cant get the square root of a negative number. So in that case there are no solutions.

  8. #8
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Quadratic function

    Quote Originally Posted by 03myersd
    And as you know you cant get the square root of a negative number. So in that case there are no solutions.

    I'm sure you've heard of imaginary numbers, where i = sqrt(-1), and all the rest are multiples of i.....

    "Complex numbers" is the general term, and they have the form a+ib. They can be used to describe the entire range of numbers on the complex plane.
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  9. #9
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Quadratic function

    I'm sure he did too, but to be honest if somebody doesn't know what the quadratic function is used for, it's probably best not to confuse them with imaginary numbers just yet

  10. #10
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Quadratic function

    I've often found it's better not to deliberately say something that isn't true, because it's surprising what people remember a year or two down the line and subsequently things can become very confusing. "But I thought I was told that there was no such thing as the square-root of -1...???"

    Better to skirt about the issue than mislead.
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  11. #11
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: Quadratic function

    Interesting

    Cheers
    Icyculyr

  12. #12
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: Quadratic function

    Quote Originally Posted by zaza
    I'm sure you've heard of imaginary numbers, where i = sqrt(-1), and all the rest are multiples of i.....

    "Complex numbers" is the general term, and they have the form a+ib. They can be used to describe the entire range of numbers on the complex plane.

    Yeah I did but as NickThissen said, its very complex compared to the straight forward quadratic function.

  13. #13
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Quadratic function

    Quote Originally Posted by 03myersd
    ...its very complex...
    Yay bad and probably unintentional puns!

    On a more interesting note, there is no (sane...) solution of the order 5 polynomial. That is, for the equation

    ax5+bx4+cx3+dx2+ex1+f = 0,

    there is no simple equation like the Quadratic Equation which can solve it. There are, however, versions of the Quadratic Formula for the third and (IIRC) fourth order polynomials. If you're interested in that sort of thing, take or study Group Theory/Galois Theory someday
    Last edited by jemidiah; May 1st, 2008 at 03:02 AM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  14. #14
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Quadratic function

    Quote Originally Posted by zaza
    I've often found it's better not to deliberately say something that isn't true, because it's surprising what people remember a year or two down the line and subsequently things can become very confusing. "But I thought I was told that there was no such thing as the square-root of -1...???"

    Better to skirt about the issue than mislead.
    True. However this is the way most students will learn about complex numbers. I can't imagine for example a basics math studybook explaining what a square root of a number is, before veering off into explaning what complex numbers are...

    Most people will think that square roots of negative numbers don't exist, and for the problems they have to solve, they ofcourse don't need complex numbers.
    People in middle school for example who are going to become sport teachers or something like that probably don't care nor need to know about complex numbers.
    Once you start studying higher maths or physics or whatever you need complex numbers for, then you can be taught about the square root of negative numbers.


    But I do agree that it's a bit 'wrong' to exclaim the fact that square roots of negative numbers don't exist.

  15. #15
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: Quadratic function

    Lol, this is probably stupid, I but I've always figured the square root of -9, would be 3.. as 9 is 3.. is that right?

    I also wonder, how do you do those little one's, two's, three's, four's, and five's etc.. as in post #13

    Cheers
    Icyculyr
    Last edited by Icyculyr; May 1st, 2008 at 11:15 PM.

  16. #16
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: Quadratic function

    Ive never done it properly but from what ive picked up the square root of -9 is 3i. I wouldn't mind knowing how to do the superscripts either.

  17. #17
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Quadratic function

    The square root of -9 can never be 3 because of the definition of square roots.
    If the square root of -9 would be 3, then 32 would be -9, which ofcourse it's not.
    Also, because every real number squared (2) is positive, the square root of a negative number can never be a real number. (Real numbers are all numbers from - infinity to +infinity).

    However, some time back (can't remember the date lol), someone (Euler?) believed it would be useful if we could define a number which square would be negative. That number became i and it's defined as: i2 = -1.
    Therefore, sqrt(-1) = i.
    And, sqrt(-9) = 3i.

    Oh and superscript is done with (sup)..(/sup) (only then with [ ] )


    Slightly offtopic, but here's proof that -1 = 1

    We all know 1 = -1 * -1
    We also know sqrt(1) = 1.
    Because 1 = -1*-1 we can write:
    1 = sqrt(1) = sqrt(-1*-1) = sqrt(-1) * sqrt(-1) = i * i = i2 = -1

    ^^

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