This program illustrates the process of finding the maximum and minimum values of functions of two variables f(x,y) on closed
and bounded domains D in R2. The domain D is specified by a set of defining functions g1(x,y),…,gN(x,y) in the sense that
(x,y)∈D if and only if gj(x,y)≥0 for all j=1,…,N.
It is assumed that all functions are continuously differentiable, that D is closed and bounded, and that for each defining function g(x,y)
we have ∇g=0 whenever g=0, and at points where more than one of the defining function vanishes the respective gradients
are supposed to be independent.
The interior of D is then the set of points where all functions gj are strictly positive, and the boundary consists of pieces of zero sets
of the defining functions. The condition on the gradients of the defining functions insures that the boundary is a collection of
smooth curves that intersect each other transversally.
In the program below, you can specify the function f(x,y) to be discussed and a list [g1(x,y),…,gN(x,y)] to specify the domain.
Depending on the input, it may take quite a while for the program to finish. Proper functionality strongly depends on the symbolic
solver. It is advisable to stick to algebraic functions of simple structure, and to avoid cases where the critical point equations
or Lagrange multiplier equations are solved by parametrized curves rather than merely a finite collection of points.