I want to find the maxima of a function, say f(x). Normally that is not difficult since we have a built in function that finds the maximum. The problem is, that it just finds the largest value of the function. What I really want is to find the maximum of f(x) that is stable within a certain amount of change in x. For example, I have a function of IIP3 vs. Width and I want to find the

Width that gives me the largest IIP3, so I use the command: IIP3max_width_index = max_index(IIP3) and it will pop out the width that gives me the best IIP3 (Actually, it pops out the index, which I would use in IIP3max_width=Width[IIP3max_width_index]).

Unfortunately, if IIP3 contains large peaks and/or valleys, this approach could result in a

choice of width that could be very sensitive to change, i.e. if my widths are a little off, I

could end up with a very bad IIP3. So I would like to be able to tell the simulator find me the max point whoâ€™s nearest (user defined number) neighbors have IIP3's very close to those of the maximum.

So, to elaborate, if I want the Width to be insensitive to changes of 2 Width steps then f(max-2),f(max-1),f(max),f(max+1),f(max+2) would all have values that are close. Now how close and

how I would define that I'm not sure. I guess I would have to specify something like a variance of +/- 10% or something.

I have looked at various ways to use derivatives and

moving averages and the like, but it seems as though for every solution I can think of a function that will sneak by and give me a sensitive max.

Any thoughts?

Width that gives me the largest IIP3, so I use the command: IIP3max_width_index = max_index(IIP3) and it will pop out the width that gives me the best IIP3 (Actually, it pops out the index, which I would use in IIP3max_width=Width[IIP3max_width_index]).

Unfortunately, if IIP3 contains large peaks and/or valleys, this approach could result in a

choice of width that could be very sensitive to change, i.e. if my widths are a little off, I

could end up with a very bad IIP3. So I would like to be able to tell the simulator find me the max point whoâ€™s nearest (user defined number) neighbors have IIP3's very close to those of the maximum.

So, to elaborate, if I want the Width to be insensitive to changes of 2 Width steps then f(max-2),f(max-1),f(max),f(max+1),f(max+2) would all have values that are close. Now how close and

how I would define that I'm not sure. I guess I would have to specify something like a variance of +/- 10% or something.

I have looked at various ways to use derivatives and

moving averages and the like, but it seems as though for every solution I can think of a function that will sneak by and give me a sensitive max.

Any thoughts?