########################################## Global minimization of bivariate functions ########################################## ------------------------------ Analytic bivariate polynomials ------------------------------ Consider the problem of minimizing a bivariate polynomial .. math:: \underset{x,y\,\in\,\R}{\operatorname{minimize}}&~~p(x,y)\mbox{,} or more generally, a rational function .. math:: \underset{x,y\,\in\,\R}{\operatorname{minimize}}&~~\frac{p(x,y)}{q(x,y)}\mbox{.} Since all local minimizers :math:`(x^*,y^*)` are stationary points, they are roots of the system of bivariate polynomials .. math:: \frac{\partial p}{\partial x}q - p\frac{\partial q}{\partial x} &= 0\\ \frac{\partial p}{\partial y}q - p\frac{\partial q}{\partial y} &= 0\mbox{,} where :math:`q(x,y) \equiv 1` in the case of minimizing a bivariate polynomial. With ``polysol2``, Tensorlab offers a numerically robust way of computing isolated real roots of a system of bivariate polynomials .. math:: :label: bisys f(x,y) &= 0\\ g(x,y) &= 0 as the eigenvalues of a generalized eigenvalue problem :cite:`r738,r775`. Stationary points of bivariate polynomials and rational functions may be computed with ``polymin2`` and ``ratmin2``, respectively. ----------------------------------- Polyanalytic univariate polynomials ----------------------------------- Closely related is the problem of minimizing a polyanalytic univariate polynomial .. math:: \underset{z\,\in\,\C}{\operatorname{minimize}}&~~p(z,\conj{z})\mbox{,} or more generally, a rational function .. math:: \underset{z\,\in\,\C}{\operatorname{minimize}}&~~\frac{p(z,\conj{z})}{q(z,\conj{z})}\mbox{.} Analogously to the analytic bivariate case, all local minimizers are roots of the system .. math:: \frac{\partial p}{\partial z}q - p\frac{\partial q}{\partial z} &= 0\\ \frac{\partial p}{\partial \conj{z}}q - p\frac{\partial q}{\partial \conj{z}} &= 0\mbox{,} where the derivatives are Wirtinger derivatives (cf. Section :ref:`deriv`). The method ``polysol2`` can also solve systems of polyanalytic polynomials .. math:: :label: unisys f(z,\conj{z}) &= 0\\ g(z,\conj{z}) &= 0\mbox{.} In fact, given a system of bivariate polynomials :eq:`bisys`, ``polysol2`` will first convert it to the form :eq:`unisys` before computing the roots as the eigenvalues of a (complex) generalized eigenvalue problem. Stationary points of real-valued polyanalytic polynomials and rational functions may be computed with ``polymin2`` and ``ratmin2``, respectively.x ******************************************************* Stationary points of polynomials and rational functions ******************************************************* ---------------------------------- Polynomials and rational functions ---------------------------------- In MATLAB, a polynomial :math:`p(x)` is represented by a row vector ``p = [ad ... a2 a1 a0]`` as .. math:: p(x) = \begin{bmatrix}a_d & \cdots & a_2 & a_1 & a_0\end{bmatrix}\cdot \begin{bmatrix}x^d & \cdots & x^2 & x & 1 \end{bmatrix}^{\T}\mbox{.} For example, the polynomial :math:`p(x) = x^3 + 2x^2 + 3x +4` is represented by the row vector ``p = [1 2 3 4]``. Its derivative :math:`\frac{dp}{dx}` can be computed with ``polyder(p)`` and its zeros can be computed with ``roots(p)``. The stationary points of :math:`p(x)`, i.e., all :math:`x^*` which satisfy :math:`\frac{dp}{dx}(x^*) = 0`, are the output of ``roots(polyder(p))``. However, some of these solutions may have a small imaginary part which correspond to a numerical zero. The stationary points can also be computed as roots of the polynomial's derivative with ``polymin(p)``, which deals with solutions with small imaginary part and returns only real solutions. Analogously, the stationary points of a a rational function :math:`\frac{p(x)}{q(x)}` are given by .. code-block:: tensorlab roots(conv(polyder(p),q)-conv(p,polyder(q))) where ``conv(p,q)`` is the convolution of the two row vectors ``p`` and ``q`` and is equivalent to computing the coefficients of the polynomial :math:`p(x)\cdot q(x)`. As in the polynomial case, there are a few numerical issues which can be dealt with by computing the stationary points of :math:`\frac{p(x)}{q(x)}` with ``ratmin(p,q)``. -------------------------------------------- Bivariate polynomials and rational functions -------------------------------------------- In Tensorlab, a bivariate polynomial :math:`p(x,y)` is represented by a matrix ``p`` as .. math:: p(x,y) = \begin{bmatrix}1 & y & \cdots & y^{d_y}\end{bmatrix}\cdot \begin{bmatrix}a_{00} & \cdots & a_{0d_x}\\\vdots & \ddots & \vdots\\ a_{d_y0} & \cdots & a_{d_yd_x}\end{bmatrix}\cdot \begin{bmatrix}1 \\ x \\ \vdots \\ x^{d_x}\end{bmatrix}\mbox{.} For example, the six-hump camel back function :cite:`r740` .. math:: p(x,y) = 4x^2 - 2.1x^4+\frac{1}{3}x^6 + xy - 4y^2 + 4y^4 is represented by the matrix .. code-block:: tensorlab p = [ 0 0 4 0 -2.1 0 1/3; ... 0 1 0 0 0 0 0; ... -4 0 0 0 0 0 0; ... 0 0 0 0 0 0 0; ... 4 0 0 0 0 0 0]; and can be seen in :num:`Figure #sixhump`. The stationary points of the polynomial :math:`p(x,y)` can be computed as the solutions of the system :math:`\frac{\partial p}{\partial x} = \frac{\partial p}{\partial y} = 0` with ``polymin2(p)``. To obtain a global minimum, select the solution with smallest function value using .. code-block:: tensorlab [xy,v] = polymin2(p); [vmin,idx] = min(v); xymin = xy(idx,:); To visualize the level zero contour lines of :math:`\frac{\partial p}{\partial x}` and :math:`\frac{\partial p}{\partial y}` in the neighbourhood of the stationary points, set ``options.Plot = true`` as follows .. code-block:: tensorlab p = randn(6); % Generate random bivariate polynomial of coordinate degree 5. options.Plot = true; xy = polymin2(p,options); or inline as ``polymin2(randn(6),struct('Plot',true))``. .. _sixhump: .. figure:: img/sixhump_surfc.png :alt: sixhump :width: 80% :align: center The six-hump camel back function and its stationary points as red dots. The corresponding system of polynomials is solved by ``polysol2``. The latter includes several balancing steps to improve the accuracy of the solution. For some poorly scaled problems, the method may fail to find all solutions of the system. In that case, try decreasing the ``polysol2`` balancing tolerance ``options.TolBal`` to a smaller value, e.g., .. code-block:: tensorlab options.TolBal = 1e-4; xy = polymin2(p,options); Computing the stationary points of a bivariate rational function :math:`\frac{p(x,y)}{q(x,y)}` is completely analogous to the polynomial case. The following example generates a random bivariate rational function and computes its stationary points: .. code-block:: tensorlab p = randn(6); % Random bivariate polynomial of coordinate degree 5. q = randn(4); % Random bivariate polynomial of coordinate degree 3. options.Plot = true; xy = ratmin2(p,q,options); The inline equivalent of this example is ``ratmin2(randn(6),randn(4),struct('Plot',true))``. ----------------------------------------------- Polyanalytic polynomials and rational functions ----------------------------------------------- Polyanalytic polynomials :math:`p(z,\conj{z})` are represented by a matrix ``p`` as .. math:: p(z,\conj{z}) = \begin{bmatrix}1 & \conj{z} & \cdots & \conj{z}^{d_y}\end{bmatrix}\cdot \begin{bmatrix}a_{00} & \cdots & a_{0d_x}\\\vdots & \ddots & \vdots\\ a_{d_y0} & \cdots & a_{d_yd_x}\end{bmatrix}\cdot \begin{bmatrix}1 \\ z \\ \vdots \\ z^{d_x}\end{bmatrix}\mbox{.} For example, the polynomial :math:`p(z,\conj{z}) = 1 + 2z + 3z^2 + 4\conj{z} + 5z\conj{z} + 6z^2 \conj{z} + 7\conj{z}^2` is represented by the matrix .. code-block:: tensorlab p = [1 2 3; ... 4 5 6; ... 7 0 0]; However, minimizing a polyanalytic polynomial :math:`p(z,\conj{z})` only makes sense if :math:`p(z,\conj{z})` is real-valued for all :math:`z \in \C`. A polyanalytic polynomial is real-valued if and only if its matrix representation is Hermitian, i.e., ``p == p'``. As with bivariate polynomials, the stationary points of a real-valued polyanalytic polynomial :math:`p(z,\conj{z})` can be computed with ``polymin2(p)``. As an example, the stationary points of a pseudorandom real-valued polyanalytic polynomial can be computed with .. code-block:: tensorlab p = rand(6)+rand(6)*1i; p = p*p'; options.Plot = true; xy = polymin2(p,options); Computing the stationary points of a polyanalytic rational function :math:`\frac{p(z,\conj{z})}{q(z,\conj{z})}` is completely analogous to the polynomial case. For example, .. code-block:: tensorlab p = rand(6)+rand(6)*1i; p = p*p'; q = rand(4)+rand(4)*1i; q = q*q'; options.Plot = true; xy = ratmin2(p,q,options); .. note:: If the matrix ``p`` contains complex coefficients and is Hermitian, ``polymin2`` will treat ``p`` as a real-valued polyanalytic polynomial. Otherwise, it will be treated as a bivariate polynomial. In some cases it may be necessary to specify what type of polynomial ``p`` is. In that case, set ``options.Univariate`` to ``true`` if ``p`` is a real-valued polyanalytic polynomial and ``false`` otherwise. The same option also applies to ``ratmin2``. *********************************************************** Isolated solutions of a system of two bivariate polynomials *********************************************************** The functions ``polymin2`` and ``ratmin2`` depend on the lower level function ``polysol2`` to compute the isolated solutions of systems of bivariate polynomials :eq:`bisys` or systems of polyanalytic univariate polynomials :eq:`unisys`. In the case :eq:`bisys`, ``polysol2(p,q)`` computes the isolated real solutions of the system :math:`p(x,y) = q(x,y) = 0`. A solution :math:`(x^*,y^*)` is said to be isolated if there exists a neighbourhood of :math:`(x^*,y^*)` in :math:`\C^2` that contains no solution other than :math:`(x^*,y^*)`. Some systems may have solutions that are isolated in :math:`\R^2`, but not in :math:`\C^2`. .. note:: By default, ``polysol2(p,q)`` assumes ``p`` and ``q`` are polyanalytic univariate if at least one of ``p`` and ``q`` contains complex coefficients. If this is not the case, the user can specify the type of polynomial by setting ``options.Univariate`` to ``true`` if both polynomials are polyanalytic univariate or ``false`` otherwise. The algorithm in ``polysol2`` applies several balancing steps to the problem in order to improve the accuracy of the computed roots, before refining them with Newton-Raphson. If the system is poorly scaled, it may be necessary to decrease the balancing tolerance ``options.TolBal`` to a smaller value. In :num:`Figure #marcdeg20`, the solutions of a relatively difficult bivariate system :math:`p(x,y) = q(x,y) = 0` are plotted. The polynomials :math:`p(x,y)` and :math:`q(x,y)` are both of total degree 20 and have coefficients of which the exponents (in base 10) range between 1 and 7. .. _marcdeg20: .. figure:: img/marcdeg20.png :alt: marcdeg20 :width: 80% :align: center A system of bivariate polynomials :math:`p(x,y) = q(x,y) = 0` of total degree 20. .. ********** References ********** .. bibliography:: tensorlab.bib :style: unsrt