 EvalhfMapleProc - Maple Help

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) Parameters

 kv - kernel handle returned by StartMaple s - Maple object object fn - Maple FUNCTION object n - number of arguments args - array of n hardware floats Description

 • 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.  For example, to call f(3.14,2.718), set args = 3.14, and args = 2.718.  The value at args is not used. Examples

 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 Else '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 Else MyNewton = guess(1) End If End Function