Seminar to the lecture Computer-based Engineering Mathematics

Size: px
Start display at page:

Download "Seminar to the lecture Computer-based Engineering Mathematics"

Transcription

1 Seminar to the lecture Computer-based Engineering Mathematics N T S Prof. Dr.-Ing. A. Czylwik Mohammad Abdelqader, M.Sc. Room: BA 249, Tel: abdelqader@nts.uni-duisburg-essen.de Chair of Communication Systems University of Duisburg-Essen

2 Contents 1 Introduction to Matlab What is MATLAB? Expressions Variables Numbers Operators Functions Handling matrices Entering matrices and addressing elements Generating matrices Concatenation Deleting rows and columns Array orientation Scalar-array mathematics Array-array mathematics Basic plotting using Matlab Two-dimensional Graphics Multiple plots on the same axis Line styles, markers and color Plotting rapidly changing mathematical functions Three-dimensional graphics Curve plots Mesh and surface plots Multiple plots in a figure: subplot Functions Domain, range and symmetries

3 3.2 Transformation of coordinates Normalization of physical quantities Local minima and maxima Poles and zeros Curve fitting, interpolation and approximation of functions using Polynomials Polynomial curve fitting Polynomial interpolation Taylor series expansion Vectors and matrices Creating matrices Inverses and determinants Vector norms and the scalar product in Matlab Matlab functions that work on diagonals of a matrix Systems of linear equations Linear system, coefficient matrix, augmented matrix Solutions of linear systems: Existence and uniqueness Numerical methods in linear algebra Matlab syntax and descriptions for LU- and Cholesky-factorization Matlab solutions for systems of linear equations Eigenvalues and eigenvectors Eigenvalues, eigenvectors MATLAB methods to determine eigenvalues and eigenvectors Linear independence of eigenvectors Orthonormal set, Symmetric matrices Diagonalization of a matrix, canonical form Cayley-Hamilton theorem Nonlinear equations 62

4 8.1 Polynomial roots Solving real function using fzero Solving equations using symbolic toolbox System of nonlinear equations Differentiation Polynomial derivatives Approximate derivative Symbolic derivative Integration Introduction to numerical integration Numerical integration using Matlab Symbolic integration Ordinary differential equations Introduction Numerical methods to solve initial value problems (IVP) of ODEs Solving ODEs in Matlab Systems of first-order ODEs

5 1 CHAPTER 1 Introduction to Matlab 1.1 What is MATLAB? MATLAB 1 is a high-performance language for technical computing. It integrates computation, programming and visualisation in a user-friendly environment where problems and solutions are expressed in an easy-to-understand mathematical notation. MATLAB is an interactive system whose basic data element is an array that does not require dimensioning. This allows the user to solve many technical computing problems, especially those with matrix and vektor operations, in less time than it would take to write a programm in a scalar noninteractive language such as C or Fortan. MATLAB features a family of application-specific solutions which are called toolboxes. It is very important to most users of MATLAB, that toolboxes allow to learn and apply specialized technology. These toolboxes are comprehensive collections of MATLAB functions, so-called M-files, that extend the MATLAB environment to solve particular classes of problems. MATLAB is a matrix-based programming tool. Although matrices often need not to be dimensioned explicity, the user has always to look carefully for matrix dimensiones. If it is not defined otherwise, the standard matrix exhibits two dimensiones Ò Ü Ñ. Column vectors an row vectors are represented consistently by Ò Ü ½ and ½ Ü Ò matrices, respectively. MATLAB operations can be classified into the following types of operations: arithmetic and logical operations, mathematical functions, graphical functions, and input/output operations In the following sections, individual elements of MATLAB operations are explained in detail. 1 MATLAB is a registered trademark of The MathWorks, Inc.

6 1.2 Expressions Like most other programming languages, MATLAB provides mathematical expressions, but unlike most programming languages, these expressions involve entire matrices. The building blocks of expressions are Variables Numbers Operators Functiones Variables MATLAB does not require any type declarations or dimension statements. When a new variable name is introduced, it automatically creates the variable and allocates the appropriate amount of memory. If the variable already exists, MATLAB changes its contents and, if necessary, allocates new storage. For example ÓÓ ½¼ creates a 1-by-1 matrix named ÓÓ and stores the value 10 in its single element. In the expression above, constitutes the MATLAB prompt, where the commands can be entered. Variable names consist of a string, which start with a letter, followed by any number of letters, digits, or underscores. MATLAB is case sensitive; it distinguishes between uppercase and lowercase letters. and are not the same variable. To view the matrix assigned to any variable, simply enter the variable name Numbers MATLAB uses the conventional decimal notation. A decimal point and a leading plus or minus sign is optional. Scientific notation uses the letter e to specify a power-of-ten scale factor. Imaginary numbers use either or as a suffix. Some examples of legal numbers are: ¹ ¼º¼¼ ½ º º½¼¾¾¼ ¹½¼ º¼ ¾ ¾½ ¾ ¹¾º ½ ¾ ¾ ¾º ½º Operators Expressions use familar arithmetic operators and precedence rules. Some examples are:

7 + Addition - Subtraction * Multiplication / Division Complex conjugate transpose ( ) Brackets to specify the evaluation order Functions MATLAB provides a large number of standard elementary mathematical functions, including Ò, ÕÖØ, ÜÔ and. Taking the square root or logarithm of a negative number does not lead to an error; the appropriate complex result is produced automatically. MATLAB also provides a lot of advanced mathematical functions, including Bessel and Gamma functions. Most of these functions accept complex arguments. For a list of the elementary mathematical functions, type ÐÔ Ð ÙÒ Some of the functions, like ÕÖØ and Ò are build-in. They are a fixed part of the MATLAB core so they are very efficient. The drawback is that the computational details are not readily accessible. Other functions, like ÑÑ, are implemented in so called M-files. You can see the code and even modify it if you want. 1.3 Handling matrices MATLAB was mainly designed to deal with matrices. In MATLAB, a matrix is a rectangular array of numbers. So scalars can be interpreted to be 1-by-1 matrices and vectors are matrices with only one row or column. MATLAB has other ways to store both numeric and non-numeric data, but in the beginning of learning MATLAB, it is usually best to think of everything as a matrix. The operations in MATLAB are designed to be as natural as possible. Where other programming languages work only with single numbers, MATLAB allows to work with entire matrices quickly and easily Entering matrices and addressing elements The elements of a matrix must be entered one-by-one in a list where the elements of a row must be separated with commas or blank spaces and the rows are divided by semicolons. The whole list must be surrounded with square brackets, e.g.: ½ ¾ After pressing " Enter" MATLAB displays the numbers entered in the command line

8 ½ ¾ Addressing an element of a matrix is also very easy. The Ò-th element of the Ñ-th column in matrix from above is Ò Ñµ. So typing ½ µ ¾ ½µ ¾µ will compute the answer Ò ½ The -th to ½-th elements of the Ñ-th to Ò-th columns can be addressed by ½ Ñ Òµ, e. g. ¾ ½ ¾µ Ò Further examples: ½ ½ ¾µ addresses the first two elements of the first row. Ò ½ ¾ ¾µ addresses all elements of the second column. Ò ¾ Generating matrices There are different ways to generate matrices. Assigning elements explicitly was presented in the paragraph above. To create a row vector with 101 equidistant values starting at 0 and ending by π, this method would be very tedious. So two other possibilities are shown below:

9 Ü Ð Ò Ô ¼ Ô ½¼½µ or Ü ¼ ¼º¼½ ½µ Ô In the first case, the MATLAB function Ð Ò Ô is used to create Ü. The function s arguments are described by: Ð Ò Ô Ö Ø Ú ÐÙ Ð Ø Ú ÐÙ ÒÙÑ Ö Ó Ú ÐÙ µ with the default ÒÙÑ Ö Ó Ú ÐÙ ½¼¼. In the second case, the colon notation ¼ ¼º¼½ ½µ creates an array that starts at 0, increments by 0.01 and ends at 1. Afterwards each element in this array is multiplied by π to create the desired values in Ü. Both of these array creation forms are common in MATLAB. While the colon notation form allows to specify the increment between data elements directly, but not the number of data elements, the MATLAB function Ð Ò Ô allows to specify the number of data elements directly, but not the increment value between these data elements. The colon notation is very often used in MATLAB therefore a closer look should be taken on it. Ö Ø Ú ÐÙ ÒÖ Ñ ÒØ Ð Ø Ú ÐÙ µ creates an array starting at Ö Ø Ú ÐÙ, ending at Ð Ø Ú ÐÙ with an increment which can be negative as well, e. g. Ú ½¼ ¹¾ ¼µ Ú ½¼ ¾ ¼ If the increment is 1, then its usage is optional: Û ½¼µ Û ½¼ MATLAB also provides four functions that generate basic matrices: Þ ÖÓ, ÓÒ, Ö Ò and Ö Ò Ò. These functions will be discussed in chapter Concatenation Concatenation is a process of joining small matrices to make bigger ones. In fact, the first matrix A was created by concatenating its individual elements. The pair of square brackets, [ ], is the concatenation operator. For an example, start with the 3-by-3 matrix, and form

10 ½¼ ¾ º The result is an 6-by-6 matrix, obtained by joining the four submatrices. ½ ¾ ½½ ½¾ ½ ½ ½ ½ ½ ½ ½ ¾ ½¾ ½ ½¾ ¾ ¾ ½ ½¾ ½ ½¾ ¾ Deleting rows and columns To delete rows or columns of a matrix, just use a pair of square brackets, e. g. ¾ µ deletes the second row of. ½ ¾ It is not possible to delete a single element of a matrix, because afterwards it would not still be a matrix. (Exception: vectors, since here deleting an element is the same as deleting a row/column.) Array orientation The orientation of an array can be changed with the MATLAB transpose operator : ¼ ¼ ½ ¾ ³ ¼ ½ ¾ Scalar-array mathematics Addition, subtraction, multiplication and division by a scalar apply the operation to all elements of the array:

11 ½ ¾ ½¼ ½½ ½¾ ½ ¾ ½¼ ½½ ½¾ ¾ ¹½ multiplies each element in c by two and subtracts one from each element of the result. Ò ½ ½½ ½ ½ ½ ½ ¾½ ¾ Array-array mathematics When two arrays have the same dimensions, which means that they have the same number of rows and columns, addition, subtraction, multiplication and division apply on an element-by-element basis in MATLAB. ½ ¾ ½ ¾ ¾ ¾ ¾ ¾ ¾ ¾ ± ØÓ ÓÒ Ò Ð Ñ Òع ݹ Ð Ñ ÒØ ¾ ¹ ± ÑÙÐØ ÔÐ Ý ØÛÓ Ò Ù ØÖ Ø ÖÓÑ Ø Ö ÙÐØ ¼ ¾ Element-by-element multiplication an division work similarly, but the notation is slightly different: º ¾ ½¾ ½ ½

12 The element-by-element multiplication uses the dot multiplication symbol.*, the elementby-element array division uses either º» or º º» Ò ¼º ¼¼ ½º¼¼¼ ½º ¼¼ ½º ½º ¾º¼¼¼ º Ò ¼º ¼¼ ½º¼¼¼ ½º ¼¼ ½º ½º ¾º¼¼¼ In both cases, the elements of the array in front of the slash is divided by the elements of the array behind the slash. To compute a matrix multiplication only the asterisk * must be used, e. g. Therefore the number of columns of must be equal the number of rows of. ½ ¾ ½ ¾ ½ ¾ ½ ¾ ¾¾ ¾

13 Übungen Variablen erzeugen 1.1) Definieren Sie eine skalare Variable und weisen Sie der Variablen den Wert ( j) zu. 1.2) Definieren Sie einen Spaltenvektor mit 5 Elementen, die linear von 80 bis 60 absteigen. 1.3) Welche Ergebnisse liefern die Befehle: Ð Ò Ø µ und Þ µ für die Definitionen in 1.1 und 1.2? 1.4) Definieren Sie den Zeilenvektor mit c = ( ). 1.5) Ergänzen Sie zu dem Vektor eine zweite Zeile, so dass die Matrix ( ) C = entsteht. 1.6) Fügen Sie der Matrix C weitere Spalten hinzu, so dass sich die Matrix ( ) D = ergibt. Matrixoperationen Gegeben sind die Matrix ¾ ½ ½ ¾ und der Spaltenvektor ¾ ½. Bestimmen Sie die Ergebnisse folgender Matlab-Befehle: 2.1) ³ 2.2) 2.3) µ³ 2.4) ³ ³ 2.5) ÓÒ ¾µº 2.6) Þ ÖÓ ¾ µ

14 10 CHAPTER 2 Basic plotting using Matlab 2.1 Two-dimensional Graphics Graphs (in 2-D) are drawn with the ÔÐÓØ statement. In its simplest form, it takes a single vector argument y as in ÔÐÓØ Ýµ. In this case the elements of y are plotted against their indexes, e. g. ÔÐÓØ Ö Ò ½ ¾¼µµ plots 20 random numbers against the integers 1 to 20, joining successive points with straight lines. Straight-line graphs are drawn by giving the x and y coordinates of the end-points in two vectors. For example, to draw a line between the point with cartesian coordinates (0, 1) and (4, 3) use the statement ÔÐÓØ ¼ ½ µ Exercise 1 Draw lines joining the following points: (0, 0), (1, 1), (2, 0), (1,-1) and (0, 0). If x and y are vectors of the same length, the command ÔÐÓØ Ü Ýµ opens a graphics window and draws the elements of y versus the elements of x. For example, Ü ¹ ¼º¼½ Ý Ò Üµ ÔÐÓØ Ü Ýµ The vector x is a partition of the domain with mesh size 0.01, and y is a vector giving the values of sine at the nodes of this partition (recall that Ò Üµ operates entry-wise). When plotting a curve, the plot routine is actually connecting consecutive points induced by the partition with line segments. Thus, the mesh size should be chosen sufficiently small to render the appearance of a smooth curve.

15 Exercise 2 Plot y versus x for y = exp( x 2 ) and x varies from -10 to 10. Plot y versus t for y = sin(2π f t), f = 2 and t varies from -2 to 2. Plot y versus t for y = cos(2π f t), f = 2 and t varies from -2 to Multiple plots on the same axis The easiest way is simply to use hold to keep the current plot on the axes. All subsequent plots are added to the axes until hold is released, either with hold off, or just hold, which toggles the hold state. The second way is to use plot with multiple arguments, e. g. ÔÐÓØ Ü½ ݽ ܾ ݾ Ü Ý ººº µ plots the (vector) pairs (x1, y1), (x2, y2), etc. The advantage of this method is that the vector pairs may have different lengths. MATLAB automatically selects a different color for each pair. For example, Ü ¹¾ Ô ¼º¼½ ¾ Ô ÔÐÓØ Ü Ó Üµ Ü Ò Üµµ ± ÕÙ Ú Ð ÒØ ØÓ Ø ÓÑÑ Ò ÔÐÓØ Ü Ó Üµµ ÓÐ ÓÒ ÔÐÓØ Ü Ò Üµµ ÓÐ Ó Exercise 3 Draw x 2, x 3, x 4, exp( x 2 ) on the same figure using both methods as described above. Add a legend using Matlab command Ð Ò ³Ü ¾ Ü Ü ÜÔ ¹Ü ¾µ³µ Line styles, markers and color Line styles, markers and colors may be selected for a graph with a string argument to plot, e. g. ÔÐÓØ Ü Ý ³¹¹³µ joins the plotted points with dashed lines, whereas ÔÐÓØ Ü Ý ³Ó³µ draws circles at the data points with no lines joining them. You can specify all three properties, e. g.

16 ÔÐÓØ Ü Ò Üµ Ü Ó Üµ ³¹¹ÑÓ³µ plots sin (x) in the default style and color and cos (x) with circles joined with dashes in magenta. The available colors are denoted by the symbols c, m, y, k, r, g, b, w. You can have fun trying to figure out what they mean, or you can use help plot to see the full range of possible symbols Plotting rapidly changing mathematical functions In all the graphing examples so far, the x coordinates of the points plotted have been incremented uniformly, e. g. x = 0 : 0.01 : 4. If the function being plotted changes very rapidly in some places, this can be inefficient, and can even give a misleading graph. For example, Ü ¼º¼½ º¼¼½ º½ ÔÐÓØ Ü Ò ½º»Üµµ MATLAB has a function called ÔÐÓØ which uses a more elegant approach. Whereas the above method evaluates sin(1/x) at equally spaced intervals, ÔÐÓØ evaluates it more frequently over regions where it changes more rapidly. Here is how to use it: ÔÐÓØ ³ Ò ½»Üµ³ ¼º¼½ ¼º½ µ ± ½º»Ü ÒÓØ Ò Exercise 4 Now draw the functions from exercise 3 using ÔÐÓØ. Try also using ÞÔÐÓØ. For more information check the MATLAB help by typing at command window ÐÔ ÞÔÐÓØ. 2.2 Three-dimensional graphics MATLAB s primary commands for creating three dimensional graphics of numericallydefined functions are ÔÐÓØ Ñ ÙÖ Ò ÙÖ Ð Curve plots Completely analogous to plot in two dimensions, the command plot3 produces curves in three-dimensional space. If x, y, and z are three vectors of the same size, then the command ÔÐÓØ Ü Ý Þµ produces a perspective plot of the piecewise linear curve in threespace passing through the points whose coordinates are the respective elements of x, y, and z. These vectors are usually defined parametrically. For example, Ø ¼º¼½ ¼º¼½ ¾¼ Ô Ü Ó Øµ Ý Ò Øµ Þ Øº ÔÐÓØ Ü Ý Þµ ±ÔÖÓ Ù Ð Ü Ø Ø ÓÑÔÖ Ò Ö Ø Ü¹Ý ÔÐ Ò

17 2.2.2 Mesh and surface plots The Ñ command draws three-dimensional wire mesh surface plots. Similarly, threedimensional faceted surface plots are drawn with the command ÙÖ. The following MATLAB M-File generate a mexican hut using the mesh command. ± Å Ü Ò ÙØ Ò Ü ÑÔÐ ÓÖ ÔÐÓغ Ü Ý Ñ Ö ¹ ¼º µ Ö ÕÖØ Üº ¾ ݺ ¾µ Þ Ò Öµº»Ö Ñ Ü Ý Þµ Ø ØÐ ³Å Ü Ò Ùسµ Mexican hut The following script shows how to graph the function f(x, y) = x 1+ y 2 (2.1) over the disk (x 1) 2 +(y 3) 2 = 4 (2.2) ± Ü ÑÔÐ ÓÖ ÈÐÓØ ÖÓÑ Ø ÓÓ ³ Å ØÐ ÓÑ Ô Ò ÓÒ ÓÖ ÑÙÐØ Ú Ö Ð ÐÙÐÙ ³ ± Ý Âº ÓÓÔ Ö ÍÒ Ú Ö ØÝ Ó Å ÖÝÐ Ò ± Ö Ø Ñ Ñ Ö Ò Ö Ø Ø ÓÓÖ Ò Ø Ö Ð Ò Ô ¼ ¾ ¾½µ Ø Ø Ð Ò Ô ¼ ¾ Ô ½µ Ê ÌÀ Ñ Ö Ö Ø Ø µ ± ÆÓÛ ÓÒÚ ÖØ ÒØÓ ÙÖÚ Ð Ò Ö Ñ Ö Ò Ü Ý ± ÓÓÖ Ò Ø ½ ʺ Ó ÌÀµ ʺ Ò ÌÀµ ¹½ º ¾ ÙÖ µ

18 ÓÐ ÓÒ ± Ø ÔÐ Ò Þ ¹ Û Ø Ø ÙÖÚ Ð Ò Ö ± Ñ Ö ÙÖ ¹ ¼ µ ÓÐ Ó Plot of f(x,y) = x 1 +y 2 over the disk (x 1) 2 + (y 3) 2 = z axis y axis x axis 2 3 Exercise 5 Plot a Gaussian probability density function f x,y (x, y) with zero mean and variance 1 within the range x [ 5, 5], y [ 5, 5]: f x,y (x, y) = 1 2π e 1 2 (x2 +y 2 ) Try out the commands Ñ, ÙÖ and ÓÒØÓÙÖ to plot the graph! Exercise 6 Plot the function (2.3) over the unit disk, centered at the origin Multiple plots in a figure: subplot g(r,θ) = (r/2) sin(θ)+r 3 cos(3θ) (2.4) You can show a number of plots in the same figure window with the subplot function. The statement Ù ÔÐÓØ Ñ Ò Ôµ divides the figure window into m n small sets of axes, and selects the p-th set for the current plot (numbered by row from the left of the top row). Exercise 7 Plot the function from Exercise 5 in four subplots using the commands Ñ in Ù ÔÐÓØ ¾ ¾ ½µ, ÙÖ in Ù ÔÐÓØ ¾ ¾ ¾µ, ÙÖ Ð in Ù ÔÐÓØ ¾ ¾ µ and ÓÒØÓÙÖ in Ù ÔÐÓØ ¾ ¾ µ. Give title to each plot as for instance Ø ØÐ ³ÈÐÓØ Ó Ù Ò Ô Ù Ò Ñ ³µ

19 15 CHAPTER 3 Functions This chapter analyzes important characteristics of functions using Matlab. 3.1 Domain, range and symmetries Consider the functions 1 f(x) = 1 x2 4 1 g(x) =. 1 x2 4 Exercise Draw on the same figure the functions f(x) and g(x) for 5 x 5 with distinct colors, markers and legends. Determine the domain, range and symmetry points of f(x) and g(x) so that these are real-valued. Name the x- and y-axis using the Matlab commands ÜÐ Ð ³Ü Ö Ø ÖÖÓÛ³µ ÝÐ Ð ³ ܵ ܵ Ö Ø ÖÖÓÛ³µ 3.2 Transformation of coordinates Consider the function g(x) drawn in the interval 5 x 5: Ð Ð Ö ÐÓ ÐÐ Ü ¹ º¼ Ü ½ º» ÕÖØ ½ ¹ ¼º¾ ܺ ¾ µ µ ÔÐÓØ Ü Ü ³¹Öº³ µ ÓÐ ÓÒ A simple coordinate transformation is obtained by shifting g(x) to g 2 (x) = g(x x 0 ). For x 0 = 1:

20 Ü ¼ ½ ¾ Ü ½º» ÕÖØ ½¹¼º¾ Ü¹Ü ¼µº ¾µµ ÔÐÓØ Ü ¾ Ü ³¹ ³µ ÓÐ ÓÒ Coordinate transformation g(x) g(x 1) g(x), g 2 (x) x Exercise Draw on the same figure the coordinate transformation g 3 (x) = g(ax) for a = 2 (scaling of the x-axis). Draw on the same figure the coordinate transformation g 4 (x) = g(ax x 0 ) for a = 2 and x 0 = 1. Draw a new figure with the non-linear coordinate transformation g 5 (x) = g(x 2 ). Add a legend for all five curves. 3.3 Normalization of physical quantities Physical quantities are normalized with the purpose of simplifying calculations and eliminate the use of the physical units of distinct variables. Consider the the transfer function of the following RLC filter: R U 1 (ω) L C U 2 (ω)

21 H(ω) = U 2(ω) U 1 (ω) = jωl/r 1 ω 2 LC+jωL/R. The squared magnitude of the RLC filter using the technical frequency f is given by H( f) 2 = (2π f L/R) 2 [ ] 2+[2π. 1 (2π f) 2 LC f L/R] 2 Expressing: f in khz, L inµh, C inµf, R in Ω results in: H( f) 2 = ( 2π f L/µH khz R/Ω 10 3) 2 ( ( ) ) 1 2π f 2 2 L C khz µh µf ( ). 2π f L/µH 2 khz R/Ω 10 3 Exercise Draw H( f) 2 in the range 0 f 20kHz for L = 100µH, C = 10µF and R = 10Ω with the corresponding labels in the x- and y-axis. 3.4 Local minima and maxima For a function y = f(x), local minima and maxima are determined by solving the expression dy dx = lim x 0 f(x+ x) f(x) x = 0 A graphical approximation of the derivate can be calculated in Matlab using the command. For a vector y, ݵ calculates the differences between adjacent elements of y. As an example, we would like to determine graphically the local minima and maxima of the function y(x) = x cos(x) for π x π:

22 Ð Ð Ö ÐÓ ÐÐ ÐØ ¼º¼½ Ü ¹Ô ÐØ Ô Ý Ü º Ó Ü µ ÔÐÓØ Ü Ýµ Ö ÓÒ ÓÐ ÓÒ ÔÐÓØ Ü ½ Ò ¹½µ ݵº» ܵ ³Ö³µ ÜÐ Ð ³Ü Ö Ø ÖÖÓÛ³µ ÝÐ Ð ³ ܵ Ö Ø ÖÖÓÛ³µ Ø ØÐ ³ ÔÔÖÓÜ Ñ Ø Ö Ú Ø ÓÒ³µ Ð Ò ³Ý ÜÓ Üµ³ ³ Ý» ܳµ 4 3 Approximate derivation y = xcos(x) dy/dx f(x) Local Minimum Local Maximum x Notice that the command ݵ reduces the dimension of the vector y by one element. Therefore, the figure is drawn by reducing the elements of the vector x by one element - using the command Ü ½ Ò ¹½µ. Exercise Determine the local minima and maxima of the function ( ) 2π f L/µH 2 khz R/Ω 10 3 H( f) 2 = ( ( ) ) 1 2π f 2 2 L C khz µh µf ( ). 2π f L/µH 2 khz R/Ω 10 3 for 0 f 20kHz, L = 100µH, C = 10µF and R = 10Ω with the corresponding labels in the x- and y-axis. The location of the local minima and maxima can be solved analytically in the case that a function can be expressed in a polynomial form. The procedure is described in the following.

23 First, a polynomial is defined in Matlab by a row vector that contain the coefficients of the polynomial. As an example, the polynomial p(x) = x 3 2x 5 is represented by: Ô ½ ¼ ¹¾ ¹ The derivative q(x) = dp(x) dx is calculated using the Matlab command ÔÓÐÝ Ö: Õ ÔÓÐÝ Ö Ôµ The calculation of the roots of q(x), that is q(x) = 0, provides the location of the local minima and maxima. This takes place using the command ÖÓÓØ : Ö ÖÓÓØ Õµ Finally, the value of the local minima and maxima of p(x) are evaluated by means of the command ÔÓÐÝÚ Ð: ÔÓÐÝÚ Ð Ô Öµ x = 0.81 y = 6.01 p(x) x = 0.81 y = x More complex functions can be represented by the ratio of two polynomials H(x) = p 1 (x) p 2 (x) (as is the case of the transfer function of most linear time invariant systems, for example). The derivative of H(x) results in the ratio of two polynomials q 1 (x) and q 2 (x), that is: dh(x) dx = q 1(x) q 2 (x). The polynomials q 1 (x) and q 2 (x) are calculated using the command ÔÓÐÝ Ö as follows:

24 Õ ½ Õ ¾ ÔÓÐÝ Ö Ô ½ Ô ¾µ Finally, the location of the local minima and maxima can be determined by calculating the roots of q 1 (x) using the command ÖÓÓØ, as it was done before. Exercise Determine the local minima and maxima of the function ( ) 2π f L/µH 2 khz R/Ω 10 3 H( f) 2 = ( ( ) ) 1 2π f 2 2 L C khz µh µf ( ). 2π f L/µH 2 khz R/Ω 10 3 for L = 100µH, C = 10µF and R = 10Ω. Compare this result with the resonant frequency f 0 = 1 2π LC. 3.5 Poles and zeros The poles and zeros of a function H(x) are obtained by calculating the roots of the denominator and the numerator H(x), respectively: Exercise Draw the poles and zeros diagram of H( f) 2 = H(x) = k (x x N,1)(x x N,2 ) (x x P,1 )(x x P,2 ) ( ) 2π f L/µH 2 khz R/Ω 10 3 ( ( ) ) 1 2π f 2 2 L C khz µh µf ( ). 2π f L/µH 2 khz R/Ω 10 3 for L = 100µH, C = 10µF and R = 10Ω.

25 21 CHAPTER 4 Curve fitting, interpolation and approximation of functions using Polynomials This chapter covers the basic MATLAB tools for curve fitting, interpolation and approximation of functions using polynomials. 4.1 Polynomial curve fitting The Matlab command ÔÓÐÝ Ø finds the coefficients of a polynomial that fits a set of data in a least-squares sense: Ô ÔÓÐÝ Ø Ü Ý Òµ finds the best-fit Ò-degree polynomial that approximates the data points x and y. x and y are vectors containing the Ü and Ý data to be fitted, and Ò is the degree of the polynomial to return. For example, consider the x-y test data: Ü ½ ¾ Ý º º½ ½¾ ¾ ¼º º ± Ø Ö Ö ÔÓÐÝÒÓÑ Ð Ø Ø ÔÔÖÓÜ Ñ Ø ÐÝ Ø Ø Ø Ô ÔÓÐÝ Ø Ü Ý µ Ô ¹¼º½ ½ ½º ¾½ ¹ ¼º ¾ ¾ º ¼¼ Let us now compute the values of the ÔÓÐÝ Ø estimate over a finer range, and plot the estimate over the real data values for comparison: ܾ ½ º½ ݾ ÔÓÐÝÚ Ð Ô Ü¾µ ÔÐÓØ Ü Ý ³Ó³ ܾ ݾµ Ö ÓÒ Ð Ò ³Ñ ÙÖ ÔÓ ÒØ ³ ³ÔÓÐÝ Ø Ó Ö ³µ Ø ØÐ ³ ßÈÓÐÝÒÓÑ Ð ÙÖÚ ØØ Ò Ð³µ Note: The command ÔÓÐÝÚ Ð Ô Ü¾µ evaluates the polynomial p for each element of the vector x2. For more information check Matlab help by writing at command window ÐÔ ÔÓÐÝÚ Ð. The figure on the next page shows the measured data and the curve fitting to it.

26 Polynomial Curve Fitting measured points polyfit of degree y x Exercise 1 Consider the following test data : Ü ¼ ½ ¾ Ý ¼ ¼º ¾ ¼º ¼º ¼º ¾ ¼º Find a fifth degree polynomial that fits the data, compute the values of the ÔÓÐÝ Ø estimate over a finer range and plot the estimate over the real data values for comparison. 4.2 Polynomial interpolation Polynomials are useful as easier-to-compute approximations of more complicated functions, via a Taylor series expansion or by a low-degree best-fit polynomial using the ÔÓÐÝ Ø function. Example: Let us approximate y = sin(x) between 0 and 2π using a polynomial of degree 5 and plot both in the same figure for comparison. ± Ü ÑÔÐ ÙÒØ ÓÒ ÔÔÖÓÜ Ñ Ø ÓÒ Ù Ò ÔÓÐÝÒÓÑ Ð ± Ø Ú Ò ÙÒØ ÓÒ Ý Ò Üµ ± Ø Ó Ø Ú ØÓ ÔÔÖÓÜ Ñ Ø Ø ÙÒØ ÓÒ ØÛ Ò ¼ Ò ¾ Ô Ù Ò ± ÔÓÐÝÒÓÑ Ð Ó Ö º ÐÓ ÐÐ

27 Ü ¼ ¼º½ ¾ Ô Ý Ò Üµ ÔÐÓØ Ü Ýµ ÜÐ Ð ³Ü Ö Ø ÖÖÓÛ³µ ÝÐ Ð ³Ý Ö Ø ÖÖÓÛ³µ ÓÐ ÓÒ Ô ÔÓÐÝ Ø Ü Ý µ ÜÜ ¼ ¼º½ ¾ Ô ÝÝ ÔÓÐÝÚ Ð Ô Üܵ ÔÐÓØ ÜÜ ÝÝ ³¹ Ö³µ Ð Ò ³ Ò Üµ³ ³ÔÓÐݺ Ó Ö ÔÔÖÓܺ³µ Polynomial approximation of the sin(x) over one period sin(x) poly. of degree 5 approx. 0.5 y x Exercise 2 Approximate y = sin(x) between 2π and 2π using a polynomial of degree 5 and plot both in the same figure for comparison. Now approximate y = sin(x) between 2π and 2π using a polynomial of degree 7 and plot both in the second figure for comparison. Piecewise-polynomial interpolation is typically better than a single high-degree polynomial. The following example shows the difference between them. ± ÓÑÔ Ö ÓÒ Ó Ô Û ÔÓÐÝÒÓÑ Ð Ú Ö Ù Ò Ð ¹ Ö ÔÓÐÝÒÓÑ Ð

28 ± ÒØ ÖÔÓÐ Ø ÓÒ ± ± Ö Ø Ò º ½ Ò Ð ÔÓÐÝÒÓÑ Ð ÔÔÖÓÜ Ñ Ø ÓÒ Ó Ö ÓÖ Ö ÐÓ ÐÐ Ò ½¼ Ü ¹ ¼º½ Ý ½º» ܺ ¾ ½µ Ô ÔÓÐÝ Ø Ü Ý Òµ ÙÖ ½µ ÔÐÓØ ³½» Ü ¾ ½µ³ ¹ ³Ö ¹³µ ÓÐ ÓÒ ÜÜ ¹ ¼º¼½ ÔÐÓØ ÜÜ ÔÓÐÝÚ Ð Ô Üܵ ³ ¹³µ Ð Ò ³ ܵ ½» Ü ¾ ½µ³ ³Ë Ò Ð ÔÓÐÝÒÓÑ Ð ÔÔÖÓܺ Ó Üµ³µ Ø ØÐ ³ ßË Ò Ð ÔÓÐÝÒÓÑ Ð ÔÔÖÓÜ Ñ Ø ÓÒ Ó ÙÒØ ÓÒ Ð³µ ± ÒÓÛ Ø Ô Û ÔÓÐÝÒÓÑ Ð ÒØ ÖÔÓÐ Ø ÓÒ Ù Ò ÔÐ Ò ÓÖ ÔÐ Ò ÔÔÚ Ð ÙÖ ¾µ ÝÝ ÔÐ Ò Ü Ý Üܵ ÔÐÓØ ³½» Ü ¾ ½µ³ ¹ ³Ö ¹³µ ÓÐ ÓÒ ÔÐÓØ ÜÜ ÝÝ ³ ¹³µ Ð Ò ³ ܵ ½» Ü ¾ ½µ³ ³È Û ÔÓÐÝÒÓÑ Ð ÔÔÖÓܺ Ó Üµ³µ Ø ØÐ ³ ßÈ Û ÔÓÐÝÒÓÑ Ð ÔÔÖÓÜ Ñ Ø ÓÒ Ó ÙÒØ ÓÒ Ð³µ The result of the first plot using the single polynomial approximation is: Single polynomial approximation of a function f(x)=1/(x 2 + 1) Single polynomial approx. of f(x) From this figure it could be observed that as n increases the error in the center improves but increases near the endpoints.

29 The second figure, which is shown below, using the piecewise polynomial interpolation shows a better result Piecewise polynomial approximation of a function f(x)=1/(x^2 + 1} Piecewise polynomial approx. of f(x) Exercise 3 Approximate the function y = sin 3 (x) between 2π and 2π using a single polynomial of degree 7 and plot both the original function and the approximated polynomial in the same figure for comparison. Approximate the function y = sin 3 (x) between 2π and 2π using piecewise polynomial interpolation and plot both the original function and the approximated polynomial in the same figure for comparison. 4.3 Taylor series expansion The Taylor series for an analytic function f(x) at x = a is given by: f(x) = (x a) n f(n) (a) n=0 n! (4.1) The Matlab syntax and its description about Taylor series is available from the Matlab help under Symbolic Math Toolbox. The main commands are: Ø ÝÐÓÖ µ is the fifth order Taylor polynomial approximation of f(x) at x = 0 (also known as fifth order Maclaurin polynomial). Ø ÝÐÓÖ Ü ³È Ê Å½³ Ú Ð½ ³È Ê Å¾³ Ú Ð¾ ºººµ returns the Taylor series approximation of f(x) with some optional parameters. Please have a look at possible options using the Matlab command ÐÔ Ø ÝÐÓÖ.

30 Note: The independent variable in the above descriptions is symbolic and hence should first be declared as ÝÑ Ü. Example The Taylor series expansion of f(x) = sin(x) at x = 0 with the order of 5 is: ÝÑ Ü Ò Üµ Ø ÝÐÓÖ Ø ÝÐÓÖ µ The Matlab answer to these commands is: Ø ÝÐÓÖ Ü»½¾¼ ¹ Ü» Ü The Taylor series expansion of f(x) = sin(x) at x = 0 up to the order of 7 is: ÝÑ Ü Ò Üµ ØÖ Ø ÝÐÓÖ ³ÇÖ Ö³ µ The Matlab answer to these commands is: ØÖ ¹ Ü» ¼ ¼ Ü»½¾¼ ¹ Ü» Ü Now we plot the function sin(x) and the Taylor series obtained above for comparison. ÔÐÓØ ³ Ò Üµ³ ¹¾ Ô ¾ Ô ¹½ ½ µ ÓÐ ÓÒ ÔÐÓØ ³¹ Ü» ¼ ¼ Ü»½¾¼ ¹ Ü» ܳ ¹¾ Ô ¾ Ô ¹½º ½º ³Ö ¹¹³µ Observe from the figure below how well the polynomial obtained through Taylor series approximates the function for small values of x ( 3 x 3). Exercise 4 Determine the Taylor series expansion of the following functions at a = 1 with the order of 9 and plot both the function and the corresponding Taylor series in the same figure as the above example. exp(x)

31 cosh(x) sinh(x) Taylor series of a sin function sin(x) x 7 / x 5 /120 x 3 /6 + x Taylor series approximation using the Matlab command Ø ÝÐÓÖØÓÓÐ Syntax Ø ÝÐÓÖØÓÓÐ Ø ÝÐÓÖØÓÓÐ ³ ³µ Description Ø ÝÐÓÖØÓÓÐ initiates a GUI that graphs a function against the N th partial sum of its Taylor series about a base point x = a. The default function, value of N, base point, and interval of computation for Ø ÝÐÓÖØÓÓÐ are f = x cos(x), N = 7, a = 0, and [ 2π, 2π], respectively. Ø ÝÐÓÖØÓÓÐ ³ ³µ initiates the GUI for the given expression f. Example Ø ÝÐÓÖØÓÓÐ ³ ÜÔ Ü Ò Üµµ³µ, this command opens the GUI depicted below:

32 Taylor Series Approximation T N (x) = x 6 /120 + x 4 /3 + x Exercise 5 Now use the command Ø ÝÐÓÖØÓÓÐ, like the example above, and determine the Taylor series approximations at x = 0 for the following functions: tan(x) sin(x) cosh(x) sinh(x) sin(tan(x)) tan(sin(x))

33 29 CHAPTER 5 Vectors and matrices This chapter covers basic operations on vectors and matrices in the MATLAB environment. 5.1 Creating matrices The MATLAB environment uses the term matrix to indicate a variable containing real or complex numbers arranged in a two-dimensional grid. An array is, more generally, a vector, matrix, or higher-dimensional grid of numbers. All arrays in MATLAB are rectangular, in the sense that the component vectors along any dimension are all the same length. MATLAB has a number of functions that create different kinds of matrices. The functions shown in the table below create matrices for more general use. Function ÓÒ Þ ÖÓ Ý Ñ Ö Ò Ö Ò Ò Description Create a matrix or array of all ones. Create a matrix or array of all zeros. Create a matrix with ones on the diagonal and zeros elsewhere. Create a diagonal matrix from a vector. Create a square matrix with rows, columns, and diagonals that add up to the same number. Create a matrix or array of uniformly distributed random numbers. Create a matrix or array of normally distributed random numbers and arrays. For more information check ÐÔ Ñ Ø ÙÒ. Examples Here are some examples of how you can use these functions. Creating a Random Matrix. The Ö Ò function creates a matrix or array with elements uniformly distributed between zero and one. This example multiplies each element by 20:

34 Ö Ò µ ¾¼ ½ º¾ ½º ¼ º½ ¾ ¾º ½ º½½ ½ º½½ º ¼¼ ½ º ½½ º ¾ ¼º ½ ¾ ¾º ½¼º ½ º½ ½ º ½ ½ º ¾ ½ º¾ ½ º½ ¼½ º ¼ ½ º ½ ½ º ½¾º ¾ ½ º¾ ½ º¼¼ ½ º½ ½ º Creating a diagonal matrix. Use to create a diagonal matrix from a vector. You can place the vector along the main diagonal of the matrix, or on a diagonal that is above or below the main one, as shown here. The -1 input places the vector one row below the main diagonal: ½ ¾ ½ ½ ¾ ½ µ Ò ½ ¼ ¼ ¼ ¼ ¼ ¾ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ½ ¹½µ Ò ¼ ¼ ¼ ¼ ¼ ¼ ½ ¼ ¼ ¼ ¼ ¼ ¼ ¾ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ¼ ½ ¼ Creating a magic square matrix. A magic square is a matrix in which the sum of the elements in each column, or each row, or each main diagonal is the same. To create a

35 5-by-5 magic square matrix, use the Ñ function as shown. Ñ µ ½ ¾ ½ ½ ¾ ½ ½ ½ ¾¼ ¾¾ ½¼ ½¾ ½ ¾½ ½½ ½ ¾ ¾ Note that the elements of each row, each column, and each main diagonal add up to the same value: 65. Concatenating matrices Matrix concatenation is the process of joining one or more matrices to make a new matrix. The brackets operator which we have used often serves not only as a matrix constructor, but also as the MATLAB concatenation operator. The expression horizontally concatenates matrices and. The expression vertically concatenates them. ÓÒ ¾ µ ± ¾¹ ݹ Ñ ØÖ Ü Ó ³ Ö Ò µ ± Ú ÖØ ÐÐÝ ÓÒ Ø Ò Ø Ò º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ º¼¼¼¼ ¼º ¼º ¼º¼ ½ ¼º¼ ½ ¼º ½ ½ ¼º ½ ¼º½ ½¾ ¼º¾ ¼º ¾ ¼º ¼¾ ¼º ¾¾ ¼º ¼ ¼ ¼º¼ ¾ ¼º ¼º¼ Accessing single elements We have already discussed in the previous sessions how to reference single elements of a matrix. The syntax is: ÖÓÛ ÓÐÙÑÒµ, where is a variable matrix. Linear indexing You can refer to the elements of a MATLAB matrix with a single subscript, µ. MAT- LAB stores matrices and arrays not in the shape that they appear when displayed in the MATLAB command window, but as a single column of elements. This single column is composed of all of the columns from the matrix, each appended to the last. So, matrix ¾ ¾ ½

36 ¾ ¾ ½ is actually stored in memory as the sequence ¾ ¾ ½ The element at row 3, column 2 of matrix A (value = 5) can also be identified as element 6 in the actual storage sequence. To access this element, you have a choice of using the standard ¾µ syntax, or you can use µ, which is referred to as linear indexing. Accessing multiple elements For the 4-by-4 matrix A shown below, it is possible to compute the sum of the elements in the fourth column of A by typing Ñ µ ½ µ ¾ µ µ µ Ò You can reduce the size of this expression using the colon operator. Subscript expressions involving colons refer to portions of a matrix. The expression ½ Ñ Òµ refers to the elements in rows 1 through m of column n of matrix A. Using this notation, you can compute the sum of the fourth column of A more succinctly: ÙÑ ½ µµ Nonconsecutive elements To refer to nonconsecutive elements in a matrix, use the colon operator with a step value. The Ñ Ò in this expression means to make the assignment to every third element in the matrix. Note that this example uses linear indexing: ½ ½ µ ¹½¼ ¹½¼ ¾ ¹½¼ ½½ ¹½¼ ¹½¼ ½¾ ¹½¼ ½ ½ ¹½¼

37 MATLAB supports a type of array indexing that uses one array as the index into another array. You can base this type of indexing on either the values or the positions of elements in the indexing array. Here is an example of value-based indexing where array B indexes into elements 1, 3, 6, 7, and 10 of array A. In this case, the numeric values of array B designate the intended elements of A: ¼ ½¼ ½ ¾¼ ¾ ¼ ¼ ¼ ½ ½¼ µ Ò ½ ¼ ¼ The end keyword MATLAB provides the keyword end to designate the last element in a particular dimension of an array. This keyword can be useful in instances where your program does not know how many rows or columns there are in a matrix. You can replace the expression in the previous example with ½ Ò µ ¹½¼ Specifying all elements of a row or column The colon by itself refers to all the elements in a row or column of a matrix. Using the following syntax, you can compute the sum of all elements in the second column of a 4-by-4 magic square A: Ñ µ ÙÑ ¾µµ Ò By using the colon with linear indexing, you can refer to all elements in the entire matrix. The command µ displays all the elements of matrix A, returning them in a column-wise order. Check it! Using logicals in array indexing A logical array index designates the elements of an array A based on their position in the indexing array, B, not their value. In this masking type of operation, every

38 true element in the indexing array is treated as a positional index into the array being accessed. In the following example, B is a matrix of logical ones and zeros. The position of these elements in B determines which elements of A are designated by the expression µ: ½ ¾ ½ ¾ ÐÓ Ð ¼ ½ ¼ ½ ¼ ½ ¼ ¼ ½ µ µ Ò ¾ The Ò function can be useful with logical arrays as it returns the linear indices of nonzero elements in B, and thus helps to interpret µ: Ò µ Ò ¾

39 5.2 Inverses and determinants If A and B are square matrices, each of order n n, which satisfy the equations AB = BA = I n then B is called the inverse of A. We write B = A 1. Since the definition is symmetric, A is the inverse of B, that is A = B 1. Let us consider a general 2 2 matrix, and determine the inverse matrix and also look for the conditions for the existance of the inverse matrix. Ax = d, where Thus [ ] a11 a A = 12, x = a 21 a 22 [ x1 x 2 ], d = [ d1 d 2 ] a 11 x 1 + a 12 x 2 = d 1 a 12 x 1 + a 22 x 2 = d 2. These are linear equations in the unknowns x 1 and x 2. x 1 and x 2 are given by, provided that a 11 a 22 a 21 a 12 = 0, or x 1 = a 22d 1 a 12 d 2 a 11 a 22 a 21 a 12, x 2 = a 21d 1 + a 11 d 2 a 11 a 22 a 21 a 12 x = 1 a 11 a 22 a 21 a 12 [ a22 a 12 a 21 + a 11 ][ d1 The number a 11 a 22 a 21 a 12 is known as the determinant of the matrix A, det(a). [ ] Ax = d x = A 1 d A 1 1 a22 a = 12 det(a) a 21 a 11 The Matlab command to find the determinant of the square matrix A is Ø µ and the inverse of A can be obtained using the command ÒÚ µ if it exists, i.e. if A is non-singular. If A is square and nonsingular, then, without roundoff error, ÒÚ µ is theoretically the same as and ÒÚ µ is theoretically the same as». But the computations involving the backslash and slash operators are preferable because they require less computer time, less memory, and have better error-detection properties. d 2 ].

40 Exercise a) Decide whether A, where A = [ ] is singular or not. If it is non-singular, find its inverse. b) Given are the matrices: A = Find A 1, B 1,(AB) 1, and B 1 A 1. c) Find A 1, where [ ] [ ] , B = A = Find the determinants of A T, A and A 1. d) Given that A = [ ] , B = 2 1, C = , , 0 1 verify the distributive law A(B+C) = AB+AC for the three matrices. e) Given are the matrices: A = [ ] 4 2, B = 2 1 Find the inverse of (BA) and(ab) if they exist. f) Given is the matrix: A = [ ] Find a matrix C such that A + C is the identity matrix I 3, i. e. 3 3 identity matrix. Determine AC, CA and A 2 + C 2. Check whether AC = CA. g) For a general n n matrix it could be shown that A+A T is a symmetric matrix, and A A T is a skew-symmetric matrix. Now, express the matrix: A = as the sum of a symmetric matrix and a skew-symmetric matrix..

41 Pseudoinverses Rectangular matrices do not have inverses or determinants. At least one of the equations AX = I and XA = I does not have a solution. A partial replacement for the inverse is provided by the Moore-Penrose pseudoinverse, which is computed by the Ô ÒÚ function. The Matlab syntax is: Ô ÒÚ µ The Moore-Penrose pseudoinverse is a matrix B of the same dimensions as A satisfying the four conditions: A B A = A B A B = B A B is Hermitian B A is Hermitian Example Ö Ò ³ Ø Ø ³ ¼µ Ö Ò ¾µ ¼º ¼½ ¼º¾ ½½ ¼º ¼ ¼º ¼ ¼º ½ ¼º ¾½ Ô ÒÚ µ ½º½ ¹¼º ½½ ¼º½ ¼ ¹¼º ¼¾¾ ½º¼ ¾ ¼º Ò ¼º ¹¼º½ ¾ ¼º ½¾ ¹¼º½ ¾ ¼º ¼ ¼º ¼ ¼º ½¾ ¼º ¼ ¼º ¼ µ³ Ò

42 ¼º ¹¼º½ ¾ ¼º ½¾ ¹¼º½ ¾ ¼º ¼ ¼º ¼ ¼º ½¾ ¼º ¼ ¼º ¼ Ò ½º¼¼¼¼ ¼º¼¼¼¼ ¹¼º¼¼¼¼ ½º¼¼¼¼ µ³ Ò ½º¼¼¼¼ ¹¼º¼¼¼¼ ¼º¼¼¼¼ ½º¼¼¼¼ B A is the 2-by-2 identity matrix, but A B is not the 3-by-3 identity matrix. However, A B acts like an identity on a portion of the space in the sense that A B is symmetric, A B A is equal to A, and B A B is equal to B. Exercise Now A is given by ½¼ Ö Ò ¾ µ. Determine the Moore-Penrose pseudoinverse B, proof the four conditions described earlier. 5.3 Vector norms and the scalar product in Matlab The p-norm of a vector x ( ) 1/p x p = x i p is computed by ÒÓÖÑ Ü Ôµ. This is defined by any value of p > 1, but the most common values of p are 1, 2 and. The default value is p = 2, which corresponds to Euclidean length: Example Ú ¾ ¼ ¹½ ÒÓÖÑ Ú ½µ ÒÓÖÑ Úµ ÒÓÖÑ Ú Ò µ Ò º¼¼¼¼ ¾º¾ ½ ¾º¼¼¼¼

43 Exercise Compute the 1 st, 2 nd, 3 rd, 10 th and the infinity norms of the following vectors: Û ½ ½ ½ Ü ¾ ¾ ½ Ý ½ ½ ½¼ Þ ¹½ ¹½ ½ The scalar product of two vectors Suppose that two vectors a and b are given in component form in 3D as: The scalar product is defined as: a = (a 1, a 2, a 3 ) and b = (b 1, b 2, b 3 ) a b = a 1 b 1 + a 2 b 2 + a 3 b 3 The Matlab equivalent to this is element-by-element multiplication of two vectors of the same size and summed up. Exercise Let a be a vector on x z plane with values( 1, 0, 1) and b = (2, 3, 2). Determine the scalar product a b. Check the results of (a b) (a b) and a 2 b Matlab functions that work on diagonals of a matrix Function ØÖ ØÖ Ð ØÖ Ù Description Compute the sum of the elements on the main diagonal. Return the diagonals of a matrix. Return the lower triangular part of a matrix. Return the upper triangular part of a matrix. Exercise 5.4 The Matlab command Ô Ð µ creates a 3 3 symmetric matrix. Now, create 4 4 symmetric matrix using the function Ô Ð and then determine: The lower triangular part of this matrix. The upper triangular part of this matrix. A vector with the main diagnoal elements of this matrix. The sum of the elements on the main diagonal.

44 40 CHAPTER 6 Systems of linear equations 6.1 Linear system, coefficient matrix, augmented matrix A linear system of equations in n unknowns x 1, x 2,, x n is a set of m equations of the form a 11 x a 1n x n = b 1 a 21 x a 2n x n = b 2.. a m1 x a mn x n = b m. Thus, a system of two equations in three unknown is a 11 x 1 +a 12 x 2 +a 13 x 3 = b 1 a 21 x 1 +a 22 x 2 +a 23 x 3 = b 2. The a jk are given numbers, which are called the coefficients of the system. If the b i are all zero, then (6.1) is called a homogeneous system. If at least one b i is not zero, then (6.1) is called a nonhomogeneous system. A solution of (6.1) is a set of numbers x 1,..., x n that satisfies all the m equations. A solution vector of (6.1) is a vector x whose components constitute a solution of (6.1). Matrix form of the linear system (6.1). The m equations of (6.1) can be written as a single vector equation Ax = b, (6.1) where the coefficient matrix A = [a jk ] is the m n matrix a 11 a 12 a x 1 1n a 21 a 22 a 2n A =......, x = a m1 a m2 a mn x n b 1 and b = b n

45 are column vectors. It is assumed that A is not a zero matrix, which means not all the coefficients a jk are zero. The augmented matrix à of (6.1) is a 11 a 12 a 1n b 1 à = [ A b ] a 21 a 22 a 2n b 2 = a m1 a m2 a mn b n The method of solving such a system by determinants (Cramer s rule) is not practical, but the Gauss elimination method is often used and briefly discussed below. 6.2 Solutions of linear systems: Existence and uniqueness The necessary and sufficient conditions for the existence of solutions and for the uniqueness can be given using the rank of the coefficient matrix A and Ã. (a) Existence A linear system of m equations in n unknowns (6.1) has solutions if and only if the coefficient matrix A and the augmented matrix à have the same rank. (b) Uniqueness The system (6.1) has precisely one solution if and only if this common rank r of A and à equals n. (c) Infinitely many solutions If this rank r is less than n, the system has infinitely many solutions. All of these are obtained by determining r suitable unknowns in terms of the remaining n r unknowns, to which arbitrary values can be assigned. (d) Gauss elimination If solutions exist, they can be obtained by the Gauss elimination. A homogeneous linear system has always the trivial solution x 1 = 0,..., x n = 0. Nontrivial solutions exist if and only if rank A < n. Exercise 6a Determine the existence of the solutions to the following systems of linear equations and proof also the uniqueness of the solutions x 1 + 2x 2 + 4x 3 = 2 4x 1 + 5x 2 +13x 3 = 7 10x 1 +14x 2 +43x 3 = 25 3x 1 4x 2 = 2 x 1 +5x 2 = 4 5x 1 +2x 2 = 12

46 3. 2x 1 +3x 2 +2x 3 = 2 x 1 x 2 3x 3 = 5 3x 1 +5x 2 +5x 3 = 3 4. x 1 + x 2 + x 3 = 1 x 1 2x 2 + x 3 = 2 x 1 x 2 + 5x 3 = 0 5. x 1 +x 2 + x 3 + 3x 4 =0 2x 2 + 2x 4 =5 x 1 x 2 2x 3 2x 4 =4 2x 1 +4x 2 + 2x 3 +8x 4 =5 6.3 Numerical methods in linear algebra Gauss elimination This standard method for solving linear systems (6.1) is a systematic process of elimination that reduces (6.1) to a triangular form because the system can easily solved by back substitution. For instance, a triangular system is 3x 1 + 5x 2 + 2x 3 = 8 8x 2 + 2x 3 = 7. 6x 3 = 3 LU-factorization A is now assumed to be an n n square matrix. Below three related methods are briefly discussed that are modifications of the Gauss elimination. They are named after Doolittle, Crout, and Cholesky and use the idea of LU-factorization, which will be explained first. An LU-factorization of a given square matrix A is of the form A = LU, (6.2) where L is a lower triangular and U is an upper triangular matrix. For example, [ ] [ ][ ] A = = LU =

47 It could be proved that for any nonsingular matrix (interested reader can refer to section 6 of Advanced engineering mathematics by E. Kreyszig), the rows can be reordered so that the resulting matrix A has an LU-factorization (6.3) in which U turns out to be the triangular system at the end of the Gauss elimination and L is the matrix of the multipliers m jk of the Gauss elimination, with diagonal (1,..., 1). The main idea here is that L and U in (6.3) can be computed directly, without solving the simultaneous equations thus, without using the Gauss elimination. Once we have (6.3), Ax = b can be solved in two steps, simply by noting that Ax = LUx = b can be written as: Ly = b, (6.3a) where Ux = y (6.3b) and solving first (6.4a) for y and then (6.4b) for x. This is called Doolittle s method. Both systems (6.4a) and (6.4b) are triangular, so their solution can be found by back substitution in the Gauss elimination method. A similar method, Crout s method, is obtained from (6.3) if U (instead of L) is required to have main diagonal (1,..., 1). In either case the factorization (6.3) is unique. Example A system is given by a matrix A and the vector b as follows: A = b = [ ] Solve the system using Doolittle s method (LU-factorization with main diagonal elements of L equals 1). Solution: u 11 u 12 u 13 A = = l u 22 u l 31 l u 33 u 11 = 3, l 21 u 11 = 0 l 21 = 0,... First solve for Ly = b: A = = y y 2 = 7 y = y

48 Now solve Ux = y: x / x 2 = 7 x = 1/ x /6 Cholesky s method For a symmetric, positive definite matrix A (thus A = A T, x T Ax > 0 for all x = 0), U (sometimes also called R) in (6.3) can even be choose R = L T, thus u jk = l k j but impose no conditions on the main diagonal entries. The popular method of solving Ax = b based on this factorization A = LL T is called Cholesky s method. If A is symmetric but not positive definite, this method could still be applied, but then leads to a complex matrix L, so that it becomes impractical. Example Solve by Cholesky s method: 4x 1 + 2x x 3 = 14 2x x 2 5x 3 = x 1 5x x 3 = 155 Solution: l l 11 l 21 l 31 A = = l 21 l l 22 l l 31 l 32 l l 33 l 11 = a 11 = 2 l 21 = a 21 = 2 l 11 2 = 1 l 31 = a 31 = 14 l 11 2 = A = = By solving first Ly = b, that is: y y 2 = y y = Now solve L T x = y: x x 2 = 27 x = x

SKMM 3023 Applied Numerical Methods

SKMM 3023 Applied Numerical Methods SKMM 3023 Applied Numerical Methods Solution of Nonlinear Equations ibn Abdullah Faculty of Mechanical Engineering Òº ÙÐÐ ÚºÒÙÐÐ ¾¼½ SKMM 3023 Applied Numerical Methods Solution of Nonlinear Equations

