|
RootX
The RootX control is
utilized to find a root (zero crossing) of a user supplied function.
The control also has a routine for finding the minimum or maximum of a
user supplied function.
RootX1.rootfind(initX1 As Double, initX2 As Double, xacc As Double,
Xfinal As Double, Yfinal As Double, userfunc As Long) As Long
A
simple example of root and min finding:
Sub
findminroot()
Dim
x1 As Double, x2 As Double, x3 As Double, xfinal As Double, yfinal As Double
'
initial bracket
x1
= -1000#
x2
= 1000#
'
required accuracy
x3
= 0.0001
'
find root (user supplied function roottest, below)
Call
RootX1.rootfind(x1, x2, x3, xfinal, yfinal, AddressOf roottest)
MsgBox
"Root X Y = " & xfinal & " " & yfinal
'
find min (user supplied function mintest, below)
Call
RootX1.minmaxfind(x1, x2, x3, xfinal, yfinal, AddressOf mintest)
MsgBox
"Minimum X Y = " & xfinal & " " & yfinal
End
sub
'Example
user supplied functions
Function
roottest(ByVal x As Double) As Double
roottest = (x - 3.45)
End
Function
Function
mintest(ByVal x As Double) As Double
mintest = (x - 3.45) ^ 2
End
Function
|