On Sun, Jan 28, 2007 at 10:59:14PM -0500, Adam Christopher Lawrence wrote:
> Several fruitless hours of searching through the documentation and the
> Internet in general has left me very puzzled. Maxima - seemingly - has
> no mechanism for calculating the relative extrema of a polynomial over a
> given range. Other posts implied that a function 'lbfgs' can do this
> function, but the language in the help file for this function seems
> targeted to PhD candidates, as I cannot make heads or tails out of it.
Do you want numerical approximations (floating point) or do you want
symbolic results (such as sqrt(2)/4 or similar)?
For functions of a single real variable, the procedure to find a
maximum is this:
Find the derivative. Find where the derivative is zero. For each of
these points which is within your interval, check to see whether the
second derivative is negative (therefore the function is concave
downwards). If it is, one of these points is your maximum. Otherwise
the maximum occurs on the boundary of the interval.
Maxima will do all of these steps for a wide class of functions.
> So, experts: say you have a fourth-order function like f(x):=10x^4 -
> 3x^3 + 2x^2 -6x + 1. Is there any command for finding the minimum and
> maximum values of this function over a specified range? Is there no
> equivalent to the Maple "maximize" and "minimize" functions?
I don't believe that there is a maximize or minimize function.
Depending on how much calculus you know, it is relatively
straightforward to carry out the maximization procedure using
differentiation.
f: 10*x^4-3*x^3+2*x^2-6*x+1;
df: diff(f,x);
now you can ask solve to find where df = 0,
solve(df=0,x);
however, for higher orders it may not be possible. And in general, you
may prefer to find only the real roots to some high precision,
imaginary numbers are probably not what you're interested in:
root:realroots(df,1/10^6);
It turns out there is only one root of the derivative. We now need to
check whether the function is concave up, down, or saddle point
here. Calculate the second derivative.
ddf:diff(df,x);
subst(first(root),ddf);
The previous result is a largish positive number, therefore the
concavity is upwards, and the point is a local minimum. so given any
interval, your maximum will occur on one or the other end of the
interval. So you just check the endpoints.
As for LBFGS it will try to find a minimum of a function numerically
(you can always convert a minimization procedure to a maximization
procedure by multiplyin by -1 so lbfgs only does minimization), but it
won't do it on a constrained interval as far as I know.
You can write a straightforward procedure which will carry out this
process, checking each of the roots of the derivative, and the
boundary points. You need not even check the second derivative if you
simply take the maximum of the function over x on the endpoints and at
the roots of the derivative that fall within your interval.
Hope that is helpful.
--
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan