Using MS Excel 2003 on XP...
Anyone have any ideas regarding what might cause the following discrepancy and how it might be corrected?
I am attempting to stop using the Solver Tool for some optimizations that do not require Newtonian convergence...
I created a custom optimization function in VBA. It solves to what first appears to be an acceptable value, but when I checked it against what I get via the exact same formula set in Excel (iteration via Solver Tool instead of VBA), the VBA solution value is significantly different (+/-5.0E-3 relative accuracy) even though all formulae and constants are exactly the same. This discrepancy is unacceptable. I do not even know which venue is more accurate (Excel or VBA).
I am seeking a solution that has relative accuracy +/-1.0E-5 or better. What I mean by "relative accuracy" is xUsed/xAccurate-1 = {relative accuracy}.
It is important to note that I am using exponents and logarithm functions, though not "aggressively" (I think).
I created a custom test function with logarithms and compared its result to that of a plain Excel formula (no VBA)... I saw that "as single" and "as double" made a difference there, but even when I set everything to "as double" in my original VBA formula, the discrepancy did not go away and actually did not change at all. Double gave the exact same answer as single in the original VBA formula. Sample code from test function, feel free to play around with it:
Function logTest1(meow1 As Single, meow2 As Single) As Double
logTest1 = Log(meow1) / Log(meow2)
End Function
It is interesting to note that another VBA test function using Excel formula behaved just like the VBA native formula:
Function logTest2(meow1 As Single, meow2 As Single) As Double
logTest2 = Application.WorksheetFunction.Log(meow1, meow2)
End Function
Anyone have any ideas regarding what might cause such a discrepancy and how it might be corrected?
Bookmarks