More information

SME 3023 Applied Numerical Methods

SME 3023 Applied Numerical Methods UNIVERSITI TEKNOLOGI MALAYSIA SME 3023 Applied Numerical Methods Solution of Nonlinear Equations Abu Hasan Abdullah Faculty of Mechanical Engineering Sept 2012 Abu Hasan Abdullah (FME) SME 3023 Applied

More information

Lund Institute of Technology Centre for Mathematical Sciences Mathematical Statistics

Lund Institute of Technology Centre for Mathematical Sciences Mathematical Statistics Lund Institute of Technology Centre for Mathematical Sciences Mathematical Statistics STATISTICAL METHODS FOR SAFETY ANALYSIS FMS065 ÓÑÔÙØ Ö Ü Ö Ì ÓÓØ ØÖ Ô Ð ÓÖ Ø Ñ Ò Ý Ò Ò ÐÝ In this exercise we will

More information

Chapter 5. Linear Algebra. A linear (algebraic) equation in. unknowns, x 1, x 2,..., x n, is. an equation of the form

Chapter 5. Linear Algebra. A linear (algebraic) equation in. unknowns, x 1, x 2,..., x n, is. an equation of the form Chapter 5. Linear Algebra A linear (algebraic) equation in n unknowns, x 1, x 2,..., x n, is an equation of the form a 1 x 1 + a 2 x 2 + + a n x n = b where a 1, a 2,..., a n and b are real numbers. 1

More information

Fundamentals of Engineering Analysis (650163)

Fundamentals of Engineering Analysis (650163) Philadelphia University Faculty of Engineering Communications and Electronics Engineering Fundamentals of Engineering Analysis (6563) Part Dr. Omar R Daoud Matrices: Introduction DEFINITION A matrix is

More information

OR MSc Maths Revision Course

OR MSc Maths Revision Course OR MSc Maths Revision Course Tom Byrne School of Mathematics University of Edinburgh t.m.byrne@sms.ed.ac.uk 15 September 2017 General Information Today JCMB Lecture Theatre A, 09:30-12:30 Mathematics revision

More information

Chapter 2. Linear Algebra. rather simple and learning them will eventually allow us to explain the strange results of

Chapter 2. Linear Algebra. rather simple and learning them will eventually allow us to explain the strange results of Chapter 2 Linear Algebra In this chapter, we study the formal structure that provides the background for quantum mechanics. The basic ideas of the mathematical machinery, linear algebra, are rather simple

More information

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and Section 5.5. Matrices and Vectors A matrix is a rectangular array of objects arranged in rows and columns. The objects are called the entries. A matrix with m rows and n columns is called an m n matrix.

More information

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 1 x 2. x n 8 (4) 3 4 2

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 1 x 2. x n 8 (4) 3 4 2 MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS SYSTEMS OF EQUATIONS AND MATRICES Representation of a linear system The general system of m equations in n unknowns can be written a x + a 2 x 2 + + a n x n b a

More information

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and Section 5.5. Matrices and Vectors A matrix is a rectangular array of objects arranged in rows and columns. The objects are called the entries. A matrix with m rows and n columns is called an m n matrix.

More information

MTH Linear Algebra. Study Guide. Dr. Tony Yee Department of Mathematics and Information Technology The Hong Kong Institute of Education

MTH Linear Algebra. Study Guide. Dr. Tony Yee Department of Mathematics and Information Technology The Hong Kong Institute of Education MTH 3 Linear Algebra Study Guide Dr. Tony Yee Department of Mathematics and Information Technology The Hong Kong Institute of Education June 3, ii Contents Table of Contents iii Matrix Algebra. Real Life

More information

Finite Difference Methods for Boundary Value Problems

Finite Difference Methods for Boundary Value Problems Finite Difference Methods for Boundary Value Problems October 2, 2013 () Finite Differences October 2, 2013 1 / 52 Goals Learn steps to approximate BVPs using the Finite Difference Method Start with two-point

More information

Systems of Linear Equations and Matrices

Systems of Linear Equations and Matrices Chapter 1 Systems of Linear Equations and Matrices System of linear algebraic equations and their solution constitute one of the major topics studied in the course known as linear algebra. In the first

More information

Prof. Dr.-Ing. A. Czylwik

Prof. Dr.-Ing. A. Czylwik Seminar to the lecture Computer-based Engineering Mathematics N T S Prof. Dr.-Ing. A. Czylwik Amanuel Geda, M.Sc. Room: BA 240, Tel:49(0)203 379-4408, e-mail: geda@nts.uni-due.de Department of Communication

More information

Systems of Linear Equations and Matrices

Systems of Linear Equations and Matrices Chapter 1 Systems of Linear Equations and Matrices System of linear algebraic equations and their solution constitute one of the major topics studied in the course known as linear algebra. In the first

More information

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB (Linear equations) Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional Plots

More information

Applied Linear Algebra in Geoscience Using MATLAB

Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional Plots Programming in

More information

A Review of Matrix Analysis

A Review of Matrix Analysis Matrix Notation Part Matrix Operations Matrices are simply rectangular arrays of quantities Each quantity in the array is called an element of the matrix and an element can be either a numerical value

More information

Linear Algebra Using MATLAB

Linear Algebra Using MATLAB Linear Algebra Using MATLAB MATH 5331 1 May 12, 2010 1 Selected material from the text Linear Algebra and Differential Equations Using MATLAB by Martin Golubitsky and Michael Dellnitz Contents 1 Preliminaries

More information

Linear Algebra. The analysis of many models in the social sciences reduces to the study of systems of equations.

Linear Algebra. The analysis of many models in the social sciences reduces to the study of systems of equations. POLI 7 - Mathematical and Statistical Foundations Prof S Saiegh Fall Lecture Notes - Class 4 October 4, Linear Algebra The analysis of many models in the social sciences reduces to the study of systems

More information

Linear Algebra: Matrix Eigenvalue Problems

Linear Algebra: Matrix Eigenvalue Problems CHAPTER8 Linear Algebra: Matrix Eigenvalue Problems Chapter 8 p1 A matrix eigenvalue problem considers the vector equation (1) Ax = λx. 8.0 Linear Algebra: Matrix Eigenvalue Problems Here A is a given

More information

L3: Review of linear algebra and MATLAB

L3: Review of linear algebra and MATLAB L3: Review of linear algebra and MATLAB Vector and matrix notation Vectors Matrices Vector spaces Linear transformations Eigenvalues and eigenvectors MATLAB primer CSCE 666 Pattern Analysis Ricardo Gutierrez-Osuna

More information

LINEAR SYSTEMS, MATRICES, AND VECTORS

LINEAR SYSTEMS, MATRICES, AND VECTORS ELEMENTARY LINEAR ALGEBRA WORKBOOK CREATED BY SHANNON MARTIN MYERS LINEAR SYSTEMS, MATRICES, AND VECTORS Now that I ve been teaching Linear Algebra for a few years, I thought it would be great to integrate

More information

MAT Linear Algebra Collection of sample exams

