Polynomials with real coefficients are defined via record Modelica_LinearSystems2.Math.Polynomial. Read first the previous section about Complex numbers to understand how records, functions in records and the coming operator overloading technique works. The Polynomial record is equivalent to the Complex record. A screenshot is shown in the next figure:

A Polynomial is constructed by the command Polynomial(coefficientVector), where the input argument provides the polynomial coefficients in descending order. In the following figure, a typical session in the command window is shown (try it, e.g., in Dymolas command window):

After defining the import statement to get Polynomial as an abbreviation for Modelica_LinearSystems2.Polynomial, the coefficients are given as vector input to "Polynomial()". Via the operator-'String' function (called by String(p)) Polynomial p is pretty printed. Besides all elementary operations, such as operator '+', '*', functions to compute the integral or the derivative are provide. With function "evaluate(..)" the Polynomial is evaluated for a given value x. With function "roots", the roots of the Polynomial are evaluated and are returned as a Vector of Complex numbers. If the optional second input argument printRoots is set to true, the roots are at once also nicely printed.

With function "fitting", a polynomial can be determined that approximates given table values. Finally with function "plot", the interesting range of x is automatically determined (via calculating the roots of the polynomial and of its derivative) and plotted. A typical plot is shown in the next figure:

Several other examples of Polynomial are available in Polynomial.Examples. In Dymola, select the function with the right mouse button and click "Ok" on the resulting menu which provides the possibility to define all the input arguments. Since the Examples function do not have any input arguments, only the "Ok" button is present:

Generated at 2020-11-23T01:59:39Z by OpenModelicaOpenModelica 1.17.0~dev-193-gd8931f2 using GenerateDoc.mos