|
-
Apr 26th, 2008, 07:56 PM
#1
Thread Starter
Hyperactive Member
-
Apr 27th, 2008, 03:10 AM
#2
Frenzied Member
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.
-
Apr 27th, 2008, 11:16 AM
#3
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
-
Apr 27th, 2008, 12:28 PM
#4
Thread Starter
Hyperactive Member
Re: Quadratic function
Thank you logophobic with a little tweaking your code worked great.
-
Apr 30th, 2008, 04:32 AM
#5
Frenzied Member
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
-
Apr 30th, 2008, 07:12 AM
#6
Re: Quadratic function
It tells you the solution(s) to a quadratic equation, in the form of:
ax^2 + bx + c = 0
-
Apr 30th, 2008, 11:36 AM
#7
Frenzied Member
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.
-
Apr 30th, 2008, 02:05 PM
#8
Re: Quadratic function
 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.
-
Apr 30th, 2008, 02:14 PM
#9
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
-
Apr 30th, 2008, 02:53 PM
#10
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.
-
Apr 30th, 2008, 07:03 PM
#11
Frenzied Member
Re: Quadratic function
Interesting 
Cheers
Icyculyr
-
May 1st, 2008, 01:21 AM
#12
Frenzied Member
Re: Quadratic function
 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.
-
May 1st, 2008, 02:59 AM
#13
Re: Quadratic function
 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.
-
May 1st, 2008, 02:06 PM
#14
Re: Quadratic function
 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.
-
May 1st, 2008, 11:11 PM
#15
Frenzied Member
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.
-
May 2nd, 2008, 01:32 AM
#16
Frenzied Member
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.
-
May 2nd, 2008, 04:25 AM
#17
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|