Signature (Visual Basic / VBA)
Public Function QuadraticRoot( _
ByVal vA As Variant _
, ByVal vB As Variant _
, ByVal vC As Variant _
, ByVal vRootNum As Variant _
) As Variant
Code Examples
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"
(-vB - Sqr(vB ^ 2 - 4 * vA * vC)) / (2 * vA)
(-vB + Sqr(vB ^ 2 - 4 * vA * vC)) / (2 * vA)
Parameters
| Parameter | Description |
|---|---|
| vRootNum | The number of the solution that is to be returned, either 1 or 2. Function returns Null if vRootNum if Null or cannot be fixed up to a number that is either 1 or 2. |
Notes & Version History
| Note | 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. |
| vA, vB, and vC | See the definition above. Function returns Null if any of the arguments vA, vB, or vC are Null or cannot be fixed up to real or complex numbers (as defined by the ComplexStringToReals function). Complex numbers are represented within strings as "R|I" where R is the real part and I is the imaginary part. |