How to work with small numbers

User Name

Spammer
Joined
Aug 10, 2010
Messages
182
Hello... I'm working on an optimization algorithm that minimizes quantity X in an iterative fashion. At this point the algorithm is working well enough that my errors are sometimes getting down below 10^-16 - this is displayed as a 0.00E+00 in my results.

I'm worried that even smaller errors might be overlooked if numbers smaller than 10^-16 are recorded as zero. Is this what happens? I've currently got everything declared as double. Is there a way to declare a custom variable that allows for smaller numbers or more digits?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Is this displayed value in VBA or in Excel? Not that it should really matter since both Excel and VBA should correctly show 10^-16.

So, some more details about what you are doing and where you are showing the result...
 
Upvote 0
I've written an algorithm to solve for the parameters of the Characteristic Equation - this equation has to do with photovoltaic modeling. I start out with a 100 by 100 grid of inputs. Input A has 100 values and input B has 100 values. Input A is incremented up by 1, the equation is solved, Input A is incremented up by 1 again, the equation is solved etc. When input A gets to the end of it's range input B ratchets up by 1 and the process starts over.

The output of the process is an Error value. If the Error is below a chosen threshold value, say .5, then the process feeds into a Nelder-Mead algorithm that zooms in on the solution. At the end of the Nelder-Mead step the Error value is compared against the minimum Error so far and the parameters associated with this Error are saved if the Error is the lowest so far.

Sometimes my Nelder-Mead algorithm gets to a zero error. So my thinking is, what happens if another zero value comes along? Will it replace the previous zero? I can approach the problem from other angles but I'd like to know how VBA deals with these zero values.

At this point I'm dicing mice nuts... I'm happy enough with my results as they stand so it won't be the end of the world if I can't get to the bottom of this situation. Any advice is appreciated though.
 
Upvote 0
I would say it depends, not on VBA, but on you.

If the error you are evaluating can never be negative (say, the absolute or the square of some term), then you may want to stop your process when you reach zero. Or, you could "save" this result and continue searching for the next zero error. This would let you report all inputs that yield a zero error.
 
Upvote 0

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top