SolveQuadratic

Solves a quadratic equation. A quadratic equation is a second-order polynomial equation in a single variable, x.

ax2 + bx + c = 0

with a <> 0 . Because it is a second-order polynomial equation, the fundamental theorem of algebra guarantees that it has two solutions. These solutions may be both real, or both complex.

Syntax

Rhino.SolveQuadratic (dblA, dblB, dblC)

Parameters

dblA

Required.  Number.  The A coefficient.

dblB

Required.  Number.  The B coefficient.

dblC

Required.  Number.  The C coefficient.

Returns

Array

The results of the calculation, if successful, where:

Element

Type

Description

0

Number

The results of the calculation, where:

0 = Two distinct real roots (R0 < R1) are returned.

1 = One real root (R0 = R1) is returned.

2 = Two complex conjugate roots (R0 +/- (R1)*Sqr(-1)) are returned

1

Number

The first root, or R0.

2

Number

The second root, or R1.

 

Null

If not successful, or on error.

Example

Dim arrSolve

arrSolve = Rhino.SolveQuadratic(2, 4, -30)

If IsArray(arrSolve) Then

  Rhino.Print "Root 0 = " & CStr(arrSolve(1))

  Rhino.Print "Root 1 = " & CStr(arrSolve(2))

End If

Also See

Math Functions