evaluate an object using hardware floats in external code - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : VB Application Programming Interface : Evaluation and Error Handling : OpenMaple/VB/MapleEvalhf

MapleEvalhf - evaluate an object using hardware floats in external code

EvalhfMapleProc - evaluate a procedure using hardware floats in external code

Calling Sequence

MapleEvalhf(kv, s)

EvalhfMapleProc(kv, fn, n, args)




kernel handle returned by StartMaple



Maple object object



Maple FUNCTION object



number of arguments



array of n hardware floats



These functions are part of the OpenMaple interface to Microsoft Visual Basic.


The MapleEvalhf function evaluates an expression to a numerical value using the hardware floating-point of the underlying system.  This command is equivalent to the Maple function, evalhf.


The EvalhfMapleProc function evaluates the function, f(args), to a numerical value using evalhf.  The n arguments provided are all 64-bit hardware floating-point numbers. The first argument must be inserted at args[1].  For example, to call f(3.14,2.718), set args[1] = 3.14, and args[2] = 2.718.  The value at args[0] is not used.


Function MyNewton(ByVal kv As Long) As Double

    Dim i As Long

    Dim guess(2) As Double

    Dim tolerance As Double

    Dim f, fprime, x, initguess As Long

    ' define a function in x to solve, and find it's derivative

    f = EvalMapleStatement(kv, "(x) -> x^3+2*x^2-9*x+2;")

    MapleAssign kv, ToMapleName(kv, "f", True), f

    fprime = EvalMapleStatement(kv, "unapply(diff(f(x),x),x);")

    x = ToMapleName(kv, "x", True)

    guess(1) = 1.1

    tolerance = 0.0001

    ' find a root (abort after 500 iterations)

    For i = 0 To 500

        'test current guess

        If Abs(EvalhfMapleProc(kv, f, 1, guess(0))) <= tolerance Then

            i = 501 'break


            'refine guess

            guess(1) = guess(1) - EvalhfMapleProc(kv, f, 1, guess(0)) / _

                        EvalhfMapleProc(kv, fprime, 1, guess(0))

        End If

    Next i

    If i = 500 Then

        MyNewton = -999999  'couldn't find root


        MyNewton = guess(1)

    End If

End Function

See Also

evalhf, OpenMaple, OpenMaple/VB/API, OpenMaple/VB/Examples

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam