12.07.2015 Views

Diploma thesis - Czech Technical University in Prague

Diploma thesis - Czech Technical University in Prague

Diploma thesis - Czech Technical University in Prague

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ČESKÉ VYSOKÉ UČENÍ TECHNICKÉ V PRAZEFAKULTA ELEKTROTECHNICKÁKATEDRA ŘÍDICÍ TECHNIKYDIPLOMOVÁ PRÁCEMuPAD Library for Symbolic Computationwith Polynomial MatricesPetr Augusta2005Vedoucí:Oponent:Ing. Zdeněk Hurák, Ph.D.Centrum aplikované kybernetiky, Katedra řídicí techniky,Fakulta elektrotechnická, České vysoké učení technické v PrazeRNDr. Aleš NěmečekKatedra matematiky, Fakulta elektrotechnická,České vysoké učení technické v Praze


AnotacePráce popisuje nově vytvořenou a volně dostupnou knihovnu funkcí pro symbolické počítánís polynomy a polynomiálními maticemi nazvanou Polmat. Knihovna Polmat je vyvíjena proMuPAD, snadno dostupný a výkonný počítačový algebraický systém a programovací jazyk. SamotnýMuPAD neobsahuje funkce pro analýzu systémů a návrh regulačních obvodů a filtrů,a proto vznikla snaha tyto algoritmy vytvořit. Knihovna najde uplatnění ve výzkumu a vývojitzv. algebraických metod návrhu regulátorů a filtrů. Implementovány byly funkce pro řešeníl<strong>in</strong>eárních rovnic s polynomy a polynomiálními maticemi, výpočet spektrální faktorizace polynomua polynomiální matice a další. Dokument obsahuje úvod do počítání s polynomiálnímimaticemi a počítání s počítačovými algebraickými systémy, popis použití funkcí a procedur,vysvětlení užitých metod, demonstrativní příklady a výsledky zkušebních testů.AbstractThis diploma <strong>thesis</strong> comes with a freely available library for symbolic computation with polynomialsand polynomial matrices, named Polmat. The Polmat library is developed for MuPAD,which is an easily accessible efficient computer algebra system and programm<strong>in</strong>g language.MuPAD does not conta<strong>in</strong> functions used for design and analysis of control systems, therefore,an endeavour to make them arose. Solvers for l<strong>in</strong>ear equations with polynomials and polynomialmatrices, spectral factorization of polynomials and polynomial matrices and others havebeen implemented. This document conta<strong>in</strong>s <strong>in</strong>troduction <strong>in</strong>to polynomial matrix computationand basic usage of computer algebra systems, syntax of implemented functions and procedures,description of used methods, demonstrative examples and results of computational test<strong>in</strong>g.2


Contents1 Introduction 52 Polynomial Matrix Computation 72.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Computer Algebra Systems 113.1 Maple and Mathematica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2 Matlab and Polynomial Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . 123.3 Scilab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 MuPAD 134.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2 MuPAD Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3 MuPAD-Scilab L<strong>in</strong>k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 New Data Type Polmat 185.1 Def<strong>in</strong>ition of a New Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 Algorithms 216.1 Greatest Common Divisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216.2 Adjo<strong>in</strong>t, Inverse, Determ<strong>in</strong>ant and Rank . . . . . . . . . . . . . . . . . . . . . 226.3 Solution of L<strong>in</strong>ear Equations with Polynomials, Polynomial Matrices . . . . . . 246.4 Spectral Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.5 Matrix Reductions and Decompositions . . . . . . . . . . . . . . . . . . . . . 296.6 Routh Table and Its Offer <strong>in</strong> Addition to Stability . . . . . . . . . . . . . . . . . 336.7 Division of Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356.8 M<strong>in</strong>imal Realization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Benchmarks 377.1 Equation Solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377.2 Matrix Determ<strong>in</strong>ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387.3 Smith Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393


8 Applications <strong>in</strong> Control Design 408.1 Cruise Control System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408.2 Inverted Pendulum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448.3 Pendulum Discrete-Time Model . . . . . . . . . . . . . . . . . . . . . . . . . . 488.4 Robust Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Conclusions 53Bibliography 55List of Symbols 58List of Figures 59List of Tables 60Index 614


Chapter 1IntroductionThe polynomial methods, launched <strong>in</strong> 1970’s from <strong>Czech</strong>oslovakia, are one of the two ma<strong>in</strong> usedapproaches to l<strong>in</strong>ear systems, the other be<strong>in</strong>g the so-called state-space methods. With<strong>in</strong> thisframework, systems are described by <strong>in</strong>put-output relations, i. e. the systems with s<strong>in</strong>gle <strong>in</strong>putand s<strong>in</strong>gle output (SISO) by univariate polynomial fractions and the systems with multiple<strong>in</strong>puts and multiple outputs (MIMO) by left or right fractions of polynomial matrices. Theprocedures for analysis of properties of dynamical systems and controller design are based onmanipulation with polynomials and polynomial matrices.While the state-space methods, which operate with constant matrices, are <strong>in</strong>cluded <strong>in</strong> manysoftware libraries, there are a few packages that can handle polynomial matrices. The mostcomplete library is no doubt the commercial Polynomial Toolbox for Matlab [44], developed byPolyX company. A few functions are implemented <strong>in</strong> Maple [43], Scilab [46]. Quite recently,some other packages for polynomial matrices computation for various software have beendeveloped by the students of <strong>Czech</strong> <strong>Technical</strong> <strong>University</strong> <strong>in</strong> <strong>Prague</strong>: Mathematica package forpolynomial matrices [21, 22] by Petr Kujan, package Polpack++ for C++ [6] by Leoš Halmo,Java package [33] by Michal Paděra, a library for TI-89/TI-92 programmable calculators [39]by Petr Štefko. These packages are based on numerical methods.Numerical computation plays central role <strong>in</strong> <strong>in</strong>dustrial applications. Even the task of acontroller design us<strong>in</strong>g polynomial methods is transformed <strong>in</strong>to series of numerical operationswith constant matrices, for which numerous software libraries are available (LAPACK, NAG,IMSL). The algorithms are based on e. g. Sylvester matrix methods, <strong>in</strong>terpolation [8, 12] andthere is endeavour to improve them all the time. However fast and efficient, these numericalalgorithms are not always useful and reliable. The round<strong>in</strong>g errors <strong>in</strong>troduced by f<strong>in</strong>ite precisionarithmetics (ma<strong>in</strong>ly 64-bit float<strong>in</strong>g po<strong>in</strong>t) take their price.On the other hand, symbolic algorithms usually require more comput<strong>in</strong>g time and morestorage then numeric ones. But symbolic computation gives the precise results and thereforeeven numerically unstable elementary operations can be performed without any risk of hugeerrors. In addition, computation with symbols is available. The role of symbolic algorithms canbe found <strong>in</strong> help<strong>in</strong>g with development of numerical algorithms and f<strong>in</strong>d out round<strong>in</strong>g errors andnumerical unstability.It is the aim of this work to give a package of functions for symbolic computation withpolynomials and polynomial matrices. The created library is named Polmat and it is distributed5


INTRODUCTION 6freely [1]. A computer algebra system MuPAD [45] was chosen for algorithms implementation.It provides a concept for object oriented programm<strong>in</strong>g, offers an <strong>in</strong>teractive source code debuggerand a powerfull visualization tool. A license of MuPAD versions for a student, a teacher,a lecturer, a representant of an educational <strong>in</strong>stitution or a private person is free. MuPAD isdeveloped ma<strong>in</strong>ly at the <strong>University</strong> of Paderborn <strong>in</strong> Germany s<strong>in</strong>ce 1990. Polmat has beenimplemented and tested <strong>in</strong> MuPAD 2.5.3.In this document, the chapter Polynomial Matrices Computation gives the basic <strong>in</strong>formationabout a computation with polynomials and polynomial matrices. The next chapter expla<strong>in</strong>ssome fundamentals of Computer Algebra Systems. The chapter MuPAD is devoted to Mu-PAD software. A data type polmat and its def<strong>in</strong>ition is described <strong>in</strong> the chapter New Data TypePolmat. The implemented algorithms are described <strong>in</strong> the chapter Algorithms. In the chapterBenchmarks some tests and comparison with some others packages are made. The chapterApplications <strong>in</strong> Control Design gives some examples for us<strong>in</strong>g Polmat <strong>in</strong> the control theory.Responses of UsersStefan Wehmeier, MuPAD developer and researcher at Universität-Gesamthochschule Paderborn,together with Prof. Benno Fuchsste<strong>in</strong>er, head of MuPAD developers, have contacted usand offered cooperation and support.Prof. Mirosław Majewski, Zayed <strong>University</strong>, organizer of MathPAD Conference, has <strong>in</strong>vited usto MathPAD 2005, Toruń, Poland.Ishan Pendharkar from Department of Electrical Eng<strong>in</strong>eer<strong>in</strong>g, Indian Institute of TechnologyBombay, work<strong>in</strong>g <strong>in</strong> behavioral systems theory, uses Polmat for comput<strong>in</strong>g polynomialJ-spectral factorization and matrix diagonalization.Julian Stoev has contacted us and expressed his suggestions.


Chapter 2Polynomial Matrix ComputationThis chapter would like to give a short <strong>in</strong>troduction <strong>in</strong>to polynomial matrix computation. Fordetailed <strong>in</strong>formations you can read e. g. [19, 24, 5, 25, 13, 23, 7, 37, 38].2.1 IntroductionThere are two ma<strong>in</strong> approaches to description of l<strong>in</strong>ear systems signals and control: state-spaceand polynomial description. The former uses four constant matrices and is often written as asystem of differential (recurrence) and algebraic equations. The latter expresses l<strong>in</strong>ear model asa transfer function. S<strong>in</strong>gle Input S<strong>in</strong>gle Output (SISO) system is described by a fraction of twopolynomials, i. e. ratio of Laplace transform of output and Laplace transform of <strong>in</strong>put with zero<strong>in</strong>itial conditions <strong>in</strong> cont<strong>in</strong>uous-time case and ratio of Z-transform of output and Z-transformof <strong>in</strong>put with zero <strong>in</strong>itial conditions <strong>in</strong> discrete-time case. Multi Input Multi Output (MIMO)system is described by a fraction of two polynomial matrices.For <strong>in</strong>stance, a system can be described by state-space methods as⎛ ⎞ ⎛ ⎞x(t + 1) =y(t) = ( 45⎝ 0 − 1 5161350⎠ x(t) + ⎝ 1 ⎠ u(t)0) ( )x(t) + 0 u(t)5where t is discrete time. The same system is described by polynomial methods as transferfunction45Y(d) =d − 7 10 d21 − 6 d + 1 U(d),d25 5where d is complex variable. Obviously, the second method is more elegant than the first one.Polynomials and polynomial matrices arise naturally and have clear physical <strong>in</strong>terpretation.This description is usually obta<strong>in</strong>ed from experimental identification and there is no need to<strong>in</strong>troduce artificial variables called states. Sometimes the concept of state variable is very useful,because it enables us consider th<strong>in</strong>gs that are go<strong>in</strong>g on <strong>in</strong>side the model, but sometimes this isundesirable if we want to focus on <strong>in</strong>put-output behaviour only.7


