07-01-2003, 09:33 AM
Quote:I already made a function to do that for statlib... pity I'll have to rewrite it because I'm using strings now...That only finds the real roots... I suppose we'll let you get away with it this time...
Functions for finding roots of quadratic equations. Two needed: one for each root.
Code:a = 1
b = 4
c = 2
' equivilant to x²+4x+2
r1 = (-b + (SQR(b ^ 2 - (4 * a * c)))) / (2 * a)
r2 = (-b - (SQR(b ^ 2 - (4 * a * c)))) / (2 * a)
PRINT r1, r2
' returns -1, -3