The a N (
finds a minimum value for a formula. It is very similar in operation
to a R (
calc-find-root): You give the formula and an initial
guess on the stack, and are prompted for the name of a variable. The guess
may be either a number near the desired minimum, or an interval enclosing
the desired minimum. The function returns a vector containing the
value of the variable which minimizes the formula's value, along
with the minimum value itself.
Note that this command looks for a local minimum. Many functions have more than one minimum; some, like ‘x sin(x)’, have infinitely many. In fact, there is no easy way to define the “global” minimum of ‘x sin(x)’ but Calc can still locate any particular local minimum for you. Calc basically goes downhill from the initial guess until it finds a point at which the function's value is greater both to the left and to the right. Calc does not use derivatives when minimizing a function.
If your initial guess is an interval and it looks like the minimum occurs at one or the other endpoint of the interval, Calc will return that endpoint only if that endpoint is closed; thus, minimizing ‘17 x’ over ‘[2..3]’ will return ‘[2, 38]’, but minimizing over ‘(2..3]’ would report no minimum found. In general, you should use closed intervals to find literally the minimum value in that range of ‘x’, or open intervals to find the local minimum, if any, that happens to lie in that range.
Most functions are smooth and flat near their minimum values. Because of this flatness, if the current precision is, say, 12 digits, the variable can only be determined meaningfully to about six digits. Thus you should set the precision to twice as many digits as you need in your answer.
The H a N [
wminimize] command, analogously to H a R,
expands the guess interval to enclose a minimum rather than requiring
that the minimum lie inside the interval you supply.
The a X (
H a X [
wmaximize] commands effectively minimize the
negative of the formula you supply.
The formula must evaluate to a real number at all points inside the interval (or near the initial guess if the guess is a number). If the initial guess is a complex number the variable will be minimized over the complex numbers; if it is real or an interval it will be minimized over the reals.