POLYNOMIAL MATRIX COMPUTATION 8A follow<strong>in</strong>g example shows controller design by polynomial methods.Example 2.1Consider the scheme <strong>in</strong> Fig. 2.1 and the unstable plant P, the controller C which are describedby the follow<strong>in</strong>g transfer functionsP(d) = b(d) 4a(d) = d − 7 5 10 d2y(d)1 − 6 d + 1 , C(d) =d2 x(d) .5 5Figure 2.1: Basic block scheme of closed loopF<strong>in</strong>d the polynomials x(d) and y(d) such that closed-loop system is stable. A stability ofclosed loop depends on a polynomial c(d) given byc(d) = a(d) x(d) + b(d) y(d).Choose any stable polynomial c(d), for <strong>in</strong>stance c(d) = 1, and solve the previous equation forx(d) and y(d)(1 − 6 5 d + 1 ) ( 45 d2 x(d) +5 d − 7 )10 d2 y(d) = 1.This equation has <strong>in</strong>f<strong>in</strong>ite set of solutions, one of them isx(d) = 1 − 23827 dy(d) = 33827 − 6827 dand the controller isC(d) = y(d) 68 d − 338=x(d) 238 d − 27 . ✷Simply, the controller design consists of the solution of a l<strong>in</strong>ear polynomial equationa x + b y = c.For MIMO systems, the process is analogous. L<strong>in</strong>ear equations with polynomial matrices aresolved. These equations may have one of the follow<strong>in</strong>g formsA X + B Y = CA X + Y B = CX A + Y B = C.


POLYNOMIAL MATRIX COMPUTATION 9In optimal control with quadratic control quality criterion a spectral factorization is computed.Then the equationX J X ∗ = B or X X ∗ = Bwhere X ∗ (s) = X T (−s) <strong>in</strong> cont<strong>in</strong>uous-time case, X ∗ (z) = X T (z −1 ) <strong>in</strong> discrete-time case issolved.Very often <strong>in</strong> system analysis of syn<strong>thesis</strong>, we need conversion of a polynomial matrix to oneof several special forms, e.g., Smith form, Smith-McMillan form, Hermite form, row echelonform, etc.Example 2.2Consider the MIMO system [38]G(s) =⎛1⎜s (s + 1) 2 ⎝1 (s + 1) 2 s (s + 1) (s + 2)0 s (s + 2) 00 0 3 s (s + 1) (s + 2)⎞⎟⎠ .Compute its zeros and poles. Smith-McMillan form of G(s) is⎛1⎛⎞0 01 0 0s (s + 1) 21⎜s (s + 1) 2 ⎝ 0 s (s + 2) 0 ⎟⎠ = s + 200⎜(s + 1) 20 0 3 s (s + 1) (s + 2) ⎝3 (s + 2)0 0(s + 1)Poles, zeros are given by⎞.⎟⎠s (s + 1) 2 · (s + 1) 2 · (s + 1) = 0,(s + 2) · 3 (s + 2) = 0,respectively.✷2.2 MethodsFor all these mathematical rout<strong>in</strong>es the special algorithms are designed. They may be based on• elementary operations on polynomial matrix,• Sylvester matrix method,• <strong>in</strong>terpolation.Let us <strong>in</strong>troduce the correspond<strong>in</strong>g def<strong>in</strong>itions.Def<strong>in</strong>ition 2.1 (Elementary operations) [19, 4]Let A(λ) m,n be a polynomial matrix. Elementary row (column) operations for polynomial matrixA(λ) have the form


