I have a function of several variables for which I'd like to find the maximum.
On one hand, it's easy to work with in the sense that it's smooth, and its only local maximum is a global one. On the other hand, it starts behaving weirdly if you stray too far from this maximum.
When I try running FindMaximum
on it, it fails to give meaningful results unless I use an initial point which is very close to the maximum. I suspect that it tries to look at points which are too far and runs into trouble. I've tried several of the Methods described in the documentation.
If it just used a simple gradient ascent with small steps, it could easily find the maximum.
So my question is - how do I instruct FindMaximum
to be more conservative in its search?
Edit: My actual function is complicated, but I can reproduce the effect with a much simpler one that captures the basic problem.
FindMaximum[(1 + a) (1 - a^2)^(1/10), {{a, 1/100}}]
The maximum of this function is at 5/6 (with a value of 1.62836), as can be easily seen by starting anywhere the function is defined and following the slope. But when I run the above command, I get the result {1.46441, {a -> 0.508985}} with the message:
"FindMaximum::nrnum: "The function value -3.46289-1.12516\ I is not a real number at {a} = {2.1873596654572154`}"
For some reason FindMaximum
decided that trying to evaluate the function at 2.187, where it's undefined/complex-valued, is a good idea - and then went haywire.
What parameters can be set for FindMaximum
to allow it to handle this function with this starting point? I suspect that whatever works here, might also work for my function.