Private Sub CubicRootSample() ' Print some samples of the CubicRoot function. Debug.Print "AX^3 + BX^2 + CX + D = 0" Randomize Dim intCurTry As Integer For intCurTry = 1 To 4 Debug.Print Dim A As Double Dim B As Double Dim C As Double Dim D As Double A = Rnd - 0.5 B = Rnd - 0.5 C = Rnd - 0.5 D = Rnd - 0.5 Debug.Print "A = " & A Debug.Print "B = " & B Debug.Print "C = " & C Debug.Print "D = " & D Dim X1 As Variant Dim X2 As Variant Dim X3 As Variant X1 = CubicRoot(A, B, C, D, 1) X2 = CubicRoot(A, B, C, D, 2) X3 = CubicRoot(A, B, C, D, 3) Debug.Print "X1 = " & X1 Debug.Print "X2 = " & X2 Debug.Print "X3 = " & X3 ' Evaluate the cubic expression for both roots. If Not IsNull(X1) Then Debug.Print "Eval X1 = " & CubicExpr(A, B, C, D, X1) If Not IsNull(X2) Then Debug.Print "Eval X2 = " & CubicExpr(A, B, C, D, X2) If Not IsNull(X3) Then Debug.Print "Eval X3 = " & CubicExpr(A, B, C, D, X3) Next intCurTry End Sub
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.