Public Function QuadraticRoot( _
ByVal vA As Variant _
, ByVal vB As Variant _
, ByVal vC As Variant _
, ByVal vRootNum As Variant _
) As Variant QuadraticRoot(-2, -2, 3, 1) = -1.82287565553229
QuadraticRoot(-2, -2, 3, 2) = 0.822875655532295
QuadraticRoot(-2, -3, -4, 1) = "-0.75|1.19895788082818"
QuadraticRoot(-2, -3, -4, 2) = "-0.75|-1.19895788082818"See also: QuadraticExpr Function
CubicRoot function
QuadraticRootSample Subroutine
QuadraticRootBenchmark SubroutineNote: In many cases you will have to accept a complex number as the return value then round that number off to zero if it approximately equal to zero. Solution #1:
(-vB - Sqr(vB ^ 2 - 4 * vA * vC)) / (2 * vA)Solution #2:
(-vB + Sqr(vB ^ 2 - 4 * vA * vC)) / (2 * vA)
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.