MAT Linear Algebra Collection of sample exams MAT 342 - Linear Algebra Collection of sample exams A-x. (0 pts Give the precise definition of the row echelon form. 2. ( 0 pts After performing row reductions on the augmented matrix for a certain system

More information

Gaussian Elimination and Back Substitution

Gaussian Elimination and Back Substitution Jim Lambers MAT 610 Summer Session 2009-10 Lecture 4 Notes These notes correspond to Sections 31 and 32 in the text Gaussian Elimination and Back Substitution The basic idea behind methods for solving

More information

Introduction to Matrices and Linear Systems Ch. 3

Introduction to Matrices and Linear Systems Ch. 3 Introduction to Matrices and Linear Systems Ch. 3 Doreen De Leon Department of Mathematics, California State University, Fresno June, 5 Basic Matrix Concepts and Operations Section 3.4. Basic Matrix Concepts

More information

Review Questions REVIEW QUESTIONS 71

Review Questions REVIEW QUESTIONS 71 REVIEW QUESTIONS 71 MATLAB, is [42]. For a comprehensive treatment of error analysis and perturbation theory for linear systems and many other problems in linear algebra, see [126, 241]. An overview of

More information

Chapter 7. Linear Algebra: Matrices, Vectors,

Chapter 7. Linear Algebra: Matrices, Vectors, Chapter 7. Linear Algebra: Matrices, Vectors, Determinants. Linear Systems Linear algebra includes the theory and application of linear systems of equations, linear transformations, and eigenvalue problems.

More information

a11 a A = : a 21 a 22

a11 a A = : a 21 a 22 Matrices The study of linear systems is facilitated by introducing matrices. Matrix theory provides a convenient language and notation to express many of the ideas concisely, and complicated formulas are

More information

F(jω) = a(jω p 1 )(jω p 2 ) Û Ö p i = b± b 2 4ac. ω c = Y X (jω) = 1. 6R 2 C 2 (jω) 2 +7RCjω+1. 1 (6jωRC+1)(jωRC+1) RC, 1. RC = p 1, p

F(jω) = a(jω p 1 )(jω p 2 ) Û Ö p i = b± b 2 4ac. ω c = Y X (jω) = 1. 6R 2 C 2 (jω) 2 +7RCjω+1. 1 (6jωRC+1)(jωRC+1) RC, 1. RC = p 1, p ÓÖ Ò ÊÄ Ò Ò Û Ò Ò Ö Ý ½¾ Ù Ö ÓÖ ÖÓÑ Ö ÓÒ Ò ÄÈ ÐØ Ö ½¾ ½¾ ½» ½½ ÓÖ Ò ÊÄ Ò Ò Û Ò Ò Ö Ý ¾ Á b 2 < 4ac Û ÒÒÓØ ÓÖ Þ Û Ö Ð Ó ÒØ Ó Û Ð Ú ÕÙ Ö º ËÓÑ Ñ ÐÐ ÕÙ Ö Ö ÓÒ Ò º Ù Ö ÓÖ ½¾ ÓÖ Ù Ö ÕÙ Ö ÓÖ Ò ØÖ Ò Ö ÙÒØ ÓÒ

More information

Linear Algebra Homework and Study Guide

Linear Algebra Homework and Study Guide Linear Algebra Homework and Study Guide Phil R. Smith, Ph.D. February 28, 20 Homework Problem Sets Organized by Learning Outcomes Test I: Systems of Linear Equations; Matrices Lesson. Give examples of

More information

APPENDIX: MATHEMATICAL INDUCTION AND OTHER FORMS OF PROOF

APPENDIX: MATHEMATICAL INDUCTION AND OTHER FORMS OF PROOF ELEMENTARY LINEAR ALGEBRA WORKBOOK/FOR USE WITH RON LARSON S TEXTBOOK ELEMENTARY LINEAR ALGEBRA CREATED BY SHANNON MARTIN MYERS APPENDIX: MATHEMATICAL INDUCTION AND OTHER FORMS OF PROOF When you are done

More information

Examples and MatLab. Vector and Matrix Material. Matrix Addition R = A + B. Matrix Equality A = B. Matrix Multiplication R = A * B.

Examples and MatLab. Vector and Matrix Material. Matrix Addition R = A + B. Matrix Equality A = B. Matrix Multiplication R = A * B. Vector and Matrix Material Examples and MatLab Matrix = Rectangular array of numbers, complex numbers or functions If r rows & c columns, r*c elements, r*c is order of matrix. A is n * m matrix Square

More information

SKMM 3023 Applied Numerical Methods

SKMM 3023 Applied Numerical Methods UNIVERSITI TEKNOLOGI MALAYSIA SKMM 3023 Applied Numerical Methods Ordinary Differential Equations ibn Abdullah Faculty of Mechanical Engineering Òº ÙÐÐ ÚºÒÙÐÐ ¾¼½ SKMM 3023 Applied Numerical Methods Ordinary

More information

Linear Algebra. Matrices Operations. Consider, for example, a system of equations such as x + 2y z + 4w = 0, 3x 4y + 2z 6w = 0, x 3y 2z + w = 0.

Linear Algebra. Matrices Operations. Consider, for example, a system of equations such as x + 2y z + 4w = 0, 3x 4y + 2z 6w = 0, x 3y 2z + w = 0. Matrices Operations Linear Algebra Consider, for example, a system of equations such as x + 2y z + 4w = 0, 3x 4y + 2z 6w = 0, x 3y 2z + w = 0 The rectangular array 1 2 1 4 3 4 2 6 1 3 2 1 in which the

More information

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel LECTURE NOTES on ELEMENTARY NUMERICAL METHODS Eusebius Doedel TABLE OF CONTENTS Vector and Matrix Norms 1 Banach Lemma 20 The Numerical Solution of Linear Systems 25 Gauss Elimination 25 Operation Count

More information

Chapter 9: Systems of Equations and Inequalities

Chapter 9: Systems of Equations and Inequalities Chapter 9: Systems of Equations and Inequalities 9. Systems of Equations Solve the system of equations below. By this we mean, find pair(s) of numbers (x, y) (if possible) that satisfy both equations.

More information

Algebra II Vocabulary Alphabetical Listing. Absolute Maximum: The highest point over the entire domain of a function or relation.

Algebra II Vocabulary Alphabetical Listing. Absolute Maximum: The highest point over the entire domain of a function or relation. Algebra II Vocabulary Alphabetical Listing Absolute Maximum: The highest point over the entire domain of a function or relation. Absolute Minimum: The lowest point over the entire domain of a function

More information

Math 307 Learning Goals. March 23, 2010

Math 307 Learning Goals. March 23, 2010 Math 307 Learning Goals March 23, 2010 Course Description The course presents core concepts of linear algebra by focusing on applications in Science and Engineering. Examples of applications from recent

More information

SME 3023 Applied Numerical Methods

SME 3023 Applied Numerical Methods UNIVERSITI TEKNOLOGI MALAYSIA SME 3023 Applied Numerical Methods Ordinary Differential Equations Abu Hasan Abdullah Faculty of Mechanical Engineering Sept 2012 Abu Hasan Abdullah (FME) SME 3023 Applied

More information

Chapter 1: Systems of linear equations and matrices. Section 1.1: Introduction to systems of linear equations

Chapter 1: Systems of linear equations and matrices. Section 1.1: Introduction to systems of linear equations Chapter 1: Systems of linear equations and matrices Section 1.1: Introduction to systems of linear equations Definition: A linear equation in n variables can be expressed in the form a 1 x 1 + a 2 x 2

More information

Mathematics for Graphics and Vision

Mathematics for Graphics and Vision Mathematics for Graphics and Vision Steven Mills March 3, 06 Contents Introduction 5 Scalars 6. Visualising Scalars........................ 6. Operations on Scalars...................... 6.3 A Note on

More information

Linear Algebra. Min Yan

Linear Algebra. Min Yan Linear Algebra Min Yan January 2, 2018 2 Contents 1 Vector Space 7 1.1 Definition................................. 7 1.1.1 Axioms of Vector Space..................... 7 1.1.2 Consequence of Axiom......................

More information

Math 302 Outcome Statements Winter 2013

Math 302 Outcome Statements Winter 2013 Math 302 Outcome Statements Winter 2013 1 Rectangular Space Coordinates; Vectors in the Three-Dimensional Space (a) Cartesian coordinates of a point (b) sphere (c) symmetry about a point, a line, and a

More information

Quaternion Dynamics, Part 1 Functions, Derivatives, and Integrals. Gary D. Simpson. rev 00 Dec 27, 2014.

Quaternion Dynamics, Part 1 Functions, Derivatives, and Integrals. Gary D. Simpson. rev 00 Dec 27, 2014. Quaternion Dynamics, Part 1 Functions, Derivatives, and Integrals Gary D. Simpson gsim100887@aol.com rev 00 Dec 27, 2014 Summary Definitions are presented for "quaternion functions" of a quaternion. Polynomial

More information

Digital Workbook for GRA 6035 Mathematics

Digital Workbook for GRA 6035 Mathematics Eivind Eriksen Digital Workbook for GRA 6035 Mathematics November 10, 2014 BI Norwegian Business School Contents Part I Lectures in GRA6035 Mathematics 1 Linear Systems and Gaussian Elimination........................

More information

Finite Mathematics Chapter 2. where a, b, c, d, h, and k are real numbers and neither a and b nor c and d are both zero.

Finite Mathematics Chapter 2. where a, b, c, d, h, and k are real numbers and neither a and b nor c and d are both zero. Finite Mathematics Chapter 2 Section 2.1 Systems of Linear Equations: An Introduction Systems of Equations Recall that a system of two linear equations in two variables may be written in the general form

More information

MATRICES. a m,1 a m,n A =

MATRICES. a m,1 a m,n A = MATRICES Matrices are rectangular arrays of real or complex numbers With them, we define arithmetic operations that are generalizations of those for real and complex numbers The general form a matrix of

More information

Introduction - Motivation. Many phenomena (physical, chemical, biological, etc.) are model by differential equations. f f(x + h) f(x) (x) = lim

Introduction - Motivation. Many phenomena (physical, chemical, biological, etc.) are model by differential equations. f f(x + h) f(x) (x) = lim Introduction - Motivation Many phenomena (physical, chemical, biological, etc.) are model by differential equations. Recall the definition of the derivative of f(x) f f(x + h) f(x) (x) = lim. h 0 h Its

More information

Elementary Linear Algebra

Elementary Linear Algebra Matrices J MUSCAT Elementary Linear Algebra Matrices Definition Dr J Muscat 2002 A matrix is a rectangular array of numbers, arranged in rows and columns a a 2 a 3 a n a 2 a 22 a 23 a 2n A = a m a mn We

More information

Lectures 9-10: Polynomial and piecewise polynomial interpolation

Lectures 9-10: Polynomial and piecewise polynomial interpolation Lectures 9-1: Polynomial and piecewise polynomial interpolation Let f be a function, which is only known at the nodes x 1, x,, x n, ie, all we know about the function f are its values y j = f(x j ), j

More information

106 Chapter 5 Curve Sketching. If f(x) has a local extremum at x = a and. THEOREM Fermat s Theorem f is differentiable at a, then f (a) = 0.

106 Chapter 5 Curve Sketching. If f(x) has a local extremum at x = a and. THEOREM Fermat s Theorem f is differentiable at a, then f (a) = 0. 5 Curve Sketching Whether we are interested in a function as a purely mathematical object or in connection with some application to the real world, it is often useful to know what the graph of the function

More information

Homework and Computer Problems for Math*2130 (W17).

Homework and Computer Problems for Math*2130 (W17). Homework and Computer Problems for Math*2130 (W17). MARCUS R. GARVIE 1 December 21, 2016 1 Department of Mathematics & Statistics, University of Guelph NOTES: These questions are a bare minimum. You should

More information

B553 Lecture 5: Matrix Algebra Review

B553 Lecture 5: Matrix Algebra Review B553 Lecture 5: Matrix Algebra Review Kris Hauser January 19, 2012 We have seen in prior lectures how vectors represent points in R n and gradients of functions. Matrices represent linear transformations

More information

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane. Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 2018 8 Lecture 8 8.1 Matrices July 22, 2018 We shall study

More information

New Mexico Tech Hyd 510

New Mexico Tech Hyd 510 Vectors vector - has magnitude and direction (e.g. velocity, specific discharge, hydraulic gradient) scalar - has magnitude only (e.g. porosity, specific yield, storage coefficient) unit vector - a unit

More information

(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB

(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB (Mathematical Operations with Arrays) Contents Getting Started Matrices Creating Arrays Linear equations Mathematical Operations with Arrays Using Script

More information

MATRICES. knowledge on matrices Knowledge on matrix operations. Matrix as a tool of solving linear equations with two or three unknowns.

MATRICES. knowledge on matrices Knowledge on matrix operations. Matrix as a tool of solving linear equations with two or three unknowns. MATRICES After studying this chapter you will acquire the skills in knowledge on matrices Knowledge on matrix operations. Matrix as a tool of solving linear equations with two or three unknowns. List of

More information

Linear Algebra March 16, 2019

Linear Algebra March 16, 2019 Linear Algebra March 16, 2019 2 Contents 0.1 Notation................................ 4 1 Systems of linear equations, and matrices 5 1.1 Systems of linear equations..................... 5 1.2 Augmented

More information

Fundamentals of Linear Algebra. Marcel B. Finan Arkansas Tech University c All Rights Reserved

Fundamentals of Linear Algebra. Marcel B. Finan Arkansas Tech University c All Rights Reserved Fundamentals of Linear Algebra Marcel B. Finan Arkansas Tech University c All Rights Reserved 2 PREFACE Linear algebra has evolved as a branch of mathematics with wide range of applications to the natural

More information

TI89 Titanium Exercises - Part 10.

TI89 Titanium Exercises - Part 10. TI89 Titanium Exercises - Part. Entering matrices directly in the HOME screen s entry line ) Enter your nxm matrix using this format: [[ a, a 2,,a m ][a 2, a 22, a 2m ] [a n, a n2,, a nm ]] This is a matrix

More information

ENGI 9420 Lecture Notes 2 - Matrix Algebra Page Matrix operations can render the solution of a linear system much more efficient.

ENGI 9420 Lecture Notes 2 - Matrix Algebra Page Matrix operations can render the solution of a linear system much more efficient. ENGI 940 Lecture Notes - Matrix Algebra Page.0. Matrix Algebra A linear system of m equations in n unknowns, a x + a x + + a x b (where the a ij and i n n a x + a x + + a x b n n a x + a x + + a x b m

More information

Review of matrices. Let m, n IN. A rectangle of numbers written like A =

Review of matrices. Let m, n IN. A rectangle of numbers written like A = Review of matrices Let m, n IN. A rectangle of numbers written like a 11 a 12... a 1n a 21 a 22... a 2n A =...... a m1 a m2... a mn where each a ij IR is called a matrix with m rows and n columns or an

More information

Introduction to Matrices

Introduction to Matrices POLS 704 Introduction to Matrices Introduction to Matrices. The Cast of Characters A matrix is a rectangular array (i.e., a table) of numbers. For example, 2 3 X 4 5 6 (4 3) 7 8 9 0 0 0 Thismatrix,with4rowsand3columns,isoforder

More information

Lecture Notes in Linear Algebra

Lecture Notes in Linear Algebra Lecture Notes in Linear Algebra Dr. Abdullah Al-Azemi Mathematics Department Kuwait University February 4, 2017 Contents 1 Linear Equations and Matrices 1 1.2 Matrices............................................

More information

ÇÙÐ Ò ½º ÅÙÐ ÔÐ ÔÓÐÝÐÓ Ö Ñ Ò Ú Ö Ð Ú Ö Ð ¾º Ä Ò Ö Ö Ù Ð Ý Ó ËÝÑ ÒÞ ÔÓÐÝÒÓÑ Ð º Ì ÛÓ¹ÐÓÓÔ ÙÒÖ Ö Ô Û Ö Ö ÖÝ Ñ ¹ ÝÓÒ ÑÙÐ ÔÐ ÔÓÐÝÐÓ Ö Ñ

ÇÙÐ Ò ½º ÅÙÐ ÔÐ ÔÓÐÝÐÓ Ö Ñ Ò Ú Ö Ð Ú Ö Ð ¾º Ä Ò Ö Ö Ù Ð Ý Ó ËÝÑ ÒÞ ÔÓÐÝÒÓÑ Ð º Ì ÛÓ¹ÐÓÓÔ ÙÒÖ Ö Ô Û Ö Ö ÖÝ Ñ ¹ ÝÓÒ ÑÙÐ ÔÐ ÔÓÐÝÐÓ Ö Ñ ÅÙÐ ÔÐ ÔÓÐÝÐÓ Ö Ñ Ò ÝÒÑ Ò Ò Ö Ð Ö Ò Ó Ò Ö ÀÍ ÖÐ Òµ Ó Ò ÛÓÖ Û Ö Ò ÖÓÛÒ Ö Ú ½ ¼¾º ¾½ Û Åº Ä Ö Ö Ú ½ ¼¾º ¼¼ Û Äº Ñ Ò Ëº Ï ÒÞ ÖÐ Å ÒÞ ½ º¼ º¾¼½ ÇÙÐ Ò ½º ÅÙÐ ÔÐ ÔÓÐÝÐÓ Ö Ñ Ò Ú Ö Ð Ú Ö Ð ¾º Ä Ò Ö Ö Ù Ð Ý Ó ËÝÑ

More information

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Linear Algebra /34

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Linear Algebra /34 Linear Algebra /34 Vectors A vector is a magnitude and a direction Magnitude = v Direction Also known as norm, length Represented by unit vectors (vectors with a length of 1 that point along distinct axes)

More information

Note: The command name is upper case in the description given by help, but must be lower case in actual use. And the backslash Anb is dierent when A i

Note: The command name is upper case in the description given by help, but must be lower case in actual use. And the backslash Anb is dierent when A i MATLAB Tutorial You need a small number of basic commands to start using MATLAB. This short tutorial describes those fundamental commands. You need to create vectors and matrices, to change them, and to

More information

MATH2210 Notebook 2 Spring 2018

MATH2210 Notebook 2 Spring 2018 MATH2210 Notebook 2 Spring 2018 prepared by Professor Jenny Baglivo c Copyright 2009 2018 by Jenny A. Baglivo. All Rights Reserved. 2 MATH2210 Notebook 2 3 2.1 Matrices and Their Operations................................

More information

Linear Systems and Matrices

Linear Systems and Matrices Department of Mathematics The Chinese University of Hong Kong 1 System of m linear equations in n unknowns (linear system) a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.......

More information

3. Array and Matrix Operations

3. Array and Matrix Operations 3. Array and Matrix Operations Almost anything you learned about in your linear algebra classmatlab has a command to do. Here is a brief summary of the most useful ones for physics. In MATLAB matrices

More information

8.5 Taylor Polynomials and Taylor Series

8.5 Taylor Polynomials and Taylor Series 8.5. TAYLOR POLYNOMIALS AND TAYLOR SERIES 50 8.5 Taylor Polynomials and Taylor Series Motivating Questions In this section, we strive to understand the ideas generated by the following important questions:

More information

Extra Problems for Math 2050 Linear Algebra I

Extra Problems for Math 2050 Linear Algebra I Extra Problems for Math 5 Linear Algebra I Find the vector AB and illustrate with a picture if A = (,) and B = (,4) Find B, given A = (,4) and [ AB = A = (,4) and [ AB = 8 If possible, express x = 7 as

More information

1 - Systems of Linear Equations

1 - Systems of Linear Equations 1 - Systems of Linear Equations 1.1 Introduction to Systems of Linear Equations Almost every problem in linear algebra will involve solving a system of equations. ü LINEAR EQUATIONS IN n VARIABLES We are

More information

Identity Matrix: EDU> eye(3) ans = Matrix of Ones: EDU> ones(2,3) ans =

Identity Matrix: EDU> eye(3) ans = Matrix of Ones: EDU> ones(2,3) ans = Very Basic MATLAB Peter J. Olver October, 2003 Matrices: Type your matrix as follows: Use, or space to separate entries, and ; or return after each row. EDU> [;5 0-3 6;; - 5 ] or EDU> [,5,6,-9;5,0,-3,6;7,8,5,0;-,,5,]

More information

Math Assignment 3 - Linear Algebra

Math Assignment 3 - Linear Algebra Math 216 - Assignment 3 - Linear Algebra Due: Tuesday, March 27. Nothing accepted after Thursday, March 29. This is worth 15 points. 10% points off for being late. You may work by yourself or in pairs.

More information

APPENDIX A. Background Mathematics. A.1 Linear Algebra. Vector algebra. Let x denote the n-dimensional column vector with components x 1 x 2.

APPENDIX A. Background Mathematics. A.1 Linear Algebra. Vector algebra. Let x denote the n-dimensional column vector with components x 1 x 2. APPENDIX A Background Mathematics A. Linear Algebra A.. Vector algebra Let x denote the n-dimensional column vector with components 0 x x 2 B C @. A x n Definition 6 (scalar product). The scalar product

More information

G1110 & 852G1 Numerical Linear Algebra

G1110 & 852G1 Numerical Linear Algebra The University of Sussex Department of Mathematics G & 85G Numerical Linear Algebra Lecture Notes Autumn Term Kerstin Hesse (w aw S w a w w (w aw H(wa = (w aw + w Figure : Geometric explanation of the

More information

Equality: Two matrices A and B are equal, i.e., A = B if A and B have the same order and the entries of A and B are the same.

Equality: Two matrices A and B are equal, i.e., A = B if A and B have the same order and the entries of A and B are the same. Introduction Matrix Operations Matrix: An m n matrix A is an m-by-n array of scalars from a field (for example real numbers) of the form a a a n a a a n A a m a m a mn The order (or size) of A is m n (read

More information

Some Notes on Linear Algebra

Some Notes on Linear Algebra Some Notes on Linear Algebra prepared for a first course in differential equations Thomas L Scofield Department of Mathematics and Statistics Calvin College 1998 1 The purpose of these notes is to present

More information

Linear Algebra for Machine Learning. Sargur N. Srihari

Linear Algebra for Machine Learning. Sargur N. Srihari Linear Algebra for Machine Learning Sargur N. srihari@cedar.buffalo.edu 1 Overview Linear Algebra is based on continuous math rather than discrete math Computer scientists have little experience with it

More information

Elementary Linear Algebra

Elementary Linear Algebra Elementary Linear Algebra Linear algebra is the study of; linear sets of equations and their transformation properties. Linear algebra allows the analysis of; rotations in space, least squares fitting,

More information

Linear Systems of n equations for n unknowns

Linear Systems of n equations for n unknowns Linear Systems of n equations for n unknowns In many application problems we want to find n unknowns, and we have n linear equations Example: Find x,x,x such that the following three equations hold: x

More information

8. Diagonalization.

8. Diagonalization. 8. Diagonalization 8.1. Matrix Representations of Linear Transformations Matrix of A Linear Operator with Respect to A Basis We know that every linear transformation T: R n R m has an associated standard

More information

Lab 2: Static Response, Cantilevered Beam

Lab 2: Static Response, Cantilevered Beam Contents 1 Lab 2: Static Response, Cantilevered Beam 3 1.1 Objectives.......................................... 3 1.2 Scalars, Vectors and Matrices (Allen Downey)...................... 3 1.2.1 Attribution.....................................

More information

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Linear Algebra 1/33

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Linear Algebra 1/33 Linear Algebra 1/33 Vectors A vector is a magnitude and a direction Magnitude = v Direction Also known as norm, length Represented by unit vectors (vectors with a length of 1 that point along distinct

More information

OHSx XM511 Linear Algebra: Solutions to Online True/False Exercises

OHSx XM511 Linear Algebra: Solutions to Online True/False Exercises This document gives the solutions to all of the online exercises for OHSx XM511. The section ( ) numbers refer to the textbook. TYPE I are True/False. Answers are in square brackets [. Lecture 02 ( 1.1)

More information

Contents. 1 Vectors, Lines and Planes 1. 2 Gaussian Elimination Matrices Vector Spaces and Subspaces 124

Contents. 1 Vectors, Lines and Planes 1. 2 Gaussian Elimination Matrices Vector Spaces and Subspaces 124 Matrices Math 220 Copyright 2016 Pinaki Das This document is freely redistributable under the terms of the GNU Free Documentation License For more information, visit http://wwwgnuorg/copyleft/fdlhtml Contents

More information

A Review of Linear Algebra

A Review of Linear Algebra A Review of Linear Algebra Gerald Recktenwald Portland State University Mechanical Engineering Department gerry@me.pdx.edu These slides are a supplement to the book Numerical Methods with Matlab: Implementations

More information

LS.1 Review of Linear Algebra

LS.1 Review of Linear Algebra LS. LINEAR SYSTEMS LS.1 Review of Linear Algebra In these notes, we will investigate a way of handling a linear system of ODE s directly, instead of using elimination to reduce it to a single higher-order

More information

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

Jim Lambers MAT 610 Summer Session Lecture 2 Notes Jim Lambers MAT 610 Summer Session 2009-10 Lecture 2 Notes These notes correspond to Sections 2.2-2.4 in the text. Vector Norms Given vectors x and y of length one, which are simply scalars x and y, the

More information

Next topics: Solving systems of linear equations

Next topics: Solving systems of linear equations Next topics: Solving systems of linear equations 1 Gaussian elimination (today) 2 Gaussian elimination with partial pivoting (Week 9) 3 The method of LU-decomposition (Week 10) 4 Iterative techniques:

More information

Foundations of Matrix Analysis

Foundations of Matrix Analysis 1 Foundations of Matrix Analysis In this chapter we recall the basic elements of linear algebra which will be employed in the remainder of the text For most of the proofs as well as for the details, the

More information

Chapter 4. Vector Space Examples. 4.1 Diffusion Welding and Heat States

Chapter 4. Vector Space Examples. 4.1 Diffusion Welding and Heat States Chapter 4 Vector Space Examples 4.1 Diffusion Welding and Heat States In this section, we begin a deeper look into the mathematics for diffusion welding application discussed in Chapter 1. Recall that

More information

CPE 310: Numerical Analysis for Engineers

CPE 310: Numerical Analysis for Engineers CPE 310: Numerical Analysis for Engineers Chapter 2: Solving Sets of Equations Ahmed Tamrawi Copyright notice: care has been taken to use only those web images deemed by the instructor to be in the public

More information

Using MATLAB. Linear Algebra

Using MATLAB. Linear Algebra Using MATLAB in Linear Algebra Edward Neuman Department of Mathematics Southern Illinois University at Carbondale One of the nice features of MATLAB is its ease of computations with vectors and matrices.

More information

Scientific Computing: Dense Linear Systems

Scientific Computing: Dense Linear Systems Scientific Computing: Dense Linear Systems Aleksandar Donev Courant Institute, NYU 1 donev@courant.nyu.edu 1 Course MATH-GA.2043 or CSCI-GA.2112, Spring 2012 February 9th, 2012 A. Donev (Courant Institute)

More information

Matrix & Linear Algebra

Matrix & Linear Algebra Matrix & Linear Algebra Jamie Monogan University of Georgia For more information: http://monogan.myweb.uga.edu/teaching/mm/ Jamie Monogan (UGA) Matrix & Linear Algebra 1 / 84 Vectors Vectors Vector: A

More information

1 Matrices and Systems of Linear Equations. a 1n a 2n

1 Matrices and Systems of Linear Equations. a 1n a 2n March 31, 2013 16-1 16. Systems of Linear Equations 1 Matrices and Systems of Linear Equations An m n matrix is an array A = (a ij ) of the form a 11 a 21 a m1 a 1n a 2n... a mn where each a ij is a real

More information

ADDITIONAL MATHEMATICS

ADDITIONAL MATHEMATICS ADDITIONAL MATHEMATICS GCE Ordinary Level (Syllabus 4018) CONTENTS Page NOTES 1 GCE ORDINARY LEVEL ADDITIONAL MATHEMATICS 4018 2 MATHEMATICAL NOTATION 7 4018 ADDITIONAL MATHEMATICS O LEVEL (2009) NOTES

More information