Lab 4: Working with arrays and eigenvalues
|
|
- Dortha Williamson
- 5 years ago
- Views:
Transcription
1 Lab 4: Working with arrays and eigenvalues March 23, 2017 The purpose of this lab is to get familiar with manipulating data arrays in numpy. Browser use: This lab introduces the use of a number of Python packages that are particularly useful for working with images such as *.jpg pictures taken with a cell phone. These packages include skimage and PIL (Python Imaging Library). We strongly recommend installing Canopy Express on your computer: if so, then these packages can be readily installed using the Package Manager to install scikits-image. Unfortunately many of these packages are not well documented and hence the only way to learn about using them is to use these packages and consult the Internet: Chances are if you are having a problem, then someone else has posted a question on the Internet about it and hopefully someone else has answered it! In addition, Appendices C and D will be useful as references. Housekeeping: In your home directory make two directories pyprogs and pyimages. It is convenient to put the programs we write in this lab into the directory pyporgs since we will use them in future labs. The directory pyimages will be used to store the programs that we will develop to manipulate images such as *.jpg pictures. 1 Background You can activate python in command mode, by typing the word python at the command prompt, then hit ENTER. In Canopy Express the command mode window is opened when you type Editor (it s the lower of the two windows that open). It is useful to do this to follow the discussion. Now type 1
2 import numpy as np then ENTER, so that you have access to the numpy library of commands. Here are two very important concepts in scientific computing that are often under-emphasized: 1. Not all numbers are the same: There are three basic number types: integers, floating point number and complex numbers. An integer is a number such as 1, 2, 3, etc. Note that integers do not have a decimal point. A floating point number is a number that has a decimal point, i.e 1.0, , and so on. A complex number has the form floating point number ± j floating point number. In Python we can specify the data type by using the command dtype. Thus it we want our number to be short integers we could specify dtype=np.int8 if a floating point number dtype=np.float32 and so on. For imaging we most often use dtype=unit8. This notation stands for 8-byte, unsigned integers. Why are images limited to 8-bytes? There are two reasons: 1). Most computer monitors can only display 8 bytes, and 2) The human eye is only able to render about 8 bytes of visual information. For a useful list of the possible dtypes see If we keep in mind that computers store objects as 0 s and 1 s it is not hard to imagine that we can specify dtypes that are not numbers. For example, dtype=str means a string of letters like a word and dtype=bool refers to either True or False. We can even use the command dtype=object to refer to something that is none of the above. 2. An important data structure in numpy is the array. For an extensive discussion of arrays in Python see Appendix C and using 2
3 arrays in numpy see Appendix D. Here we briefly touch on some of the important points. An array is a table of objects (usually numbers for scientists) having n rows and m columns. For scientists it is convenient to think of an array as a table of data. For example let us consider that the position of the hand during throwing a baseball has been recorded by motion capture cameras. The output of the camera system is typically a table of data in which the first column is time, the second column is the position of the hand in the x=direction at time t, the third column is the position in the y-direction at time t and the fourth column is the z position of the hand at time t. Thus data array has n rows, where n is the nukber of time samples, and 4 columns. The shape of this data array is (n, 4). Suppose for simplicity that we have the array stored in the file test.dat The shape of this array is 3 rows and 2 columns. We can load this data set into our program using the command X = np.loadtxt( test.dat ) The command np.shape(x) tells us the shape of X and returns (3,2). We can also use the command reshape() to change the shape of X. Thus Y=np.reshape(X,(6,1))) returns
4 3. Creating arrays: In the laboratory setting, the most common way to create an array in a Python program is to read in data using the np.loadtxt() command. In this case data file itself determines the way that the numbers are represented, the number of rows and the number of columns. The question is how to create an array of a given shape inside a computer program. In other words for a situation in which we do not read in a data file as discussed above. The answer to this question is important because we often use a computer simulation of a model to predict what the behavior of the experimental observations. Since at some point we will need to compare prediction to observation we need to be able to make an array that contains the predictions of the model. There are three ways to create an array and these are very similar in philosophy The philosophy is the same: we create an array of the desired shape filled with either 0 s, 1 s or random numbers and then replace these numbers by the number generated by our computer simulations. (a) np.zeros(): In this case we create an arrays of 0 s of a required shape. For example, the command X=np.zeros((2,2),dtype=np.float32) creates the array (b) The command np.ones() works in a similar way, except that instead of 1 s we get 0 s. (c) The command np.random.rand() creates an array of a given shape of random floating point numbers, e.g. np.random.rand(2,2) produces
5 It should be noted that for np.zeros() and np.ones() we can specify the dtype, but for np.random.rand() the dtype is always a floating point number. 4. Extracting data from arrays: Each element in an array occupies position (i, j) where i specifies the row and j specifies the column. Thus if we wanted to know what is the value located in the second row, third position of array X we would type X[2,3]. Note that an array position is enclosed by square brackets (in contrast in MATLAB we would use round brackets, i.e. X(2,3)). Keep in mind that the first element in the first row is X[0, 0]. In many languages including Python, the colon : is very special. By itself it denotes all of the corresponding row or column. Thus if we wanted to extract the first column from array X we would type x0=x[:,0] and if we wanted to first row we would type x0=x[0,:] A colon : separating two numbers a : b means rows (columns) a to b. Thus [1:5] means from 1 to 5 Here are some other useful array manipulations: [1:] means 1 to end [len(a):1] means from length a to end [::n] means each n-th item in entire sequence Of course we can also combine these notations, for example, if X was an array with shape (10, 10), then X[1:5,7:10] would mean the first five rows and the last four columns. 5
6 5. Saving computer generated arrays as data files: Numpy lets you write arrays into files in two ways. In order to use these tools well, it is critical to understand the difference between a text and a binary file containing numerical data. In a text file, the number π (referred to as pi in numpy) could be written as , for example: a string of digits that a human can read, with in this case 15 decimal digits. In contrast, that same number written to a binary file would be encoded as 8 characters (bytes) that are not readable by a human but which contain the exact same data that the variable pi had in the computer s memory. The tradeoffs between the two modes are thus: Text mode: occupies more space, precision can be lost (if not all digits are written to disk), but is readable and editable by hand with a text editor. Can only be used for one- and two-dimensional arrays. Binary mode: compact and exact representation of the data in memory, can t be read or edited by hand. Arrays of any size and dimensionality can be saved and read without loss of information. Here we discuss how to read and write arrays in text mode. Appendix D discusses how to read and write arrays in binary mode. The np.savetxt function saves an array to a text file, with options to control the precision, separators and even adding a header. Suppose we have an array X containing 10 numbers from 0 to 9 with shape (2,5) and we want to write it to a file called test.out. The command is np.savetxt( test.out, X, fmt= %1.3f, header="my dataset") and X is # My dataset
7 This is because we used the format option, fmt= %1.2f to specify a floating point number (hence the f ), where the.2 indicates two decimal points. If we wanted the numbers to be in exponential format (like in MATLAB), we would choose fmt= %.2e to obtain # My dataset 0.00e e e e e e e e e e+00 We can read the data using np.loadtxt, namely X=np.loadtxt( test.out ) If we write the command print X, we obtain Why does the file look this way? There are two reasons. First, the default data type for np.loadtxt() is float. Second, comment lines started with # are ignored. If we want to change these defaults, we can look up the options for np.loadtxt() on the Internet. 2 Exercise 1: Stability using XPPAUT In lecture we emphasized three concepts for determining the qualitative behavior of the differential equations we use to model biological phenomena: 1) fixed points, 2) the characteristic equation, and 3) local stability. Briefly, the fixed points are the values of the variables for which all derivatives are equal to zero and local stability refers to the response of the dynamical system to a small perturbation away from the fixed point. Mathematically, the stability of the fixed point is obtained by first linearizing the differential equations using Taylor s theorem and then using the usual Ansatz that x(t) e λt, to obtain a characteristic equation in terms of the eigenvalue, λ. The roots of the characteristic equation corresponds to the eigenvalues that we use to evaluate stability: the fixed point is stable if Re(λ) < 0 and unstable if Re(λ) > 0. 7
8 Figure 1: We obtained the classification of the fixed point and the eigenvalues by clicking on the tab Sing pts after we had changed the axes to make a phase plane portrait.. Note that that the classification of the eigenvalues and the location of the fixed point are shown in the window that opens, but the actual values of the eigenvalues are printed out in the Terminal window. Performing all of these steps becomes increasingly difficult as the number of variables included in the model increases. Since realistic biological models often contain many variables, it quickly happens that we are not able to evaluate stability analytically. Thus recourse to computer programming tools becomes necessary. One possibility is to use a program such as XPPAUT. XPPAUT automatically determines the eigenvalues from the phase plane representation. To see how this is done consider the equation for a damped harmonic oscillator we studied in Lab 2. Construct the phase plane representation and then click on Sing pts (Figure 1). A new window opens which shows the fixed point (bottom), gives the stability (upper right) and classifies the eigenvalues. The XPPAUT convention for classifying the eigenvalues (shown in panel 8
9 at upper left in figure) is c : number of complex eigenvalues with negative real part c + : number of complex eigenvalues with positive real part r : number of real negative eigenvalues r : number of real positive eigenvalues Im : number of pure imaginary eigenvalues The values of the eigenvalues are printed in the window that you used to start XPPAUT. Compare these values to the ones that you determined mathematically. Exercise to do: Use XPPAUT to run one of the *.ode programs you wrote last lab. Once you have a solution, click on Sing pts. Are the fixed points and the eigenvalues values the same as you calculated using paper and pencil? 3 Exercise 2: Stability using Python When we integrate a differential equation using numpy it is necessary to rewrite it as a system of first-order differential equations, for example, dx dt dy dt = ax + by, (1) = cx + dy, where the a, b, c, d are constants. In class we determined the eigenvalues by first reconstructing the differential equation from (1) d 2 x (a + d)dx + (ad bc)x = 0, dt2 dt and then obtaining the λ s (eignevalues) from the characteristic equation λ 2 (a + d)λ + (ad bc) = 0. (2) We adopted this procedure because a course in linear algebra is not a prerequisite for this course. However, this procedure rapidly becomes tedious as 9
10 the number, n, of first-order differential equations increases, i.e. dx 1 = c 11 x 1 + c 12 x 2 + c 13 x c 1,n, dt dx 2 = c 21 x 1 + c 22 x 2 + c 23 x c 2,n, (3) dt. =, dx n = c n1 x 1 + c n2 x 2 + c n3 x c n,n. dt In fact we know that when n > 4 it is unlikely we will be able to determine the λ s analytically. Thus we must resort to numerical procedures. The package np.linalg makes it easy to determine the eigenvalues for a system of linear differential equations of arbitrary size. In order to understand this we need to learn a little bit of linear algebra. First we re-write (3) as dx 1 /dt c 11 c c 1n x 1 dx 2 /dt... dx n /dt = c 21 c c 2n c n1 c n2... c nn x 2... x n. (4) Equation (4) contains two n 1 arrays, one in which the elements are dx i /dt and one in which the elements are x i, and one n n array containing the coefficients. The n 1 arrays corresponds to vectors and the n n array containing n rows and n columns corresponds to a matrix. Using this notation we can re-write (1) as ( ) ( ) ( ) dx/dt a b x =. (5) dy/dt c d y When we multiply a vector by a matrix we multiply a row of the matrix by the vector element by element. Thus we multiple the first element of the first row of the matrix by the first element of the vector, then the second element of the first row of the matrix by the second element of the vector, and so on. In this way way you can see that (5) is an alternate way of writing (1). We can also write (4) as dx dt y = Ax, (6) 10
11 where the bold-face type is used to indicate matrices (capital letter) and vectors (small letters). Equation (6) describes a linear transformation that maps a given array x into a new array y. This statement will become much clearer when we do the Glass-Moiré dot exercise (below). The important point for our discussion is that the λ s (eigenvalues) can be determined from the matrix. Important point: Although it is useful to think of vectors and matrices as kinds of arrays (this in fact is what the programming language MATLAB does), in Python vectors and arrays are not simply kinds of arrays, especially when it comes to multiplication. In other words in Python an array is not the same as a matrix. The package numpy itself contains the package numpy.linalg which makes available a number of useful functions for working with vectors and matrices. Our interest in this package stems from the fact that there is a function, eig(), which outputs the eigenvalues (also the eigenvectors). The important point is that eig() is not restricted to 2 2-matrices, but can be used to determine the eigenvalues for n n matrices where n 2. In order to use these functions it is necessary to remember two things: 1) the subscripts of the coefficients, c ij indicate, respectively, the row number (i) and column (j) number, and 2) a matrix is constructed row by row as np.matrix([[x11, x12,.., xn],.., [xn1, xn2,.., xnn]]) Our discussion up to this point concerns only linear differential equations. For nonlinear differential equations it will be necessary to linearize the equations about a fixed point before we can use numpy.linalg.eig() to determine the eigenvalues. It is posssible to write a computer program that does all of these steps (in fact XPPAUT incorporates this). However, this is an advanced topic. Note that in our typical applications, the number of rows equals the number of columns. The output of numpy.linalg.eig() is two nd.array s: vals gives the λ s and vects gives the eigenvectors. Here our interest here is on the eigenvalues. Example: Write a computer program to determine the eigenvalues, λ s, for dx dt dy dt = y = 3x 2y 11
12 Figure 2: A Moiré-Glass Pattern that resembles the flow patterns near a saddle point. The two colors distinguish the position of the random rots before and after the 2D-plane was rotated by θ. Answer: A Python program that determines the eigenvalues for a system of linear differential equations is import numpy as np import numpy.linalg as linalg X = np.matrix([[0.,1.],[3.,-2.]]) vals, vects = linalg.eig(x) print vals The result is λ = 1, 3. Question: Does this result agree with what you obtained using paper and pencil? 4 Exercise 3: Moiré-Glass dot patterns In the two-dimensional xy-plane, the values of x and y specify the coordinates of a point. A common problem concerns the determination of the coordinates 12
13 of a point when the xy-plane is rotated by an angle θ. From introductory physics we know that the answer to this problem is solved using a rotation matrix, R, [3] where ( ) x = R y new ( ) x y old ( ) cos(θ) sin(θ) R = sin(θ) cos(θ), (7) is the rotation matrix. It has been observed that when a random dot pattern is scaled, rotated, and superimposed over the original data, interesting visual patterns, known as Moiré-Glass Patterns, emerge [1, 2]. Moiré-Glass dot patterns are actively studied in psychophysics to understand how the nervous system perceives visual (sensory) stimuli. A 2-D random dot pattern can be generated using np.rand() which generates random numbers drawn a uniform probability distribution. Thus we can apply transformations to the random dot field, X 1, using a scale, S, and rotation, R, namely X 2 = SRX 1 where ( ) sx 0 S = 0 s y is the scaling matrix. If the scale and rotation factors are small, the transformation is analogous to a single step in the numerical solution of a second order ordinary differential equation, namely, the discrete equation ( ) x(t + 1) y(t + 1 = SR ( ) x(t) y(t), (8) where we have written out X 1 and X 2 in terms of their (x, y) components. The plot of both X 1 and X 2 will reveal the structure of the vector field flow around the fixed point. The fixed point corresponds to the invariant point under the transformation. The eigenvalues of the transformation matrix M = SR determine the nature of the fixed point. We have not discussed how to multiple two matrices and determine the eigenvalues. However, we can generate the Moiré Glass patterns by keeping in mind that the matrix S determines the real part of the eigenvalues and the matrix R determines the imaginary part. If there is no rotation, then the eigenvalues are real and equal to s x and s y. If s x, s y are 13
14 both negative the fixed point is astable node and if they have opposite signs the fixed point is a saddle point. If there is a rotation, then the eigenvalues are complex. If the real parts of both eigenvalues are both less that 1 1. and the eigenvalues are complex, the fixed point is a stable spiral 2. If s x = s y = 0 and there is a rotational componet, we have a center. The program moire_glass,py generates a Moiré-Glass dot pattern that resembles the vector flows in the vicinity of a saddle point (Figure 2). Find values of s x, s y and θ so that the dot pattern resembles a node, a spiral and a center. Two things to keep in mind are 1) the values of these parameters should be quite small since the patterns arise in the local vicinity of the fixed point, and 2) in a discrete dynamical the important point for stability is whether or not λ is less than or greater than 1. In our application this condition becomes whether s x, s y are less than 1. Questions to be answered: 1. Using this information, determine values of s x, s y, θ in the program to obtain the vector field flow for a center and a spiral point. Save these figures as a *.png file. 2. For a given type of Moiré-Glass pattern what happens if you increase the values of s x, s y, θ. For example, does the patterns become more or less evident? 3. What happens if you change the colors of the dots? What happens if you replace the dots with other symbols? 5 Exercise 4: Working with digital images The images produced by a digital camera are most often in *.jpg format. The data in a *.jpg file are presented in the form of an array and thus we can apply the same tricks that we applied to the Moiré dot patterns to digital photographs. Indeed, an infamous felon recently altered his own picture in this way to brag about a crime he had performed, and displayed the picture 1 In a discrete dynamical the condition for stability is that λ < 1 2 In the older literature a spiral point was referred to as a focus. 14
15 Figure 3: A *.jpg picture on the Mona Lisa (left) that is swirled (middle) and then reverse swirled (right). on YouTube. This felon did not realize that an image which has been changed by coordinate transformations, can be changed back to the original. Thus the crook had unwittingly published his confession to the crime for all to see! Skimage (a.k.a. scikit-image) is a collection of algorithms useful for image processing and computer vision. Here we use some of the tools in Skimage to create a swirled image similar to that that the felon used. Image swirling is a non-linear image deformation that creates a whirlpool effect (Figure 3). This image was produced using the program swirl_prog.py. This Python program represents a jump in programming skills from the programs we have considered up to now and thus we do not expect you to be able to digest all of the issues at this point in time. Here we discuss the basic concepts involved in swirling an image. When applying a geometric transformation on an image, we typically make use of a reverse mapping, i.e., for each pixel in the output image, we compute its corresponding position in the input. The reason is that, if we were to do it the other way around (map each input pixel to its new output position), some pixels in the output may be left empty. On the other hand, each output coordinate has exactly one corresponding location in (or 15
16 outside) the input image, and even if that position is non-integer, we may use interpolation to compute the corresponding image value. To perform a reverse mapping, namely a geometric warp, in skimage, you need to provide the reverse mapping to the skimage.transform.warp function. For example, consider the case where we would like to shift an image 50 pixels to the left. The reverse mapping for such a shift would be def shift_left(xy): xy[:, 0] += 50 return xy The corresponding call to warp is: from skimage.transform import warp warp(image, shift_left) In order to understand the swirl transformation, consider the coordinate (x, y) in the output image. The reverse mapping for the swirl transformation first computes, relative to a center, (x 0, y 0 ) using polar coordinates θ = arctan(y/x) ρ = (x x 0 ) 2 + (y y 0 ) 2 and then transforms them according to r = ln(2) radius/5 φ = rotation s = strength θ = φ + s e ρ/r+θ where strength is a parameter for the amount of swirl, radius indicates the swirl extent in pixels, and rotation adds a rotation angle. The transformation of radius into r is to ensure that the transformation decays to 1/1000 th within the specified radius. The program swirl_prog.py, takes a *.jpg picture, mona_lisa.jpg and applies the swirl algorithm. Questions to be answered: 16
17 1. Take a picture with your cell phone and see if you can swirl part of the image using swirl_prog.py. In its present form swirl_prog.py swirls a region centered on the center of the picture. See if you can change this program so that it swirls some other region of the image. Save these as a *.png file. Deliverable: Use Lab4_template.tex to prepare the lab assignment. References [1] I. Amidor (2003). Glass patterns as Moiré effects: new surprising results. Optics Lett. 28: 7-9. [2] L. Glass (1969). Moiré effect from random dots. Nature 223: [3] J. B. Marion (1970). Classical dynamics of particles and systems, 2nd edition. Academic Press, New York,
Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations
Lab 2 Worksheet Problems Problem : Geometry and Linear Equations Linear algebra is, first and foremost, the study of systems of linear equations. You are going to encounter linear systems frequently in
More informationLinearization of Differential Equation Models
Linearization of Differential Equation Models 1 Motivation We cannot solve most nonlinear models, so we often instead try to get an overall feel for the way the model behaves: we sometimes talk about looking
More informationSystems of Linear ODEs
P a g e 1 Systems of Linear ODEs Systems of ordinary differential equations can be solved in much the same way as discrete dynamical systems if the differential equations are linear. We will focus here
More informationConditioning and Stability
Lab 17 Conditioning and Stability Lab Objective: Explore the condition of problems and the stability of algorithms. The condition number of a function measures how sensitive that function is to changes
More informationMOL410/510 Problem Set 1 - Linear Algebra - Due Friday Sept. 30
MOL40/50 Problem Set - Linear Algebra - Due Friday Sept. 30 Use lab notes to help solve these problems. Problems marked MUST DO are required for full credit. For the remainder of the problems, do as many
More informationAssignment 1 Physics/ECE 176
Assignment 1 Physics/ECE 176 Made available: Thursday, January 13, 211 Due: Thursday, January 2, 211, by the beginning of class. Overview Before beginning this assignment, please read carefully the part
More informationBasic Linear Algebra in MATLAB
Basic Linear Algebra in MATLAB 9.29 Optional Lecture 2 In the last optional lecture we learned the the basic type in MATLAB is a matrix of double precision floating point numbers. You learned a number
More informationLab 5: Nonlinear Systems
Lab 5: Nonlinear Systems Goals In this lab you will use the pplane6 program to study two nonlinear systems by direct numerical simulation. The first model, from population biology, displays interesting
More informationProblem set 7 Math 207A, Fall 2011 Solutions
Problem set 7 Math 207A, Fall 2011 s 1. Classify the equilibrium (x, y) = (0, 0) of the system x t = x, y t = y + x 2. Is the equilibrium hyperbolic? Find an equation for the trajectories in (x, y)- phase
More informationIntroduction. How to use this book. Linear algebra. Mathematica. Mathematica cells
Introduction How to use this book This guide is meant as a standard reference to definitions, examples, and Mathematica techniques for linear algebra. Complementary material can be found in the Help sections
More informationMTH 464: Computational Linear Algebra
MTH 464: Computational Linear Algebra Lecture Outlines Exam 4 Material Prof. M. Beauregard Department of Mathematics & Statistics Stephen F. Austin State University April 15, 2018 Linear Algebra (MTH 464)
More informationImage Compression. 1. Introduction. Greg Ames Dec 07, 2002
Image Compression Greg Ames Dec 07, 2002 Abstract Digital images require large amounts of memory to store and, when retrieved from the internet, can take a considerable amount of time to download. The
More informationPHYS 7411 Spring 2015 Computational Physics Homework 4
PHYS 7411 Spring 215 Computational Physics Homework 4 Due by 3:pm in Nicholson 447 on 3 March 215 Any late assignments will be penalized in the amount of 25% per day late. Any copying of computer programs
More information1 Overview of Simulink. 2 State-space equations
Modelling and simulation of engineering systems Simulink Exercise 1 - translational mechanical systems Dr. M. Turner (mct6@sun.engg.le.ac.uk 1 Overview of Simulink Simulink is a package which runs in the
More informationNumber Representation and Waveform Quantization
1 Number Representation and Waveform Quantization 1 Introduction This lab presents two important concepts for working with digital signals. The first section discusses how numbers are stored in memory.
More informationLab 6: Linear Algebra
6.1 Introduction Lab 6: Linear Algebra This lab is aimed at demonstrating Python s ability to solve linear algebra problems. At the end of the assignment, you should be able to write code that sets up
More informationLab 1: Dynamic Simulation Using Simulink and Matlab
Lab 1: Dynamic Simulation Using Simulink and Matlab Objectives In this lab you will learn how to use a program called Simulink to simulate dynamic systems. Simulink runs under Matlab and uses block diagrams
More informationComplex Dynamic Systems: Qualitative vs Quantitative analysis
Complex Dynamic Systems: Qualitative vs Quantitative analysis Complex Dynamic Systems Chiara Mocenni Department of Information Engineering and Mathematics University of Siena (mocenni@diism.unisi.it) Dynamic
More informationUnderstand the existence and uniqueness theorems and what they tell you about solutions to initial value problems.
Review Outline To review for the final, look over the following outline and look at problems from the book and on the old exam s and exam reviews to find problems about each of the following topics.. Basics
More informationMath 312 Lecture Notes Linear Two-dimensional Systems of Differential Equations
Math 2 Lecture Notes Linear Two-dimensional Systems of Differential Equations Warren Weckesser Department of Mathematics Colgate University February 2005 In these notes, we consider the linear system of
More informationCopyright (c) 2006 Warren Weckesser
2.2. PLANAR LINEAR SYSTEMS 3 2.2. Planar Linear Systems We consider the linear system of two first order differential equations or equivalently, = ax + by (2.7) dy = cx + dy [ d x x = A x, where x =, and
More informationSome 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 informationchapter 12 MORE MATRIX ALGEBRA 12.1 Systems of Linear Equations GOALS
chapter MORE MATRIX ALGEBRA GOALS In Chapter we studied matrix operations and the algebra of sets and logic. We also made note of the strong resemblance of matrix algebra to elementary algebra. The reader
More informationHomogeneous Linear Systems and Their General Solutions
37 Homogeneous Linear Systems and Their General Solutions We are now going to restrict our attention further to the standard first-order systems of differential equations that are linear, with particular
More informationQuestion: Total. Points:
MATH 308 May 23, 2011 Final Exam Name: ID: Question: 1 2 3 4 5 6 7 8 9 Total Points: 0 20 20 20 20 20 20 20 20 160 Score: There are 9 problems on 9 pages in this exam (not counting the cover sheet). Make
More informationBCMB/CHEM 8190 Lab Exercise Using Maple for NMR Data Processing and Pulse Sequence Design March 2012
BCMB/CHEM 8190 Lab Exercise Using Maple for NMR Data Processing and Pulse Sequence Design March 2012 Introduction Maple is a powerful collection of routines to aid in the solution of mathematical problems
More informationDesigning Information Devices and Systems I Spring 2017 Babak Ayazifar, Vladimir Stojanovic Homework 2
EECS 16A Designing Information Devices and Systems I Spring 2017 Babak Ayazifar, Vladimir Stojanovic Homework 2 This homework is due February 6, 2017, at 23:59. Self-grades are due February 9, 2017, at
More informationProject 2: Using linear systems for numerical solution of boundary value problems
LINEAR ALGEBRA, MATH 124 Instructor: Dr. T.I. Lakoba Project 2: Using linear systems for numerical solution of boundary value problems Goal Introduce one of the most important applications of Linear Algebra
More informationTaylor series. Chapter Introduction From geometric series to Taylor polynomials
Chapter 2 Taylor series 2. Introduction The topic of this chapter is find approximations of functions in terms of power series, also called Taylor series. Such series can be described informally as infinite
More informationChapter 6 Nonlinear Systems and Phenomena. Friday, November 2, 12
Chapter 6 Nonlinear Systems and Phenomena 6.1 Stability and the Phase Plane We now move to nonlinear systems Begin with the first-order system for x(t) d dt x = f(x,t), x(0) = x 0 In particular, consider
More informationFundamentals of Dynamical Systems / Discrete-Time Models. Dr. Dylan McNamara people.uncw.edu/ mcnamarad
Fundamentals of Dynamical Systems / Discrete-Time Models Dr. Dylan McNamara people.uncw.edu/ mcnamarad Dynamical systems theory Considers how systems autonomously change along time Ranges from Newtonian
More informationHomework 1 Solutions
18-9 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 18 Homework 1 Solutions Part One 1. (8 points) Consider the DT signal given by the algorithm: x[] = 1 x[1] = x[n] = x[n 1] x[n ] (a) Plot
More informationMathematics 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 informationMon Jan Improved acceleration models: linear and quadratic drag forces. Announcements: Warm-up Exercise:
Math 2250-004 Week 4 notes We will not necessarily finish the material from a given day's notes on that day. We may also add or subtract some material as the week progresses, but these notes represent
More informationFundamentals of Measurement and Error Analysis
Lab 1 Fundamentals of Measurement and Error Analysis 1.1 Overview This first laboratory exercise introduces key concepts and statistical and plotting tools that are used throughout the entire sequence
More informationAnalog Signals and Systems and their properties
Analog Signals and Systems and their properties Main Course Objective: Recall course objectives Understand the fundamentals of systems/signals interaction (know how systems can transform or filter signals)
More informationInstructor (Brad Osgood)
TheFourierTransformAndItsApplications-Lecture26 Instructor (Brad Osgood): Relax, but no, no, no, the TV is on. It's time to hit the road. Time to rock and roll. We're going to now turn to our last topic
More informationNotation, Matrices, and Matrix Mathematics
Geographic Information Analysis, Second Edition. David O Sullivan and David J. Unwin. 010 John Wiley & Sons, Inc. Published 010 by John Wiley & Sons, Inc. Appendix A Notation, Matrices, and Matrix Mathematics
More informationCSCI 239 Discrete Structures of Computer Science Lab 6 Vectors and Matrices
CSCI 239 Discrete Structures of Computer Science Lab 6 Vectors and Matrices This lab consists of exercises on real-valued vectors and matrices. Most of the exercises will required pencil and paper. Put
More informationLab Objective: Introduce some of the basic optimization functions available in the CVXOPT package
Lab 14 CVXOPT Lab Objective: Introduce some of the basic optimization functions available in the CVXOPT package Notebox: CVXOPT is not part of the standard library, nor is it included in the Anaconda distribution.
More informationChapter #4 EEE8086-EEE8115. Robust and Adaptive Control Systems
Chapter #4 Robust and Adaptive Control Systems Nonlinear Dynamics.... Linear Combination.... Equilibrium points... 3 3. Linearisation... 5 4. Limit cycles... 3 5. Bifurcations... 4 6. Stability... 6 7.
More informationCoordinate Curves for Trajectories
43 The material on linearizations and Jacobian matrices developed in the last chapter certainly expanded our ability to deal with nonlinear systems of differential equations Unfortunately, those tools
More informationCalculus and Differential Equations II
MATH 250 B Second order autonomous linear systems We are mostly interested with 2 2 first order autonomous systems of the form { x = a x + b y y = c x + d y where x and y are functions of t and a, b, c,
More informationComputer Problems for Methods of Solving Ordinary Differential Equations
Computer Problems for Methods of Solving Ordinary Differential Equations 1. Have a computer make a phase portrait for the system dx/dt = x + y, dy/dt = 2y. Clearly indicate critical points and separatrices.
More informationMatrix-Exponentials. September 7, dx dt = ax. x(t) = e at x(0)
Matrix-Exponentials September 7, 207 In [4]: using PyPlot INFO: Recompiling stale cache file /Users/stevenj/.julia/lib/v0.5/LaTeXStrings.ji for module LaTeXString Review: Solving ODEs via eigenvectors
More informationSolutions to Math 53 Math 53 Practice Final
Solutions to Math 5 Math 5 Practice Final 20 points Consider the initial value problem y t 4yt = te t with y 0 = and y0 = 0 a 8 points Find the Laplace transform of the solution of this IVP b 8 points
More informationUsing Microsoft Excel
Using Microsoft Excel Objective: Students will gain familiarity with using Excel to record data, display data properly, use built-in formulae to do calculations, and plot and fit data with linear functions.
More informationInfinite series, improper integrals, and Taylor series
Chapter 2 Infinite series, improper integrals, and Taylor series 2. Introduction to series In studying calculus, we have explored a variety of functions. Among the most basic are polynomials, i.e. functions
More informationLAB 1: MATLAB - Introduction to Programming. Objective:
LAB 1: MATLAB - Introduction to Programming Objective: The objective of this laboratory is to review how to use MATLAB as a programming tool and to review a classic analytical solution to a steady-state
More informationLecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9
Lecture Notes to Accompany Scientific Computing An Introductory Survey Second Edition by Michael T. Heath Chapter 9 Initial Value Problems for Ordinary Differential Equations Copyright c 2001. Reproduction
More informationPhysics 202 Laboratory 5. Linear Algebra 1. Laboratory 5. Physics 202 Laboratory
Physics 202 Laboratory 5 Linear Algebra Laboratory 5 Physics 202 Laboratory We close our whirlwind tour of numerical methods by advertising some elements of (numerical) linear algebra. There are three
More informationLeast squares and Eigenvalues
Lab 1 Least squares and Eigenvalues Lab Objective: Use least squares to fit curves to data and use QR decomposition to find eigenvalues. Least Squares A linear system Ax = b is overdetermined if it has
More informationf = Xw + b, We can compute the total square error of the function values above, compared to the observed training set values:
Linear regression Much of machine learning is about fitting functions to data. That may not sound like an exciting activity that will give us artificial intelligence. However, representing and fitting
More informationScientific Computing: An Introductory Survey
Scientific Computing: An Introductory Survey Chapter 9 Initial Value Problems for Ordinary Differential Equations Prof. Michael T. Heath Department of Computer Science University of Illinois at Urbana-Champaign
More informationA primer on matrices
A primer on matrices Stephen Boyd August 4, 2007 These notes describe the notation of matrices, the mechanics of matrix manipulation, and how to use matrices to formulate and solve sets of simultaneous
More informationInterpolation on the unit circle
Lecture 2: The Fast Discrete Fourier Transform Interpolation on the unit circle So far, we have considered interpolation of functions at nodes on the real line. When we model periodic phenomena, it is
More informationGetting Started with Communications Engineering
1 Linear algebra is the algebra of linear equations: the term linear being used in the same sense as in linear functions, such as: which is the equation of a straight line. y ax c (0.1) Of course, if we
More informationChapter 10 Analyzing Multivariable Change: Optimization
Chapter 10 Analyzing Multivariable Change: Optimization 10.2 Multivariable Optimization As you might expect, multivariable optimization techniques that you use with your TI-86 are very similar to those
More informationImage Processing in Numpy
Version: January 17, 2017 Computer Vision Laboratory, Linköping University 1 Introduction Image Processing in Numpy Exercises During this exercise, you will become familiar with image processing in Python.
More informationLectures about Python, useful both for beginners and experts, can be found at (http://scipy-lectures.github.io).
Random Matrix Theory (Sethna, "Entropy, Order Parameters, and Complexity", ex. 1.6, developed with Piet Brouwer) 2016, James Sethna, all rights reserved. This is an ipython notebook. This hints file is
More informationMath 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 informationDamped harmonic motion
Damped harmonic motion March 3, 016 Harmonic motion is studied in the presence of a damping force proportional to the velocity. The complex method is introduced, and the different cases of under-damping,
More informationSatellite project, AST 1100
Satellite project, AST 1100 Part 4: Skynet The goal in this part is to develop software that the satellite can use to orient itself in the star system. That is, that it can find its own position, velocity
More informationNonlinear Autonomous Systems of Differential
Chapter 4 Nonlinear Autonomous Systems of Differential Equations 4.0 The Phase Plane: Linear Systems 4.0.1 Introduction Consider a system of the form x = A(x), (4.0.1) where A is independent of t. Such
More informationMATH.2720 Introduction to Programming with MATLAB Vector and Matrix Algebra
MATH.2720 Introduction to Programming with MATLAB Vector and Matrix Algebra A. Vectors A vector is a quantity that has both magnitude and direction, like velocity. The location of a vector is irrelevant;
More informationENGI Linear Approximation (2) Page Linear Approximation to a System of Non-Linear ODEs (2)
ENGI 940 4.06 - Linear Approximation () Page 4. 4.06 Linear Approximation to a System of Non-Linear ODEs () From sections 4.0 and 4.0, the non-linear system dx dy = x = P( x, y), = y = Q( x, y) () with
More information9. Introduction and Chapter Objectives
Real Analog - Circuits 1 Chapter 9: Introduction to State Variable Models 9. Introduction and Chapter Objectives In our analysis approach of dynamic systems so far, we have defined variables which describe
More informationChapter 1, Section 1.2, Example 9 (page 13) and Exercise 29 (page 15). Use the Uniqueness Tool. Select the option ẋ = x
Use of Tools from Interactive Differential Equations with the texts Fundamentals of Differential Equations, 5th edition and Fundamentals of Differential Equations and Boundary Value Problems, 3rd edition
More informationHW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Prog
HW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Programming environment: Spyder. To implement this, do
More informationMITOCW watch?v=dztkqqy2jn4
MITOCW watch?v=dztkqqy2jn4 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationLab 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 informationA primer on matrices
A primer on matrices Stephen Boyd August 4, 2007 These notes describe the notation of matrices, the mechanics of matrix manipulation, and how to use matrices to formulate and solve sets of simultaneous
More information{ }. The dots mean they continue in that pattern to both
INTEGERS Integers are positive and negative whole numbers, that is they are;... 3, 2, 1,0,1,2,3... { }. The dots mean they continue in that pattern to both positive and negative infinity. Before starting
More informationMath 266: Phase Plane Portrait
Math 266: Phase Plane Portrait Long Jin Purdue, Spring 2018 Review: Phase line for an autonomous equation For a single autonomous equation y = f (y) we used a phase line to illustrate the equilibrium solutions
More informationBinary floating point
Binary floating point Notes for 2017-02-03 Why do we study conditioning of problems? One reason is that we may have input data contaminated by noise, resulting in a bad solution even if the intermediate
More informationAlgebraic. techniques1
techniques Algebraic An electrician, a bank worker, a plumber and so on all have tools of their trade. Without these tools, and a good working knowledge of how to use them, it would be impossible for them
More informationLinear 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 informationMATH 415, WEEKS 7 & 8: Conservative and Hamiltonian Systems, Non-linear Pendulum
MATH 415, WEEKS 7 & 8: Conservative and Hamiltonian Systems, Non-linear Pendulum Reconsider the following example from last week: dx dt = x y dy dt = x2 y. We were able to determine many qualitative features
More informationSCHOOL OF MATHEMATICS MATHEMATICS FOR PART I ENGINEERING. Self-paced Course
SCHOOL OF MATHEMATICS MATHEMATICS FOR PART I ENGINEERING Self-paced Course MODULE ALGEBRA Module Topics Simplifying expressions and algebraic functions Rearranging formulae Indices 4 Rationalising a denominator
More informationNumber Systems III MA1S1. Tristan McLoughlin. December 4, 2013
Number Systems III MA1S1 Tristan McLoughlin December 4, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/1558 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii
More informationNOTES ON LINEAR ALGEBRA CLASS HANDOUT
NOTES ON LINEAR ALGEBRA CLASS HANDOUT ANTHONY S. MAIDA CONTENTS 1. Introduction 2 2. Basis Vectors 2 3. Linear Transformations 2 3.1. Example: Rotation Transformation 3 4. Matrix Multiplication and Function
More informationDefinition of geometric vectors
Roberto s Notes on Linear Algebra Chapter 1: Geometric vectors Section 2 of geometric vectors What you need to know already: The general aims behind the concept of a vector. What you can learn here: The
More information1.2. Indices. Introduction. Prerequisites. Learning Outcomes
Indices 1.2 Introduction Indices, or powers, provide a convenient notation when we need to multiply a number by itself several times. In this Section we explain how indices are written, and state the rules
More informationMTH 306 Spring Term 2007
MTH 306 Spring Term 2007 Lesson 3 John Lee Oregon State University (Oregon State University) 1 / 27 Lesson 3 Goals: Be able to solve 2 2 and 3 3 linear systems by systematic elimination of unknowns without
More informationDef. (a, b) is a critical point of the autonomous system. 1 Proper node (stable or unstable) 2 Improper node (stable or unstable)
Types of critical points Def. (a, b) is a critical point of the autonomous system Math 216 Differential Equations Kenneth Harris kaharri@umich.edu Department of Mathematics University of Michigan November
More informationDifferential Equations
Electricity and Magnetism I (P331) M. R. Shepherd October 14, 2008 Differential Equations The purpose of this note is to provide some supplementary background on differential equations. The problems discussed
More informationEigenvalues and eigenvectors
Roberto s Notes on Linear Algebra Chapter 0: Eigenvalues and diagonalization Section Eigenvalues and eigenvectors What you need to know already: Basic properties of linear transformations. Linear systems
More informationNonlinear dynamics & chaos BECS
Nonlinear dynamics & chaos BECS-114.7151 Phase portraits Focus: nonlinear systems in two dimensions General form of a vector field on the phase plane: Vector notation: Phase portraits Solution x(t) describes
More informationAugust 7, 2007 NUMERICAL SOLUTION OF LAPLACE'S EQUATION
August 7, 007 NUMERICAL SOLUTION OF LAPLACE'S EQUATION PURPOSE: This experiment illustrates the numerical solution of Laplace's Equation using a relaxation method. The results of the relaxation method
More informationStructural Geology, GEOL 330 Spring 2012
Developing the Magic Eye for folds This lab exercise is designed to get you thinking about the chronology of structural processes and and the resultant map patterns in areas with flat topography. You may
More informationLecture 6: Backpropagation
Lecture 6: Backpropagation Roger Grosse 1 Introduction So far, we ve seen how to train shallow models, where the predictions are computed as a linear function of the inputs. We ve also observed that deeper
More informationLooking Ahead to Chapter 10
Looking Ahead to Chapter Focus In Chapter, you will learn about polynomials, including how to add, subtract, multiply, and divide polynomials. You will also learn about polynomial and rational functions.
More informationMAT 22B - Lecture Notes
MAT 22B - Lecture Notes 4 September 205 Solving Systems of ODE Last time we talked a bit about how systems of ODE arise and why they are nice for visualization. Now we'll talk about the basics of how to
More informationCS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations
Lecture slides based on the textbook Scientific Computing: An Introductory Survey by Michael T. Heath, copyright c 2018 by the Society for Industrial and Applied Mathematics. http://www.siam.org/books/cl80
More informationDesigning Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way
EECS 16A Designing Information Devices and Systems I Fall 018 Lecture Notes Note 1 1.1 Introduction to Linear Algebra the EECS Way In this note, we will teach the basics of linear algebra and relate it
More informationSpatial Data Analysis in Archaeology Anthropology 589b. Kriging Artifact Density Surfaces in ArcGIS
Spatial Data Analysis in Archaeology Anthropology 589b Fraser D. Neiman University of Virginia 2.19.07 Spring 2007 Kriging Artifact Density Surfaces in ArcGIS 1. The ingredients. -A data file -- in.dbf
More informationAstronomy Using scientific calculators
Astronomy 113 - Using scientific calculators 0. Introduction For some of the exercises in this lab you will need to use a scientific calculator. You can bring your own, use the few calculators available
More informationIntroduction to Python
Introduction to Python Luis Pedro Coelho Institute for Molecular Medicine (Lisbon) Lisbon Machine Learning School II Luis Pedro Coelho (IMM) Introduction to Python Lisbon Machine Learning School II (1
More informationUsing web-based Java pplane applet to graph solutions of systems of differential equations
Using web-based Java pplane applet to graph solutions of systems of differential equations Our class project for MA 341 involves using computer tools to analyse solutions of differential equations. This
More informationLS.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