POLYNOMIAL MATRIX COMPUTATION 10(i) <strong>in</strong>terchange of any two rows (columns),(ii) addition to any row (column) of a polynomial multiple of any other row (column),(iii) scal<strong>in</strong>g any row (column) by any nonzero real or complex number.✷The methods based on elementary operations on polynomial matrix are very efficient. Interest<strong>in</strong>g<strong>in</strong> number of computations, these methods are the most effective of all. Because they arenumerically unstable it is not possible use them <strong>in</strong> numerical algorithms.Sylvester matrix methods are able to compute rather numerically than symbolically. Beforewe make clear what is Sylvester matrix we <strong>in</strong>troduce a follow<strong>in</strong>g def<strong>in</strong>ition.Def<strong>in</strong>ition 2.2 (Band matrix)Suppose a matrixA = (a ij ), i = 1, 2, . . . , m, j = 1, 2, . . . , n.If there exists number p, 0 < p < m<strong>in</strong>(m, n), such that a ij = 0 for all i, j for which |i − j| > p, anA is said to be band matrix. A number p is called width of band.✷Sylvester matrix [8]Suppose a polynomial matrix equationA(s) X(s) = B(s),where A(s) m,n , B(s) m,p are given polynomial matrices and X(s) n,p is variable. The matrices canbe written asThen we can write an equivalent equationA(s) = A 0 + A 1 s + A 2 s 2 + · · · + A ∂A s ∂AB(s) = B 0 + B 1 s + B 2 s 2 + · · · + B ∂B s ∂BX(s) = X 0 + X 1 s + X 2 s 2 + · · · + X ∂X s ∂X .⎛⎞A 0 0A 1 A 0⎛ ⎞ ⎛ ⎞. A 1.. .X 0 B 0X 1B 1A ∂A . A 0=⎜A ∂A A 1⎝ . ⎟ ⎜⎠ ⎝ . ⎟⎠⎜. .. X ∂X B ∂B⎝. ⎟ } {{ } } {{ }⎠̂X̂B0 A ∂A} {{ }Âwhere  is an especial k<strong>in</strong>d of band matrix called Sylvester matrix.✷A last mentioned method is the <strong>in</strong>terpolation. It is not useful for symbolic computation. Forits def<strong>in</strong>ition and algorithm see e. g. [8, 12, 21].


Chapter 3Computer Algebra SystemsA computer algebra system is a type of software package that is used <strong>in</strong> manipulation of mathematicalformulae. The primary aim of a computer algebra system is to solve tedious or difficultalgebraic tasks. The computer algebra systems can be used <strong>in</strong>teractively, the user enters somecommands and the system evaluates them. The pr<strong>in</strong>cipal difference between a computer alebrasystem and a traditional calculator is the ability to deal with equations symbolically ratherthan numerically. In addition, most computer algebra systems can approximate solutions numericallyand user can set the precision to the desired number of digits. The computer algebrasystems often provide a programm<strong>in</strong>g language and tools for visualization and animation ofmathematical data.The beg<strong>in</strong>n<strong>in</strong>g of development of computer algebra systems is jo<strong>in</strong>ted with comm<strong>in</strong>g of programm<strong>in</strong>glanguages as Fortran and Lisp. The first program able to manipulate with symbolicalexpression SAIN (Symbolic Automatic INtegration) came <strong>in</strong> 1961, followed by FORMAC,MATHLAB, REDUCE, SCRATCHPAF, muMATH and others.At present, there are many different computer algebra systems. Some are distributed commercially,others can be obta<strong>in</strong>ed for free. We dist<strong>in</strong>guish special purpose and general purposecomputer algebra systems. Special purpose systems can handle particular problems. For example,GAP, LiE deal with group theory, CASA and GANITH solve algebraic geometry problems,etc. The best-known general purpose systems are MathCAD, Mathematica, Maple, Maxima,MuPAD.In what follows, we say more about Maple, Mathematica, Matlab and Scilab. Even thoughMatlab and Scilab do not belong strictly among CAS product, we consider them here.3.1 Maple and MathematicaMaple [43] and Mathematica [47] are ones of the most used computer algebra systems. Theycomb<strong>in</strong>e symbolic and numerical comput<strong>in</strong>g methods, provide graphical tool and programm<strong>in</strong>glanguage. Maple is distributed by Waterloo Maple, Inc. Mathematica is distributed by WolframResearch, Inc. Mathematica package for polynomial matrix computation has been developed byKujan [22].11


COMPUTER ALGEBRA SYSTEMS 123.2 Matlab and Polynomial ToolboxConcern<strong>in</strong>g technical universities, Matlab is the most widespread product. It enables fast numericalsolvers, so needed <strong>in</strong> eng<strong>in</strong>eer<strong>in</strong>g. Matlab conta<strong>in</strong>s Symbolic Math Toolbox for symbolicalcomput<strong>in</strong>g. Matlab is trademark by The Mathworks, Inc.The Polynomial Toolbox for Matlab [44] is a Matlab toolbox for polynomial matrix computation,developed by PolyX company. It offers e. g. new generation of numerical algorithms,cont<strong>in</strong>uous-time and discrete-time system and signal models based on polynomial matrix fractions,classical and robustness analysis for LTI systems and filters, classical and optimal designtools (pole placement, all stabiliz<strong>in</strong>g controllers, dead-beat, H 2 and LQG), H ∞ optimization,conversion to and from LTI object of the Control System Toolbox. For futher <strong>in</strong>formationssee [44].3.3 ScilabScilab [46] is ma<strong>in</strong>ly numerical package but there exists Scilab-MuPAD l<strong>in</strong>k (see Sec. 4.3),therefore, there is a short <strong>in</strong>formation about this project <strong>in</strong> this section.Scilab is developed s<strong>in</strong>ce 1990 by INRIA and ENPC. It is a scientific software package fornumerical computations. It is distributed freely. Scilab aims at handl<strong>in</strong>g more complex objectsthan numerical matrices. The manipulation rational or polynomial transfer matrices is done bymanipulat<strong>in</strong>g lists and typed lists which allows a natural symbolic representation of complicatedmathematical objects such as transfer functions, l<strong>in</strong>ear systems or graphs.


Chapter 4MuPADThis chapter expla<strong>in</strong>s the basic use MuPAD. For more details see [32, 31, 45].4.1 IntroductionMuPAD is an <strong>in</strong>teractive general purpose computer algebra system <strong>in</strong> an <strong>in</strong>tegrated and openenvironment for symbolic and numeric comput<strong>in</strong>g. It has been developed at the <strong>University</strong> ofPaderborn s<strong>in</strong>ce 1990. MuPAD provides a concept for object oriented programm<strong>in</strong>g, offers an<strong>in</strong>teractive source code debugger and a powerfull visualization tool called VCam. MuPAD kernelis implemented <strong>in</strong> C and C++, the MuPAD libraries are implemented <strong>in</strong> MuPAD’s programm<strong>in</strong>glanguage. A user can write own MuPAD procedures and compile and l<strong>in</strong>k exist<strong>in</strong>g C/C++-codeas Dynamic Modules at runtime. The MuPAD distributions for various operat<strong>in</strong>g systems exist.Figure 4.1: MuPAD13


MUPAD 14A license of some MuPAD versions for a student, a teacher, a lecturer, a representant of aneducational <strong>in</strong>stitution or just a private person who is <strong>in</strong>terested <strong>in</strong> do<strong>in</strong>g mathematics is free,visit [45]. The free MuPAD versions, downloaded from [45], have a built-<strong>in</strong> memory limit of6 megabytes. The registration removes it, see help for register command <strong>in</strong> MuPAD.After start<strong>in</strong>g program, you can enter an <strong>in</strong>struction and wait until MuPAD computes theresult and pr<strong>in</strong>ts it on the screen. For <strong>in</strong>stance, to compute with numbers, you can type 1 + 3/2and press . MuPAD displays>> 1 + 3/25/2Most of MuPAD’s mathematical knowledge is organized <strong>in</strong> libraries. A list of all availablelibraries can be pr<strong>in</strong>ted by call<strong>in</strong>g>> <strong>in</strong>fo()-- Libraries:Ax, Cat, Dom, Network, RGB,Series, Type, adt, comb<strong>in</strong>at, detools,fp, generate, groebner, import, <strong>in</strong>tlib,l<strong>in</strong>alg, l<strong>in</strong>opt, listlib, matchlib, module,numeric, numlib, ode, orthpoly, output,plot, polylib, prog, property, solvelib,specfunc, stats, stdlib, str<strong>in</strong>glib, student,transformYou can get help by call<strong>in</strong>g ?. You can also type>> ?l<strong>in</strong>alg>> ?l<strong>in</strong>alg::stackMatrixand get help for a library l<strong>in</strong>alg, for a function l<strong>in</strong>alg::stackMatrix, respectively, or chooseHelp <strong>in</strong> MuPAD menu.The numbers, symbolic expressions, matrices, arrays, lists, equations, <strong>in</strong>equalities and moreare called MuPAD objects. Every MuPAD object belongs to some data type, called the doma<strong>in</strong>type. The types with capital letters as DOM INT, DOM POLY etc. correspond to doma<strong>in</strong>s providedby the MuPAD kernel. Doma<strong>in</strong>s as Dom::Matrix() were implemented <strong>in</strong> the MuPAD language.For full-range description of MuPAD objects read [32, Chap. 4].By way of example we illustrate work with MuPAD.Example 4.1Student’s exercise is to solve an equationx + 27 x + 23 = x − 27 (x + 1) .


MUPAD 15But student see badly and copies it with mistaken second term <strong>in</strong> the numerator on left-handside and with m<strong>in</strong>us <strong>in</strong> the denom<strong>in</strong>ator on right-hand side. He solves this bad equation correctlyand obta<strong>in</strong>s right solution of given one. The question is what equation did he solve.In MuPAD solve this tasks by follow<strong>in</strong>g.>> solve((x+2)/(7*x+23)=(x-2)/(7*(x+1)), x){-5}>> solve((x+a)/(7*x+23)=(x-2)/(7*(x-1)), x)/ { 7 a - 46 } \piecewise| { -------- } if a 16/7, {} if a = 16/7 |\ { 7 a - 16 } />> solve((7*a-46)/(7*a-16)=-5, a){3}A student solved the equationx + 37 x + 23 = x − 27 (x − 1) . ✷Example 4.2Solve a l<strong>in</strong>ear optimization problem⎧⎪⎨max 2 x − 3 y⎪⎩∣x + 2 y ≥ 6y − x ≤ 3x + y ≤ 10⎫⎪⎬, x, y ≥ 0 .⎪⎭Get a numeric solution via l<strong>in</strong>opt::maximize at first.>> l<strong>in</strong>opt::maximize([{x+2*y>=6, y-x k:=[[x+2*y>=6, y-x g:=l<strong>in</strong>opt::plot_data(k, [x, y]):>> plot2d(g)After perform<strong>in</strong>g a last command, MuPAD opens a w<strong>in</strong>dow <strong>in</strong> Fig. 4.2.✷


MUPAD 16Figure 4.2: Graphic method for solv<strong>in</strong>g a l<strong>in</strong>ear optimalization problem4.2 MuPAD PackagesMuPAD provides a programm<strong>in</strong>g language <strong>in</strong> which the user can implement complex algorithms.The procedures can be def<strong>in</strong>ed via proc-end proc and can be jo<strong>in</strong>ed to packages [32].All functions, conta<strong>in</strong>ed <strong>in</strong> a package, are avaible after call<strong>in</strong>g commandpackage("$PATH")where $PATH denotes package directory path. In L<strong>in</strong>ux, place packages to directory~/.mupad/packagesfor easy load<strong>in</strong>g.Example 4.3You can load a Polmat library by, for example,>> package("polmat")"Library Polmat successfully loaded."✷


MUPAD 174.3 MuPAD-Scilab L<strong>in</strong>kThe MuPAD-Scilab l<strong>in</strong>k [29] is the l<strong>in</strong>k between MuPAD and the numerical Scilab package [46].Us<strong>in</strong>g this l<strong>in</strong>k, data can be exchanged between MuPAD and Scilab and some Scilab commandscan be executed from <strong>in</strong>side a MuPAD session.You can perform numerical comput<strong>in</strong>g by Scilab <strong>in</strong> MuPAD, as <strong>in</strong> follow<strong>in</strong>g example.Example 4.4>> scilab::start()>> scilab::sqrt(2)TRUE1.414213562✷


Chapter 5New Data Type PolmatThe Polmat library uses MuPAD doma<strong>in</strong>s and data types for def<strong>in</strong>ition its objects and comb<strong>in</strong>esthem. Polmat works with four r<strong>in</strong>gs, with polynomials, polynomial matrices, rational functionsand rational matrices. You can def<strong>in</strong>e a new object by function polmat::new, or shortly polmat.The function chooses object data type accord<strong>in</strong>g to <strong>in</strong>put data.The doma<strong>in</strong>s DOM_POLY is used for def<strong>in</strong>ition of a polynomial. It is a special data type whichis implemented with some kernel functions and makes computation with polynomials moreefficient. The analogous data type for polynomial matrices is miss<strong>in</strong>g. Therefore, a polynomialmatrix is an element of doma<strong>in</strong> typeDom::Matrix(Dom::DistributedPolynomial([x],Dom::ExpressionField(normal, iszero@normal), LexOrder))where x denotes an <strong>in</strong>determ<strong>in</strong>ate. For better manipulation with polynomial matrices, commandpolmat::poly:=Dom::DistributedPolynomial is performed.For comput<strong>in</strong>g with the polynomials <strong>in</strong> control theory, we often need use the polynomialswith negative exponents, for example a(z) = 2 z + 1 + 2 z −1 . Such polynomials are def<strong>in</strong>ed asDOM_EXPR and a matrix of such polynomials is object of doma<strong>in</strong> Dom::Matrix().Our approach has only one trouble. There is not compability of scalar polynomial with 1 by1 polynomial matrix or a term of a polynomial matrix, because any matrix doma<strong>in</strong> type is notcompatible with type DOM_POLY <strong>in</strong> MuPAD.The description of a command polmat follows.5.1 Def<strong>in</strong>ition of a New ObjectAs it was said, polmat::new def<strong>in</strong>es a new object – a polynomial, a polynomial matrix, a rationalfunction or a rational matrix.Call(s)a:=polmat(p)A:=polmat(m, x)18


NEW DATA TYPE POLMAT 19Parameters and Optionsp – a polynomial or an expressionm – an element of a doma<strong>in</strong> DOM LIST, see the Sec. 5.2x – an <strong>in</strong>determ<strong>in</strong>ateReturn Valuesa – an element of a doma<strong>in</strong> DOM EXPR, DOM POLY, DOM INT, . . .A – an element of a doma<strong>in</strong> Dom::Matrix(polmat::poly) or Dom::Matrix()5.2 ExamplesThe creation of new objects is best seen via a simple examples.Example 5.1Create a polynomial and the polynomial matrices⎛⎞⎛a(x) = 10 c x 2 + x, A(d) = ⎝ d 1 − d ⎠ , B(x) = ⎝ x + x−1 1 + x −25 d 2 d 2 5 x + 1 2⎞⎠ .>> a:=polmat(x+10*c*x^2, x)2poly((10 c) x + x, [x])>> A:=polmat([[d, -d+1],[5*d^2, d^2]], d)+- -+| d, - d + 1 || || 2 2 || 5 d , d |+- -+>> B:=polmat([[x+x^-1, x^-2],[5*x+1, 2]], x)+- -+| 1 1 || x + -, -- || x 2 || x || || 5 x + 1, 2 |+- -+✷


NEW DATA TYPE POLMAT 20Example 5.2It is available to def<strong>in</strong>e a number as constant or as polynomial.>> a:=polmat(3)>> domtype(%)>> a:=polmat(3, x)>> domtype(%)3DOM_INTpoly(3, [x])DOM_POLY✷Example 5.3In control theory, the discrete-time systems are described by polynomials <strong>in</strong> z or <strong>in</strong> z −1 = d. Inthe second case, you can resolve if an <strong>in</strong>determ<strong>in</strong>ate will be z or d.>> c:=polmat(1/z + 3/z^2)>> c:=polmat(1/z + 3/z^2, 1/z)1 3- + --z 2z2poly(3 d+ d, [d])✷


Chapter 6AlgorithmsThis chapter serves the algorithms description. We mention the algorithms for a greatest commondivisor, an adjo<strong>in</strong>t of a matrix, the equations solvers, a spectral factorization, the matrixdecompositions and reductions, a rank of a matrix, the Routh table, the Schmidt pairs, theNehari problem, a division of the polynomials and a m<strong>in</strong>imal realization. You can read more <strong>in</strong>formations,some examples and the description of all algorithms implemented <strong>in</strong> Polmat <strong>in</strong> [2].6.1 Greatest Common DivisorFor the polynomial computation, greatest common divisor (GCD) of polynomials is one of themost important algorithms. In Polmat, it is computed by function polmat::gcd.Call(s)[d, p, q, r, s] := polmat::gcd(a, b, x)[D, P, Q, R, S] := polmat::gcd(A, B, x)[D, P, Q, R, S] := polmat::gcd(A, B, x)Parameters and Optionsa, b – the polynomials of doma<strong>in</strong> DOM_POLYA, B – the matrices of a type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn Valuesd, p, q, r, s – the polynomials of doma<strong>in</strong> DOM_POLYD – a matrix of a type Dom::Matrix(polmat::poly)P, Q, R, S – the matrices of a type Dom::Matrix()21


ALGORITHMS 22DetailsScalar version of the algorithm solves a system of equationsa p − b q = da r − b s = 0,where a, b are given polynomials, p, q, r, s, d are variables and d is GCD. Computation method isbased on Euclidean algorithm.Algorithm for polynomial matrices f<strong>in</strong>ds left, right GCD of the polynomial matrices, solves asystem of equationsA P + B Q = DA R + B S = 0,P A + Q B = DR A + S B = 0,respectively, where A, B are given polynomial matrices, P, Q, R, S are variables and D is GCD.These algorithms are based on elementary operations on polynomial matrix. For full descriptionthe both GCD algorithms see [23].6.2 Adjo<strong>in</strong>t, Inverse, Determ<strong>in</strong>ant and RankAlgorithms for computation of adjo<strong>in</strong>t, <strong>in</strong>verse, determ<strong>in</strong>ant and rank of a polynomial matrixare conta<strong>in</strong>ed <strong>in</strong> this section.6.2.1 Adjo<strong>in</strong>t of a Matrix and Determ<strong>in</strong>antAdjo<strong>in</strong>t of a matrix adj A and the determ<strong>in</strong>ant det A of a matrix A are computed by functionpolmat::adj.Call(s)[adj, det] := polmat::adj(A, x)Parameters and OptionsA – an element of a doma<strong>in</strong> Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn Valuesadj – an element of a doma<strong>in</strong> Dom::Matrix(polmat::poly)det – an element of a doma<strong>in</strong> polmat::poly


ALGORITHMS 23DetailsAlgorithm is based on elementary operations on polynomial matrix. For its full descriptionread [23].Also function polmat::det for comput<strong>in</strong>g matrix determ<strong>in</strong>ant is available, see [2].6.2.2 Inverse of a MatrixInverse of a matrix is returned by function polmat::<strong>in</strong>verse.Call(s)B := polmat::<strong>in</strong>verse(A, x)Parameters and OptionsA – an element of a doma<strong>in</strong> Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesB – an element of a doma<strong>in</strong> Dom::Matrix(polmat::poly)DetailsInverse A −1 for a matrix A is computed by us<strong>in</strong>g adjo<strong>in</strong>t and determ<strong>in</strong>ant of a matrix byA −1 = adj Adet A .6.2.3 Rank of a Polynomial MatrixRank is computed by function polmat::rank.Call(s)r := polmat::rank(A, x)r := polmat::rank(A, x)Parameters and OptionsA – a matrix of a doma<strong>in</strong> Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>atehorn – Horner scheme method is usedsylv – Sylvester matrix algorithm used


ALGORITHMS 24Return Valuesr – a nonnegative <strong>in</strong>teger numberDetailsThere are two methods for comput<strong>in</strong>g rank of a polynomial matrix [8, 4]. The first one usesmatrix evaluation by Horner scheme [49, 4], the second one is Sylvester matrix algorithm [8].Mentioned methods are performed by the macros polmat::value and polmat::gensylv [2].Optional parameter (horn/sylv) determ<strong>in</strong>es what method will be used. The default is Hornerscheme method.6.3 Solution of L<strong>in</strong>ear Equations with Polynomials,Polynomial MatricesSolvers equations with polynomials and polynomial matrices are described <strong>in</strong> this section.6.3.1 AXBYC EquationSolution of l<strong>in</strong>ear equation with polynomials, polynomial matricesa x + b y = c, (6.1)A X + B Y = C, (6.2)respectively, where a, b, c are given polynomials, A, B, C are given polynomial matrices and x, y,X, Y are variables is returned by polmat::axbyc.Call(s)[X,Y] := polmat::axbyc(a, b, c, x)[X,Y] := polmat::axbyc(a, b, c, x)[X,Y] := polmat::axbyc(a, b, c, x)[X,Y] := polmat::axbyc(A, B, C, x)Parameters and Optionsa, b, c – the polynomialsA, B, C – the polynomial matrices of type polmat::matrixx – an <strong>in</strong>determ<strong>in</strong>ate


ALGORITHMS 25Return ValuesX, Y – an element of a doma<strong>in</strong> DOM POLY or Dom::Matrix(polmat::poly)DetailsGeneral solution of (6.1) isx = p c d + r ty = q c d + s t,where polynomials d, p, q, r, s are solution of GCD algorithm and t is an arbitrary one.General solution (6.2) isX = P 2 C 2 + R 2 TY = Q 2 C 2 + S 2 T,where T is an arbitrary matrix andC = D 2 C 2 ,A P 2 + B Q 2 = D 2A R 2 + B S 2 = 0.(6.3)If the parameter "x-m<strong>in</strong>imal" is given, the equation is solved for x-m<strong>in</strong>imal solution x 1 ,y 1 . If the parameter "y-m<strong>in</strong>imal" is given, the equation is solved for y-m<strong>in</strong>imal solution x 2 , y 2 .These algorithms are described <strong>in</strong> [14].If the parameter "degy


ALGORITHMS 26Parameters and Optionsa, b, c – the polynomialsA, B, C – the polynomial matrices of type polmat::matrixx – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesX, Y – the elements of a doma<strong>in</strong> DOM POLY or Dom::Matrix(polmat::poly)6.3.3 XAYBC EquationSolution of l<strong>in</strong>ear equations of polynomials or polynomial matricesx a + y b = c,X A + Y B = C, (6.4)respectively, where a, b, c are given polynomials, A, B, C are given polynomial matrices and x, y,X, Y are variables is returned by polmat::xabyc.Call(s)[X, Y] := polmat::xabyc(a, b, c, x)[X, Y] := polmat::xabyc(A, B, C, x)Parameters and Optionsa, b, c – the polynomialsA, B, C – the polynomial matrices of type polmat::matrixx – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesX, Y – the elements of a doma<strong>in</strong> DOM POLY or Dom::Matrix(polmat::poly)DetailsGeneral solution of (6.4) isX = C 1 P 1 + T R 1Y = C 1 Q 1 + T S 1 ,(6.5)where T is an arbitrary matrix andC = C 1 D 1 ,P 1 A + Q 1 B = D 1R 1 A + S 1 B = 0.


ALGORITHMS 276.3.4 AXBYCD EquationSolution of l<strong>in</strong>ear equations of polynomialsa ¯x + ¯b y = c + ¯d,where a, b, c, d are given polynomials and x, y are variables is returned by polmat::axbycd.Call(s)[X, Y] := polmat::axbycd(a, b, c, d c, x)[X, Y] := polmat::axbycd(a, b, c, d c, x)Parameters and Optionsa, b, c – the polynomials, the expressions or the numbersd c – an expressionx – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesX, Y – the elements of a doma<strong>in</strong> DOM POLYDetailsIf the parameter "x-m<strong>in</strong>imal" is given, the equation is solved for x-m<strong>in</strong>imal solution. Thisparameter is default. If the parameter "y-m<strong>in</strong>imal" is given, the equation is solved for y--m<strong>in</strong>imal solution. The algorithm is described <strong>in</strong> [16].6.3.5 AXXAB EquationSolution of symmetric l<strong>in</strong>ear equations of polynomialsā x + a ¯x = b,where a is given polynomial, b is given two-sided one and x is variable is returned by functionpolmat::axxab.Call(s)X := polmat::axxab(a, b, x)Parameters and Optionsa, b – the polynomialsx – an <strong>in</strong>determ<strong>in</strong>ate


ALGORITHMS 28Return ValuesX – an element of a doma<strong>in</strong> DOM POLY6.4 Spectral FactorizationIn various optimal control techniques, spectral factorization is a crucial computational step.Algorithm for polynomial spectral factorization and algorithm for polynomial matrix J-spectralfactorization is performed by function polmat::spf.Call(s)[X, n, eps] := polmat::spf(p, x)[P, J] := polmat::spf(Z, x)Parameters and Optionsp – the polynomials of doma<strong>in</strong> DOM_POLYZ – a polynomial matrix of type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesX – a polynomial of doma<strong>in</strong> DOM_POLYn – an <strong>in</strong>teger numbereps – a real numberP, J – the polynomial matrices of type Dom::Matrix(polmat::poly)DetailsPolynomial spectral factorization problem means to f<strong>in</strong>d a polynomial x satisfy<strong>in</strong>gx ¯x = b,where b is given polynomial and ¯x(s) = x(−s) <strong>in</strong> cont<strong>in</strong>ue-time case, ¯x(d) = x(d −1 ) <strong>in</strong> discretetimecase. The implemented algorithm for polynomial spectral factorization is based on aNewton-Raphson iterative scheme and on the macro polmat::axxab. For details see [40, 41].The Newton-Raphson method is stopped when norm(x i − x i−1 ) is less then a value ofpolmat::spf::tol or a number of iteration is a value of polmat::spf::noi. The defaultvalue of polmat::spf::tol is 10 −8 . The default value of polmat::spf::noi is 30.The scalar version of function polmat::spf returns a polynomial x, number of performediterations n and precision ε.


ALGORITHMS 29Polynomial matrix version of spectral factorization algorithm is based on a diagonalization[13, 26]. For <strong>in</strong>put polynomial matrix Z the matrices P and J are computed thatZ = ¯P J P,where ¯P(s) = P T (−s) and the constant matrix J has a form⎛⎜⎝I 1 0 00 −I 2 00 0 0⎞⎟⎠ .The algorithm for discrete-time case is not available.6.5 Matrix Reductions and DecompositionsThis chapter refers to some matrix decompositions and the reductions to some forms. Algorithmsfor comput<strong>in</strong>g Hermite form, Smith form, Popov form, a reduction by a right and a leftdivisor and others are presented.6.5.1 Smith FormAn <strong>in</strong>put matrix is reduced by elementary column and row operations to Smith form [23, 19] byfunction polmat::smithForm. The algorithm computes matrices P and Q so thatP A Q = diag l, m [a 1 , a 2 , . . . , a r , 0, . . . , 0] ,where A l, m is a given matrix. For more details see [23].Call(s)[P, B, Q, r] := polmat::smithForm(A, x)Parameters and OptionsA – a matrix of a type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesP, B, Q – the matrices of a doma<strong>in</strong> Dom::Matrix (B= P A Q),r – an <strong>in</strong>teger number


ALGORITHMS 306.5.2 Hermite FormMatrix reduction to Hermite form [19] is performed by function polmat::hermiteForm. Itcomputes matrices P, Q so that P A, A Q is row, column Hermite form, respectively, whereA is given matrix. The comput<strong>in</strong>g method is based on elementary operations on polynomialmatrix. If the parameter col is given column Hermite form is computed else row Hermite form iscomputed.Call(s)[X, T] := polmat::hermiteForm(A, x)[X, T] := polmat::hermiteForm(A, x)Parameters and OptionsA – a matrix of a type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesX, T – the matrices of a doma<strong>in</strong> Dom::Matrix, Hermite form and a transformation matrix6.5.3 Popov FormMatrix reduction to Popov form [19, 30] is computed by function polmat::popovForm. Fordef<strong>in</strong>ition Popov form and algorithm see [19]. If the parameter col is given column Popov formis computed else row Popov form is computed. An <strong>in</strong>put matrix must be column, row reduced,respectively.Call(s)X := polmat::popovForm(A, x)X := polmat::popovForm(A, x)Parameters and OptionsA – a matrix of a type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesX – a matrix of a doma<strong>in</strong> Dom::Matrix


ALGORITHMS 316.5.4 Right and Left DecompositionRight or left matrix decompositionS = B 1 A −12 , S = A −11 B 2 ,respectively, is returned by function polmat::decomp. An <strong>in</strong>put matrix S must be given asS = B awhere B is l by m matrix and a is polynomial.For right, left decomposition, the algorithm computes left GCD of A l and B, right GCD of A mand B, respectively, where A l = a I l , A m = a I m . For full-range description see [23].Call(s)[A2, B1] := polmat::decomp(B, a, x)[A1, B2] := polmat::decomp(B, a, x)Parameters and OptionsB – a matrix of a type Dom::Matrix(polmat::poly)p – a polynomial of a doma<strong>in</strong> DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesA1, B1, A2, B2 – the matrices of a doma<strong>in</strong> Dom::Matrix6.5.5 Matrix Reduction TestFunction polmat::isreduced tests whether a matrix is column or row reduced.Call(s)polmat::isreduced(m, x)polmat::isreduced(m, x)Parameters and Optionsm – a matrix of a type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ate"col" – a column reduction test, default"row" – a row reduction test


ALGORITHMS 32Return Valuesa value of a doma<strong>in</strong> DOM_BOOL6.5.6 Reduction by a Right and a Left DivisorReduction by right or left divisor is made by function polmat::reduce. The algorithm computesmatrix C 1 , C 2 so thatC = C 1 D 1 , C = D 2 C 2 ,where D 1 , D 2 is right, left divisor of given matrix C, respectively. Presumption is that divisors arecomputed by function polmat::gcd and they are <strong>in</strong> triangular form. This algorithm is described<strong>in</strong> [23].Call(s)C1 := polmat::reduce(C, D1, x)C2 := polmat::reduce(C, D2, x)Parameters and OptionsC, D1, D2 – a matrix of a type Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ate"right" – a reduction by right divisor, default"left" – a reduction by left divisorReturn ValuesC1, C2 – a matrix of a type Dom::Matrix(polmat::poly)6.5.7 Column and Row ReductionFunction polmat::reduce returns column, row reduced matrix for an <strong>in</strong>put matrix A. Algorithmcomputes matrix A r , A c , and unimodular matrix U, V thatA r = U A, A c = A V,respectively. The method is based on elementary operations on polynomial matrix. The defaultmethod is row reduction.Call(s)[Ar, U] := polmat::reduce(A, x,)[Ac, V] := polmat::reduce(A, x,)


ALGORITHMS 33Parameters and OptionsA – a matrix of a doma<strong>in</strong> Dom::Matrix(polmat::poly)x – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesAr, Ac, U, V – the matrices of a doma<strong>in</strong> Dom::Matrix(polmat::poly)6.6 Routh Table and Its Offer <strong>in</strong> Addition to StabilityThis chapter deals with the algorithms derived from [35]. There is shown that Routh table [35,38] can be used to construct an orthonormal basis <strong>in</strong> the space of strictly proper rational functionwith a common stable denom<strong>in</strong>ator and so can be used to compute the H 2 norm, the Hankelapproximation and the Nehari problems.In follow<strong>in</strong>g, consider a strictly proper stable signal or systemG(s) = b(s)a(s) . (6.6)6.6.1 Routh and Augmented Routh TableRouth table is constructed by function polmat::routh. Augmented Routh table [35] is constructedby function polmat::augRouth.Call(s)R := polmat::Routh(a, x)[R, Q1, Q2] := polmat::augRouth(b, a, x)Parameters and Optionsa, b – the polynomials of a type DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesR, Q1, Q2 – the matrices of a doma<strong>in</strong> Dom::Matrix()6.6.2 H 2 NormH 2 norm of (6.6) is computed by function polmat::h2norm.


ALGORITHMS 34Call(s)h := polmat::h2norm(b, a, x)Parameters and Optionsa, b – the polynomials of a type DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ateReturn Valuesh – a number or an expression6.6.3 Schmidt PairsFunction polmat::schmidtPair computes Schmidt pairs for (6.6).Call(s)schp := polmat::schmidtPair(b, a, x)Parameters and Optionsa, b – the polynomials of a type DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ateReturn Valuesschp – a table of arrays of an expression6.6.4 Nehari ProblemFunction polmat::nehari f<strong>in</strong>ds Q(s) ∈ H ∞ to m<strong>in</strong>imize ‖G(−s) − Q(s)‖ ∞.Call(s)F := polmat::nehari(b, a, x)Parameters and Optionsa, b – the polynomials of a type DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ate


ALGORITHMS 35Return ValuesF – an expression6.7 Division of PolynomialsFunctions for comput<strong>in</strong>g division of polynomials are conta<strong>in</strong>ed <strong>in</strong> this section. The first functionreturns a quotient and a rem<strong>in</strong>der, the second one computes a long division. Both functions aredescribed <strong>in</strong> [23].6.7.1 Division of Two PolynomialsFunction polmat::divide divides polynomials a and b and returns a quotient q and a rem<strong>in</strong>derr. We can writeq = a b − r b .Call(s)[q, r] := polmat::divide(a, b, x)Parameters and Optionsa, b – the polynomials of a doma<strong>in</strong> DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ateReturn Valuesq, r – the polynomials of a doma<strong>in</strong> DOM_POLY6.7.2 Long DivisionFunction polmat::longdivide makes expansion of a transfer function to series. The transferfunction may be given as two polynomials a and b or as expression c. The first k members ofseries are computed.Call(s)q := polmat::longdivide(a, b, x, k)q := polmat::longdivide(c, x, k)


ALGORITHMS 36Parameters and Optionsa, b – the polynomials of a doma<strong>in</strong> DOM_POLYc – an expressionx – an <strong>in</strong>determ<strong>in</strong>atek – a nonnegative <strong>in</strong>teger numberReturn Valuesq – a polynomial of a doma<strong>in</strong> DOM_POLY6.8 M<strong>in</strong>imal RealizationThe last algorithm described <strong>in</strong> this paper deals with a state-space realization. Consider systemdef<strong>in</strong>ed byS = B a . (6.7)Function polmat::m<strong>in</strong>real computes four constant matrices, which are a m<strong>in</strong>imal realizationof S. This algorithm is based on [23].Call(s)[F, G, H, J] := polmat::m<strong>in</strong>real(B, a, x)Parameters and OptionsB – a matrix of a doma<strong>in</strong> Dom::Matrix(polmat::poly)a – the polynomials of a doma<strong>in</strong> DOM_POLYx – an <strong>in</strong>determ<strong>in</strong>ateReturn ValuesF, G, H, J – the matrices of a doma<strong>in</strong> Dom::Matrix


Chapter 7BenchmarksWe compare the Polmat library with a MuPAD library l<strong>in</strong>alg and some polynomial matricescomputation oriented packages. We are <strong>in</strong>terested <strong>in</strong> the comput<strong>in</strong>g time. Polmat performs asymbolic computation, while, for <strong>in</strong>stance, the Polynomial Toolbox for Matlab is a numericalpackage. We presume the numeric packages as Polynomial Toolbox or Scilab are faster thenPolmat.Let us verify our idea by three experimental tests. The first one shows a comput<strong>in</strong>g timeof solution l<strong>in</strong>ear equation with polynomial matrices with us<strong>in</strong>g of Polmat and the PolynomialToolbox, the second one deals with computation of a matrix determ<strong>in</strong>ant and compares a comput<strong>in</strong>gtime of four methods and, f<strong>in</strong>ally, third one shows comput<strong>in</strong>g times of reduction matrixto Smith form by Polmat, l<strong>in</strong>alg and the Polynomial Toolbox.The random matrices, used <strong>in</strong> the test<strong>in</strong>g, are generated by polmat::rand <strong>in</strong> MuPADand prand <strong>in</strong> Matlab. In MuPAD the comput<strong>in</strong>g time is measured by a function time, <strong>in</strong>Matlab by cputime and <strong>in</strong> Scilab by timer. These functions measure the CPU time that wasspent by the current process. Tables bellow conta<strong>in</strong> comput<strong>in</strong>g times <strong>in</strong> the same format asmentioned commands return them (<strong>in</strong>troduced times may be rounded). Tests are performedunder operat<strong>in</strong>g system L<strong>in</strong>ux with kernel 2.4.25 <strong>in</strong> MuPAD 2.5.3, <strong>in</strong> Matlab 6.0.0.88 (R12)with the Polynomial Toolbox 3.0.19 and <strong>in</strong> Scilab 3.0. Note that tests were runn<strong>in</strong>g with variableDIGITS equal 40 <strong>in</strong> MuPAD.7.1 Equation SolversAs it was said, we solve an equation A X + B Y = C with us<strong>in</strong>g macros• polmat::axbyc <strong>in</strong> MuPAD and• axbyc <strong>in</strong> Matlab<strong>in</strong> the first test. First, we found general solution equation with polynomial matrices (Tab. 7.1),futher, we take a solution equation with polynomials with a m<strong>in</strong>imal degree of Y (Tab. 7.2).37


BENCHMARKS 38polynomial degree 1 5 10 1 2 3 3matrix dimension 1 1 1 2 3 3 5Polmat 29 122 482 120 844 2056 19 630Polynomial Toolbox 41 44 47 40 46 47 56Table 7.1: Benchmark – the comput<strong>in</strong>g times <strong>in</strong> milliseconds: Solver for equation A X+B Y = C,general solutionpolynomial degree 3 5 10 25Polmat 49 83 224 1675Polynomial Toolbox 86 91 98 128Table 7.2: Benchmark – the comput<strong>in</strong>g times <strong>in</strong> milliseconds: Solver for equation A X+B Y = C,general solution7.2 Matrix Determ<strong>in</strong>antThe second test compares five algorithms for a matrix determ<strong>in</strong>ant, two symbolic methods andthree numeric ones, performed by• l<strong>in</strong>alg::det <strong>in</strong> MuPAD,• polmat::det <strong>in</strong> MuPAD,• polmat::det <strong>in</strong> MuPAD,• <strong>in</strong>v <strong>in</strong> the Polynomial Toolbox <strong>in</strong> Matlab and• <strong>in</strong>vr <strong>in</strong> Scilab.The results are conta<strong>in</strong>ed <strong>in</strong> Tab. 7.3.polynomial degree 1 3 3 5 5 10matrix dimension 2 3 5 5 10 10MuPAD, l<strong>in</strong>alg 2 23 292 656 19 620 ∗Polmat, symbolic 26 286 10 448 ∗ ∗ ∗Polmat, numeric 11 42 92 173 1114 2590Polynomial Toolbox 2 2 3 4 4 9Scilab 0 2 0 2 4 8Table 7.3: Benchmark – the comput<strong>in</strong>g times <strong>in</strong> milliseconds: Determ<strong>in</strong>ant of a polynomialmatrix n by n of degree d


BENCHMARKS 397.3 Smith FormReduction polynomial matrix to Smith form is tested. Three algorithms,• l<strong>in</strong>alg::smithForm <strong>in</strong> MuPAD,• polmat::smithForm <strong>in</strong> Polmat,• smith <strong>in</strong> the Polynomial Toolbox <strong>in</strong> Matlab,are compared. The comput<strong>in</strong>g times are shown <strong>in</strong> Tab. 7.4.polynomial degree 1 3 4 6 2 3matrix dimension 2 3 3 3 4 4l<strong>in</strong>alg 23 257 502 2590 3614 68310Polmat 91 910 1554 5100 1198 2944Polynomial Toolbox 210 785 1040 1465 950 1380Table 7.4: Benchmark – the comput<strong>in</strong>g times <strong>in</strong> milliseconds: Reduction polynomial matrix toSmith form


Chapter 8Applications <strong>in</strong> Control DesignWe <strong>in</strong>troduce some basic control problems and their solution by polynomial methods with us<strong>in</strong>gPolmat <strong>in</strong> this chapter.8.1 Cruise Control SystemIn the first example, consider a simple model of a car [48] of Fig. 8.1a. Neglect<strong>in</strong>g the <strong>in</strong>ertia ofthe wheels and suppos<strong>in</strong>g that friction is what is oppos<strong>in</strong>g the motion of the car, the system canbe described bym ˙v + k v = u,where u is the force from the eng<strong>in</strong>e, v is the velocity and k is the friction coefficient. Let u be<strong>in</strong>put and v output. The correspond<strong>in</strong>g transfer function isP(s) =1m s + k . (8.1)In what follows, assume m > 0 and k > 0 and consider the scheme of Fig. 8.1b.(a)(b)Figure 8.1: Cruise control system (a), Feedback control system (b)40


APPLICATIONS IN CONTROL DESIGN 418.1.1 Stabiliz<strong>in</strong>g ControllersWe shall compute a parametrization of all controllers that <strong>in</strong>ternally stabilize the plant (8.1). Setof all such controllers is given byC = Y − A WX + B W ,where X and Y are two proper and stable rational functions satisfy<strong>in</strong>g the Bézout equationA X + B Y = 1and W is a parameter rang<strong>in</strong>g over the set of proper and stable rational functions such thatX + BW ≠ 0. For more details and proof read, e. g., [13, 25].Obta<strong>in</strong> a stable fractional representation of the plant (8.1) as follows. Choose a factor (s−1),and solve the equationBy substitutionB(s)A(s) = 1m s + k ,s = 1 − ww ,transform (8.2) to the polynomial equationand solve it by Polmat1 assume(m>0): assume(k>0):2 A:=(m*s+k)/(s+1):3 B:=1/(s+1):A(s) = m s + ks + 1 , B(s) = 1s + 1m s + ks + 1 X(s) + 1 Y(s) = 1. (8.2)s + 1(m + (k − m) w) x(w) + w y(w) = 1 (8.3)4 a:=polmat(normal(subs(A, s=(1-w)/w)), w):5 b:=polmat(normal(subs(B, s=(1-w)/w)), w):6 c:=polmat(1, w):7 t:=0:8 [x,y]:=polmat::axbyc(a, b, c, w):By assum<strong>in</strong>g t = 0 on l<strong>in</strong>e 7, get a particular solution of (8.3). Now, perform backsubstitution<strong>in</strong>to x(w) and y(w) and obta<strong>in</strong> solution of (8.2)9 X:=subs(expr(x), w=1/s+1):10 Y:=subs(expr(y), w=1/s+1):w = 1s + 1


APPLICATIONS IN CONTROL DESIGN 42The formula for all controllers that <strong>in</strong>ternally stabilize the plant (8.1) readsForthe set of controllers isC(s) =m − km− m s + ks + 1 W(s)1m + 1 . (8.4)s + 1 W(s)m = 1000 kg, k = 50 N s m −1 , (8.5)C(s) =19 1000 s + 50− W(s)20 s + 111000 + 1 .s + 1 W(s)8.1.2 PI ControllersWe computed the set of all controllers that <strong>in</strong>ternally stabilize the plant (8.1) <strong>in</strong> previous subsection.We shall now select all PI controllers conta<strong>in</strong>ed <strong>in</strong> the set (8.4).PI controller has a formC PI (s) = k P s + k I.sSolve the equationC(s) = C PI (s)for W(s)11 C:=(Y-A*W)/(X+B*W):12 Cpi:=(kP*s+kI)/s:13 solve(C=Cpi, W):PI controllers corespond to the parameterWith the parameters (8.5) W(s) isW(s) = (m − k − k P) s 2 + (m − k − k I − k P ) s − k Im 2 s 2 + m (k I + k P ) s + m k I.W(s) =(950 − k P ) s 2 + (950 − k I − k P ) s + −k I1000000 s 2 + (1000 k P + 50000) s + 1000 k I.8.1.3 Asymptotic PropertiesFor the system (8.1) f<strong>in</strong>d a controller so that1. the feedback system is <strong>in</strong>ternally stable,


APPLICATIONS IN CONTROL DESIGN 432. the f<strong>in</strong>al value of y equals 1 when r is a unit step and d = 0,3. the f<strong>in</strong>al value of y equals zero when d is a s<strong>in</strong>usoid of 1 rad s −1 and r = 0.First, determ<strong>in</strong>e the set of all <strong>in</strong>ternally stabiliz<strong>in</strong>g controllers. It was done by (8.4). The secondstep is to compute the <strong>in</strong>put-to-output transfer function and disturbance-to-output transferfunction, these readT(s) = B(s) (Y(s) − A(s) W(s)) ,respectively. The po<strong>in</strong>t (2) holds if [5]and the po<strong>in</strong>t (3) holds ifH(s) = B(s) (X(s) + B(s) W(s)) ,B(0) (Y(0) − A(0) W(0)) = 1B(j) (X(j) + B(j) W(j)) = 0.The problem is reduced to solv<strong>in</strong>g follow<strong>in</strong>g three algebraic equationsW(0) = − 1 mR{W(j)} = − 1 m(8.6)I{W(j)} = − 1 m .Let W be a polynomial <strong>in</strong> (s + 1) −1 with enough variable coefficients, soW(s) = x 1 + 1s + 1 x 12 +(s + 1) x 3.2The equations (8.6) can be written as one F x = b where⎛F =⎜⎝∣11 ∣∣s=0 ⎞1 ∣s+1 s=0 (s+1) 21 R { }∣1 ∣∣s=jR { }∣ 1 ∣∣s=js+1(s+1) 20 I { }∣1 ∣∣s=jI { ⎟ ,}∣ ⎠1 ∣∣s=js+1(s+1) 2In MuPAD, type follow<strong>in</strong>g⎛x = ⎜⎝⎞x 1x ⎟ 2 ⎠ ,x 3⎛b = ⎜⎝W(0)R{W(j)}I{W(j)}⎞⎟⎠14 v:=matrix([[1, 1/(s+1), 1/(s+1)^2]]):15 F:=matrix::stackMatrix(subs(v, s=0),map(subs(v, s=I), Re), map(subs(v, s=I),Im)):16 b:=matrix([op(solve(subs(B*(Y-A*W)=1, s=0), W)),Re(op(solve(subs(B*(X+B*W), s=I), W))),Im(op(solve(subs(B*(X+B*W), s=I), W)))]):17 [x1, x2, x3]:=[op(l<strong>in</strong>alg::matl<strong>in</strong>solve(F, b))]:18 Cap:=subs(C, W=x1+1/(s+1)*x2+1/(s+1)^2*x3):


APPLICATIONS IN CONTROL DESIGN 441.5<strong>in</strong>putoutput1.5<strong>in</strong>putouput11amplitude (N, m/s)0.5amplitude (N, m/s)0.500−0.50 5 10 15 20 25 30time (sec)(a)−0.50 5 10 15 20 25 30time (sec)(b)Figure 8.2: Step response of the closed-loop system, disturbance frequency 1 rad s −1 (a),1.8 rad s −1 (b)The controller that achieves <strong>in</strong>ternal stability and asymptotic properties is given byC ap (s) = (4 m − k) s3 + 5 m s 2 + (4 m − k) s + m, (8.7)s 3 + sThe substitut<strong>in</strong>g (8.5) <strong>in</strong>to (8.7) getsC ap (s) = 3950 s3 − 5000 s 2 − 3950 s + 1000.s 3 + sProperties of the closed-loop system are best seen <strong>in</strong> the diagrams. Step response of theclose-loop system for disturbance with amplitude 1000 and frequency 1 rad s −1 and 1.8 rad s −1is <strong>in</strong> Fig. 8.2. It is obvious that the output tracks reference and the s<strong>in</strong>usoid 1 rad s −1 is filtered.8.2 Inverted PendulumConsider an <strong>in</strong>verted pendulum [5, 27, 38] of Fig. 8.3a. Suppose that friction <strong>in</strong> jo<strong>in</strong>t is negligibleand all mass is concentrated <strong>in</strong> the ball. Then describe it bym l 2 d2 ϕ(t)− m g l s<strong>in</strong> ϕ(t) = −M(t) (8.8)d t 2where m is mass of the rod, l length of the rod, ϕ is angle and M is a torque.L<strong>in</strong>earize the equation (8.8) about the po<strong>in</strong>t ϕ(t) = 0 rad and describe an <strong>in</strong>verted pendulumby transfer function1P(s) =m g l − m l 2 s 2where <strong>in</strong>put is the torque M and output is the angle ϕ. Choose m = 0.5 kg and l = 1 m and enterthis system <strong>in</strong>to MuPAD


APPLICATIONS IN CONTROL DESIGN 45(a)(b)Figure 8.3: Inverted pendulum (a), Feedback control scheme (b)19 P:=1/(m*l*g-m*l^2*s^2):20 m:=1/2: l:=1: g:=981/100:21 b:=polmat(numer(P), s):22 a:=polmat(denom(P), s):With these particular parameters the transfer function of the plant isP(s) = b(s)a(s) = 200981 − 100 s 2 . (8.9)Evidently, the pendulum up is unstable position and the system (8.9) is not stable.8.2.1 Pole PlacementDesign a controller via pole placement for our system (8.9). Consider the scheme 8.3b and acontroller hav<strong>in</strong>g a formC(s) = y(s)x(s) .Then the characteristic polynomial of a closed-loop system isTo physically realize a controller, c(s) must satisfyc(s) = a(s) x(s) + b(s) y(s). (8.10)∂c(s) ≥ 2 ∂a(s) − 1,hence, the characteristic polynomial for the system (8.9) has the formc(s) = (s 2 + 2 ζ ω n s + ω 2 n) (s + c 1 ).


APPLICATIONS IN CONTROL DESIGN 46Re-125-100-75(a)-50-25020100-10-20Time (sec)Im 0 0,125 0,25 0,375 0,50-0,0005-0,001-0,0015-0,002-0,0025-0,003Phi (rad)-0,0035(b)Figure 8.4: Zero and pole map (a) and step response (b) of closed-loop systemChooseω n = 20 √ 2, ζ =correspond<strong>in</strong>g characteristic polynomial is√22 , c 1 = 100,and solve (8.10) for x(s) and y(s).c(s) = (s 2 + 40 s + 800) (s + 100),23 c:=polmat((s^2+40*s+800)*(s+100), s):24 [x, y]:=polmat::axbyc(a, b, c, s, "y-m<strong>in</strong>imal"):25 C:=polmat::tf(y, x):The result<strong>in</strong>g controller is−480981 s − 8137340C(s) = .200 s + 28000Zero and pole map and step response of closed-loop system is <strong>in</strong> Fig. 8.4.8.2.2 LQG ControllerOur objective is to design a controllerC(s) = y(s)x(s)for the system (8.9) that m<strong>in</strong>imizes the standard quadratic optimization criterion∫ t {lim u T (t) r 2 u(t) + y T (t) q 2 y(t) } d tt→∞ 0


APPLICATIONS IN CONTROL DESIGN 47101000800q 2=1q 2=100q 2=10000−1600−2400φ (rad)−3−4−5−6q 2=1q 2=100q 2=10000u (Nms −1 )2000−200−70 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2Time (sec)(a)−4000 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2Time (sec)(b)Figure 8.5: Impulse response of closed-loop system, output (a), manipulated variable (b) forvarious weights q 2 (impulse is applied to <strong>in</strong>put w)where u(t) is the control <strong>in</strong>put and y(t) is the measured output. Let v(t) be the disturb<strong>in</strong>g torqueact<strong>in</strong>g on the pendulum with covariance r 1 and w(t) is a noise that adds to measured angularposition with covariance q 1 , see Fig. 8.3b. Consider the covariances of the <strong>in</strong>put noise and outputnoiseq 1 = 5 · 10 −6 , r 1 = 5 · 10 −6and weights on the output (controlled) signals and the <strong>in</strong>put (control) signalq 2 = 1, r 2 = 1.A controller design consists of solv<strong>in</strong>g two spectral factorizations and one l<strong>in</strong>ear equationa(s) r 1 a ∗ (s) + b(s) q 1 b ∗ (s) = f (s) f ∗ (s)a(s) r 2 a ∗ (s) + b ∗ (s) q 2 b(s) = g(s) g ∗ (s)a(s) x(s) + b(s) y(s) = f (s) g(s),where X ∗ (s) = X T (−s) and tak<strong>in</strong>g the solution with ∂ y(s) < ∂ a(s)26 q1:=r1:=polmat(5/1000000, s):27 q2:=r2:=polmat(1, s):28 f:=polmat::spf(a*r1*polmat::conjugatetranspose(a, s)+b*q1*polmat::conjugatetranspose(b, s), s)[1]:29 g:=polmat::spf(a*r2*polmat::conjugatetranspose(a, s)+polmat::conjugatetranspose(b, s)*q2*b, s)[1]:30 c:=polmat(f*g, s):31 [x, y]:=polmat::axbyc(a, b, c, s, "degy


APPLICATIONS IN CONTROL DESIGN 48The controller isC(s) = 1944722 √ 2 + 1962 √ √ √ ( √ )2004722 + s 1002361 + 981 20 1002361 + 19620−294300 √ 2 − 400 √ 2004722 − 10000 s √ √ √ ,2 2 − 4000 s 1002361 + 981numerically1764999.42 s + 5528212.82C(s) =−178086.71 s − 14142.14 s 2 − 982555.87 .Fig. 8.5 shows impulse responses for various q 2 .8.3 Pendulum Discrete-Time ModelThis example shows usage of Polmat <strong>in</strong> discrete-time control theory. Consider a system ofFig. 8.3a. Discrete-time model, correspond<strong>in</strong>g to pendulum up position, can be written asP(d) = b(d)a(d) = d2 + 2 d + 18 d 2 + 24 d + 8(8.11)where a sample time was chossen T s = 1. In follow<strong>in</strong>g, consider scheme of Fig. 8.6.Figure 8.6: Feedback control scheme8.3.1 Stabiliz<strong>in</strong>g ControllersAt first, compute set of all stabiliz<strong>in</strong>g controllers for the system (8.11). It is def<strong>in</strong>ed aswhere x and y satisfyC(d) = y − a wx + b w ,a x + b y = 1and w is an arbitrary stable and proper rational function such that x + b w ≠ 0.Solve this task <strong>in</strong> MuPAD by


APPLICATIONS IN CONTROL DESIGN 4934 P:=(d^2+2*d+1)/(8*d^2+24*d+8):35 a:=polmat(denom(P)):36 b:=polmat(numer(P)):37 [x, y]:=polmat::axbyc(a, b, 1, d):38 [x, y]:=subs([x, y], t=0):39 C:=polmat::tf(y-a*w, x+b*w):All stabiliz<strong>in</strong>g controllers are given byC(d) = 8 d + 24 − (64 d2 + 192 d + 64) w−d − 2 + (8 d 2 + 16 d + 8) w .8.3.2 Asymptotic Reference Track<strong>in</strong>gOutput tracks reference of type step if denom<strong>in</strong>ator of open-loop system conta<strong>in</strong>s (1 − d).Plant (8.11) has not this property, so a controller must have it. Solve equationfor w. Typex + b w = −d − 2 + (8 d 2 + 16 d + 8) w = (1 − d) ŵ40 solve(denom(C)=(1-d)*w_, w):41 Crt:=subs(C, w=op(%)):and getC rt (d) = −8 − (8 d3 + 16 d 2 − 16 d − 8) ŵ, (8.12)(d 3 + d 2 − d − 1) ŵwhere ŵ is an arbitrary stable and proper rational function such that(d 3 + d 2 − d − 1) ŵ ≠ 0. (8.13)Step response of closed-loop system for ŵ = 0.1 and ŵ = 0.0001 is <strong>in</strong> Fig. 8.7.8.3.3 LQ ControllerF<strong>in</strong>d an LQ controller conta<strong>in</strong>ed <strong>in</strong> the set (8.12). Disturbance-to-output transfer function isgiven byPG(d) = = p − q ŵ = 0 − (d 3 + 2 d 2 − 2 d − 1) ŵ. (8.14)1 + P C rtH 2 norm of (8.14) isclearly, it is zero forWith us<strong>in</strong>g of Polmat you can type‖G(d)‖ = ‖p − q ŵ‖ = ‖ − (d 3 + 2 d 2 − 2 d − 1) ŵ‖,ŵ = 0. (8.15)


APPLICATIONS IN CONTROL DESIGN 5042 G:=collect(normal(P/(1+P*Crt)), w_):43 wh2:=-polmat::coeff(G, w_, 0)/polmat::coeff(G, w_, 1):Solution (8.15) does not satisfy (8.13). Optimal solution of LQ controller problem was notfound. LQ controller track<strong>in</strong>g reference of type step does not exist. Step response of closed-loopsystem for value near to optimal (ŵ = 0.0001) is <strong>in</strong> Fig. 8.7b. Fig. 8.8 shows step responses withdisturbance d with zero mean and variance equaled 100000.11.0001<strong>in</strong>putoutput10.90.9999φ (rad)φ (rad)0.80.99980.7<strong>in</strong>putoutput0.99970 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5Time (s)(a)0.99960 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5Time (s)(b)Figure 8.7: Asymptotic reference track<strong>in</strong>g, step response of closed-loop system for ŵ = 0.1 (a),ŵ = 0.0001 (b)201.0215101.015φ (rad)0φ (rad)1−5−100.99−15<strong>in</strong>putoutput−200 5 10 15 20 25 30 35 40 45 50Time (s)(a)<strong>in</strong>putoutput0.980 5 10 15 20 25 30 35 40 45 50Time (s)(b)Figure 8.8: Asymptotic reference track<strong>in</strong>g, step response of closed-loop system for ŵ = 0.1 (a),ŵ = 0.0001 (b) disturbed by d with zero mean and variance equaled 100000


APPLICATIONS IN CONTROL DESIGN 518.4 Robust ControlThis example shows us<strong>in</strong>g of Polmat <strong>in</strong> robust control theory. Consider a primitive mechanicalsystem given by transfer function [11]Θ(s)T(s) =10 d s + 10 ks 2 (s 2 + 11 d s + 11 k) = b(s)a(s)where Θ denotes an angle, T is an applied moment and k and d are undeterm<strong>in</strong>ed parametersbe<strong>in</strong>g found <strong>in</strong> the <strong>in</strong>tervals0.09 ≤ k ≤ 0.4, 0.004 ≤ d ≤ 0.04. (8.16)Design a controller and f<strong>in</strong>d out robust stability [5, 7, 11].At first, choose any d and k agree<strong>in</strong>g with (8.16) and enter the nom<strong>in</strong>al model44 [dm<strong>in</strong>, dmax]:=[4/1000, 4/100]:45 [km<strong>in</strong>, kmax]:=[9/10, 4/10]:46 d:=(dm<strong>in</strong>+dmax)/2:47 k:=(km<strong>in</strong>+kmax)/2:48 a:=polmat(s^2*(s^2+11*d*s+11*k)):49 b:=polmat(10*d*s+10*k):The nom<strong>in</strong>al model isb(s)a(s) = 110 s + 3250500 s 4 + 121 s 3 + 3575 s . 2Choose the characteristic polynomial of the closed loop and design a controller via pole placement50 c:=polmat((s+5)^5*((s+1/2+1/4*I)*(s+1/2-1/4*I))):51 [x,y]:=polmat::axbyc(a, b, c, s, "y-m<strong>in</strong>imal"):The controllerC(s) = 12963581441757 s3 − 10637501072975 s 2 + 22346289062500 s + 5363769531250.5701250000 s 3 + 919592797500 s 2 + 9351194996130 s + 42140725407250is obta<strong>in</strong>ed.Now, perform the robust stability test52 delete d, k53 a:=polmat(s^2*(s^2+11*d*s+11*k), s):54 b:=polmat(10*d*s+10*k, s):55 cl:=collect(a*x+b*y, [k, d]):56 pd:=coeff(cl, d, 1):57 pk:=coeff(cl, k, 1):58 p0:=cl-d*pd-k*pk:59 polmat::ptopplot(p0, [pd, pk], [[dm<strong>in</strong>, dmax], [km<strong>in</strong>, kmax]],x*I/100 $ x=0..150)


APPLICATIONS IN CONTROL DESIGN 52The last command plots a value set of polytope of polynomials (Fig. 8.9). It is obvious that zero isexcluded and <strong>in</strong> accordance with Zero Exclusion Theorem [11] the closed loop is robustly stable.Polynomial Values SetIm-1e+4-7500-5000-250000Re-2500-5000-7500-1e+4Figure 8.9: Value set of polytope of polynomials


Chapter 9ConclusionsIt was the aim of this diploma <strong>thesis</strong> to give a package of functions for symbolic computationwith polynomials and polynomial matrices for the computer algebraic system MuPAD. Thelibrary was named Polmat. MuPAD with Polmat provide a useful alternative to the few exist<strong>in</strong>gnumerical libraries for polynomial matrices. Polmat is available for free download [1] andresponses from control community as well as MuPAD development team have been stated.MuPAD was found efficient and very capable mathematical tool and great package forsymbolic computation. Polmat makes possible us<strong>in</strong>g MuPAD <strong>in</strong> control theory by a series ofnew implemented functions, <strong>in</strong>clud<strong>in</strong>g solvers for l<strong>in</strong>ear equations with polynomial matricesand spectral factorization.Implemented algorithms do not make ambitions to perform calculations faster than similarlyoriented packages, based on numerical methods. In fact, benchmarks <strong>in</strong> Sec. 7 show that comput<strong>in</strong>gtimes needed to return result are <strong>in</strong> majority longer <strong>in</strong> Polmat than <strong>in</strong> other well-knownpackages for polynomial matrices computation. Solv<strong>in</strong>g l<strong>in</strong>ear equations with polynomials orpolynomial matrices gets longer time with us<strong>in</strong>g of Polmat than the Polynomial Toolbox forMatlab. While comput<strong>in</strong>g time <strong>in</strong>creases quickly with matrix dimension and polynomial degree<strong>in</strong> Polmat, it seems to be constant <strong>in</strong> Polynomial Toolbox. There have been implemented twomethods for comput<strong>in</strong>g a matrix determ<strong>in</strong>ant, symbolic and numeric one. The symbolic algorithmis the slowest of all tested ones. The numeric method is faster than l<strong>in</strong>alg::det butmuch slower then functions of numerical packages. While comput<strong>in</strong>g time of reduction matrixto Smith form by l<strong>in</strong>alg library <strong>in</strong>creases quickly with a matrix dimension, it <strong>in</strong>creases ratherwith polynomial degree <strong>in</strong> Polmat.There is one relevant problem with us<strong>in</strong>g Polmat and MuPAD which might br<strong>in</strong>g somedifficulties. Entry of polynomial matrix or 1 by 1 polynomial matrix as it is def<strong>in</strong>ed <strong>in</strong> Polmat(see Sec. 5) is not compatible with doma<strong>in</strong> DOM POLY which is used for scalar polynomial. Doma<strong>in</strong>DOM POLY is used because it is provided by the MuPAD kernel and comput<strong>in</strong>g with scalarpolynomials is so more efficient than with another doma<strong>in</strong>s. Similar doma<strong>in</strong> for matrix of polynomialsis lacked. This makes problems with perform<strong>in</strong>g elementary operations on polynomialmatrix when a matrix row or column is multiplied by scalar polynomial. A Polmat user mightmeet this problem, for <strong>in</strong>stance, if solver an equation with polynomial matrices returns a 1 by1 matrix whose entry becomes to one of several scalar <strong>in</strong>put arguments of another function. Ihope this problem will be fixed dur<strong>in</strong>g my cooperation with MuPAD team.53


CONCLUSIONS 54Only one of the most important algorithms useful <strong>in</strong> control theory has not been implemented.It is polynomial matrix spectral factorization for the discrete-time case. It is a futureextension.


Bibliography[1] AUGUSTA, P. – HURÁK, Z. Polmat – polynomials and polynomial matrices for MuPAD[onl<strong>in</strong>e]. 〈http://www.polmat.wz.cz〉, 2004. [cite 2004-07-11].[2] AUGUSTA, P. – HURÁK, Z. Polmat user’s guide. Reference manual, December 2004.[3] CHIASSON, J. et al. Control of a multilevel converter us<strong>in</strong>g resultant theory. IEEE Transactionson Control System Technology, vol. 11:345–354, May 2003.[4] DEMLOVÁ, M. – NAGY, J. Algebra. Praha: SNTL, 1985.[5] DOYLE, J. C. – FRANCIS, B. A. – TANNENBAUM, A. R. Feedback Control Theory. NewYork: Macmillan, 1992.[6] HALMO, L. Polpack++: C++ library for comput<strong>in</strong>g with polynomial matrices [onl<strong>in</strong>e].〈http://polpackplusplus.sourceforge.net〉, February 2004.[7] HAVLENA, V. – ŠTECHA, J. Moderní teorie řízení. Praha: Vydavatelství ČVUT, 2 st edition,2000.[8] HENRION, D. Reliable algorithms for polynomial matrices. PhD <strong>thesis</strong>, Institute of InformationTheory and Automation, ASCR. <strong>Prague</strong>, 1998.[9] HENRION, D. – PRIEUR, C. – TLIBA, S. Improv<strong>in</strong>g condition<strong>in</strong>g of polynomial pole placementproblems with application to low-order controller design for a flexible beam. LAAS-CNRS Research Report No. 04163, February 2004.[10] HENRION, D. – ŠEBEK, M. An algorithm for polynomial matrix factor extraction. InProceed<strong>in</strong>gs of the IEEE Conference on Decision and Control, pages 1875–1880, Phoenix,Arizona, December 1999.[11] HROMČÍK, M. – HURÁK, Z. – ŠEBEK, M. Robustní řízení [onl<strong>in</strong>e]. 〈http://dce.felk.cvut.cz/ror〉, 2004. [cite 2004-11-11].[12] HROMČÍK, M. – ŠEBEK, M. New algorithm for polynomial matrix determ<strong>in</strong>ant based onFFT. In European Control Conference ECC’99, Karlsruhe, Germany, September 1999.[13] HUNT, K. J., editor. Polynomial Methods <strong>in</strong> Control and Filter<strong>in</strong>g. London: Peter Peregr<strong>in</strong>us,1993. ISBN 0-86341-295-5.55


CONCLUSIONS 56[14] JEŽEK, J. New algorithm for m<strong>in</strong>imal solution of l<strong>in</strong>ear polynomial equations. Kybernetika,vol. 18, no. 6:505–516, 1982.[15] JEŽEK, J. Conjugate and symmetric polynomial equation – I : Cont<strong>in</strong>ue-time systems.Kybernetika, vol. 19, no. 2:121–130, 1983.[16] JEŽEK, J. Conjugate and symmetric polynomial equations – II : Discrete-time systems.Kybernetika, vol. 19, no. 3:196–211, 1983.[17] JEŽEK, J. – KUČERA, V. Efficient algorithm for matrix spectral factorization. Automatica,vol. 21, no. 6:663–669, 1985.[18] JOHN, J. Systémy a řízení. Praha: Vydavatelství ČVUT, 1 st edition, 1999. ISBN 80-01-01474-6.[19] KAILATH, T. L<strong>in</strong>ear Systems. New York : Prentice Hall, 1980.[20] KRAJNÍK, E. Maticový počet. Praha: Vydavatelství ČVUT, 1 st edition, 2000. ISBN 80-01-01723-0.[21] KUJAN, P. Efektivní výpočty s polynomiálními maticemi v systému Mathematica s aplikacemiv řízení. Master’s <strong>thesis</strong>, <strong>Czech</strong> <strong>Technical</strong> <strong>University</strong> <strong>in</strong> <strong>Prague</strong>, Department ofControl Eng<strong>in</strong>eer<strong>in</strong>g. <strong>Prague</strong>, 2004.[22] KUJAN, P. – HROMČÍK, M. – ŠEBEK, M. New package for effective polynomial computation<strong>in</strong> Mathematica. In The 11th Mediterranean Conference on Control and Automation(MED’03), July 2003. ISBN 960-87706-0-2.[23] KUČERA, V. Algebraická teorie diskrétního l<strong>in</strong>eárního řízení. Praha: Academia, 1978.[24] KUČERA, V. Discrete L<strong>in</strong>ear Control. John Wiley and Sons, 1979.[25] KUČERA, V. Parametrization of stabiliz<strong>in</strong>g controllers with applications. Advances <strong>in</strong>Automatic Control, Voicu, M., editor, pages 173–192, 2003.[26] KWAKERNAAK, H. – ŠEBEK, M. Polynomial J-spectral factorization. IEEE Transactionson Automatic Control, vol. 39, no. 2:315–328, 1994.[27] Leonov, G. A. Lekcii po kursu teori upravleni I. Sankt-Peterburgskigosudarstvenny universitet, 2004.[28] LUKÁČ, S. Implementácia IKT do vyučovania matematiky. In 3. celoštátna konferenciaInfovek 2002, Október 2002.[29] METZNER, T. The MuPAD-Scilab l<strong>in</strong>k. 〈http://www.additive-net.de/ftp/w<strong>in</strong>32/software/mupad/MuPADScilab_Doku.pdf〉, 2003.[30] MULDERS, T. – STORJOHANN, A. On lattice reduction for polynomial matrices. Journal ofSymbolic Computation, no. 35:377–401, 2003.


CONCLUSIONS 57[31] OEVEL, W. – GERHARD, J. MuPAD 2.5 Quick Reference. 2002.[32] OEVEL, W. et al. The MuPAD Tutorial. Spr<strong>in</strong>ger, 2000.[33] PADĚRA, M. Numerical algorithms for polynomial matrices <strong>in</strong> Java. Master’s <strong>thesis</strong>, <strong>Czech</strong><strong>Technical</strong> <strong>University</strong> <strong>in</strong> <strong>Prague</strong>, Department of Control Eng<strong>in</strong>eer<strong>in</strong>g. <strong>Prague</strong>, 2004.[34] POSTEL, F. The l<strong>in</strong>ear algebra package “l<strong>in</strong>alg”. Automath <strong>Technical</strong> Report, no. 9, 1998.[35] QIU, L. What can Routh table offer <strong>in</strong> addition to stability? In 4th IFAC Symposium onRobust Control design, 2003.[36] ROUBAL, J. et al. Moderní teorie řízení – Cvičení. Praha: Vydavatelství ČVUT, 1 st edition,2005.[37] ŠTECHA, J. Diskrétní řídicí systémy. Praha: České vysoké učení technické v Praze, 1 st edition,1985.[38] ŠTECHA, J. – HAVLENA, V. Teorie dynamických systémů. Praha: Vydavatelství ČVUT,2 nd edition, 2002. ISBN 80-01-01971-3.[39] ŠTEFKO, P. C library for comput<strong>in</strong>g with polynomial matrices for the TI-89/92 programmablecalculators [onl<strong>in</strong>e]. 〈http://ptoolti89.wz.cz〉, February 2004.[40] VOSTRÝ, Z. New algorithm for polynomial spectral factorization with quadratic convergenceI. Kybernetika, vol. 11, no. 6:415–422, 1975.[41] VOSTRÝ, Z. New algorithm for polynomial spectral factorization with quadratic convergenceII. Kybernetika, vol. 12, no. 4:248–259, 1976.[42] ZIPPEL, R. Effective polynomial computation. Boston : Kluwer Academic Publishers, 1993.ISBN 0-7923-9375-9.[43] Maple home page. Maplesoft, a division of Waterloo Maple, Inc. [onl<strong>in</strong>e]. 〈http://www.maplesoft.com〉, 2004. [cite 2004-11-04].[44] The polynomial toolboox 2.0 – polynomial equations, polynomial matrices. PolyX, Ltd.[onl<strong>in</strong>e]. 〈http://www.polyx.cz〉, 2000. [cite 2004-04-26].[45] MuPAD. SciFace [onl<strong>in</strong>e]. 〈http://www.mupad.com〉, 2004. [cite 2004-08-07].[46] Scilab. Scilab Group [onl<strong>in</strong>e]. 〈http://scilabsoft.<strong>in</strong>ria.fr〉, 2004. [cite 2004-08-07].[47] The Mathematica home page. Wolfram Research, Inc. [onl<strong>in</strong>e]. 〈http://www.mathematica.com〉, 2004. [cite 2004-11-04].[48] Control tutorial for Matlab [onl<strong>in</strong>e]. 〈http://www.eng<strong>in</strong>.umich.edu/group/ctm〉.[cite 2004-08-30].[49] Wikipedia – the free encyclopedia [onl<strong>in</strong>e]. 〈http://en.wikipedia.org〉, 2004.[cite 2003-11-10].


List of Symbolsa polynomial, numberA, A(s) matrix, polynomial matrix∂a degree of a polynomial∂A degree of a polynomial matrixI, I n identity matrix, identity matrix of the dimension n × nA l,m , A(s) l,m matrix of the dimension l × mA, A(s) transfer function or rational functionā complex conjugate of the polynomialã reciprocal of the polynomial(., .) greatest common divisorA −1adj Adet Adiag l,m [.]‖.‖‖.‖ ∞<strong>in</strong>verse of the matrixadjo<strong>in</strong>t of the matrixdeterm<strong>in</strong>ant of the matrixdiagonal matrixnormH ∞ norm58


List of Figures2.1 Basic block scheme of closed loop . . . . . . . . . . . . . . . . . . . . . . . . . 84.1 MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2 Graphic method for solv<strong>in</strong>g a l<strong>in</strong>ear optimalization problem . . . . . . . . . . . 168.1 Cruise control system, Feedback control system . . . . . . . . . . . . . . . . . 408.2 Step response of the closed-loop system . . . . . . . . . . . . . . . . . . . . . . 448.3 Inverted pendulum, Feedback control scheme . . . . . . . . . . . . . . . . . . 458.4 Zero and pole map, step response of closed-loop system . . . . . . . . . . . . . 468.5 Impulse response of closed-loop system . . . . . . . . . . . . . . . . . . . . . . 478.6 Feedback control scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488.7 Asymptotic reference track<strong>in</strong>g . . . . . . . . . . . . . . . . . . . . . . . . . . . 508.8 Asymptotic reference track<strong>in</strong>g with LQ controller . . . . . . . . . . . . . . . . 508.9 Value set of polytope of polynomials . . . . . . . . . . . . . . . . . . . . . . . . 5259


List of Tables7.1 Benchmark, solver for equation A X + B Y = C, general solution . . . . . . . . . 387.2 Benchmark, solver for equation A X + B Y = C, special solution . . . . . . . . . 387.3 Benchmark, matrix determ<strong>in</strong>ant . . . . . . . . . . . . . . . . . . . . . . . . . 387.4 Benchmark, reduction to Smith form . . . . . . . . . . . . . . . . . . . . . . . 3960


Indexadjo<strong>in</strong>t, 21, 22asymptotic properties, 42controloptimal, 9robust, 51controllerLQ, 49LQG, 46PI, 42set, 41, 48determ<strong>in</strong>ant, 22, 53elementary operations, 5, 9, 10, 22, 23, 30,32, 53formHermite, 9, 29, 30Popov, 29, 30Smith, 9, 29, 53Smith-McMillan, 9greatest common divisor, 21, 25, 31H 2 norm, 33Horner scheme, 23, 24<strong>in</strong>terpolation, 5, 9, 10<strong>in</strong>verse, 23l<strong>in</strong>alg, 14, 37–39l<strong>in</strong>alg::det, 38smithForm, 39stackMatrix, 14Maple, 5, 11Mathematica, 11Matlab, 5, 12, 37–39matrixband, 10Sylvester, 5, 9, 10, 23, 24Maxima, 11m<strong>in</strong>imal realization, 21, 36Nehari problem, 21, 33, 34pole placement, 45, 51polmat::adj, 22augRouth, 33axbyc, 24, 37axbycd, 27axxab, 27, 28axybc, 25decomp, 31det, 23, 38divide, 35gcd, 21, 32gensylv, 24h2norm, 33hermiteForm, 30<strong>in</strong>verse, 23isreduced, 31longdivide, 35m<strong>in</strong>real, 36nehari, 34popovForm, 30rand, 37rank, 23reduce, 32routh, 33schmidtPair, 34smithForm, 29, 39spf, 28value, 24xabyc, 2661


Polynomial Toolbox for Matlab, 5, 12, 37–39, 53polytope, 52rank, 21, 23reductioncolumn, 32row, 32Routh table, 21, 33Schmidt pairs, 21, 34Scilab, 5, 12, 37, 38spectral factorization, 6, 9, 21, 28, 47, 53,54Zero Exclusion Theorem, 5262

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!