Вы находитесь на странице: 1из 26

Lists & Other Structures

Sets, vectors, matrices and tensors

Structuring Data
Engineering students at this level are familiar with vectors and matrices. From a computational point of view, these are different from scalars in two ways:
They contain more than one scalar value They are organized in a way that they can be stored and acted upon in specific ways.

Formally, we say these are structured data.

Other Structures
Other structures occur in tensor calculus, set theory, graph theory, etc. In many cases, these structures behave in peculiar ways. For computational purposes, these are encapsulated in descriptive algorithms that can be bound with the data. Abstract Data types such as classes in OOP can be used to create these bindings as we shall see later.

List as the fundamental structure


In Mathematica, the fundamental data structure is the list. The list is already endued with basic algorithms for processing. Other structures can be built with additional processing algorithms.

Generating Lists

List Generation
These, in addition to some of the simple matrix examples we have seen earlier are generated lists. There are other list-creating functions such as Array and other more verbose iterative methods as you can see from the cookbook. In addition to these, lists can be amended by functions created for that purpose.

Amending Lists

Analysing Lists
Other commands are used to analyse and take lists apart. Some of these commands are used to extract parts of lists: Part, First, Last, Rest, Most, Take, Drop, Select, Cases Reverse, RotateLeft, RotateRight, Flatten, Partition, Transpose, and Sort Consider Take and Drop:

Sets
In Mathematica, A set is a list. In conformity with the mathematical definition of a set, the elements are unique so that duplicates are eleminated when set operations such as Union, Intersection or Compliment are applied to them. You can also check if a particular element belongs to a set. The set itself can be a set of scalars or of lists.

Set Operations
There are several set operations that can be performed by in-built functions. In the examples below, we generate all the subsets of a particular set and later check if a specific element belongs to a particular defined set:

Matrix and Tensor Functions


A Tensor is a more complicated structure as a matrix. For the purpose of this course we consider a matrix to be a second order tensor. This is a defective definition but will serve our purpose. Higher order tensors can be created by adding more dimensions to our table as before. Try this:

Matrix & Tensor Operations


The contraction operation can be performed on Vectors, matrices and tensors. It is up tp the programmer to ensure that these products make sense and that what you are getting out of Mathematica is not simply garbage:

Inner Product
Mathematica Generalizes the Inner Product in a powerful way. The easiest way to understand this is to compare it to the Dot product already seen:

Inner Product
In the first example, we have the well-known dot product or contraction. In the second, the actual operation has been slightly modified. Inner product is far more generalized:

Sorting
Sorting a list of scalars is a very simple matter. Mathematica sorts in ascending order. The Greater argument can be used to change that default to descending if so desired,:

Sorting Lists
Study the example on page 98 to get a better grasp on an application of list sorting.

Matrix Analysis
A 3 by 3 matrix is very useful in Continuum mechanics that spans the entire scope of Engineering science. This section is for you to get familiar with the computation of matrix and tensor functions that are very useful in this area. For this, let us recap on some basic definition from linear algebra: Trace The sum of the elements on the diagonal

Properties
There are three invariants of a 3 by 3 matrix. Trace, Square of the trace minus the trace of the square, and the determinant. The characteristics values of a matrix are called the eigenvalues. Check from you math books how to generate the eigenvalues. A matrix whose eigenvalues are positive is said to be positive definite. Many matrices (actually tensors) of engineering importance are positive definite.

Properties
Mathematica can be used to compute the eigenvalues and eigenvectors of your tensor directly.

Tensor Decompositions
Take the simple example of a 3 by 3 tensor F with a non-vanishing determinant. The polar decomposition theorem states that there is a rotation tensor R (Determinant = +1) and positive definite tensors U and V such that F=RU=VR Given a tensor F, the homework is to find the tensors R, U and V

Right and left tensors


C=FF and B=FF are the right and left tensors derived from C. Tensor U is such that UU=C so that U is the square root of the tensor C. The Mathematica function MatrixPower can be used to find U once C is known.

Homework

1. Given that

1 0 0

3 2

4 3

1 0

0 1

Find the rotation tensor, the right stretch tensor and the left stretch tensor. Demonstrate that the Rotation tensor is true orthogonal.

HW Continued
Find the eigenvalues and eigenvectors of C Demonstrate numerically that the eigenvalues of B and C are the same. Demonstrate that the eigenvectors of C and U are the same Show that the eigenvectors of B and V are the same. Show that the determinant of each tensor is simply the product of the eigenvalues.

HW continued
2. Explain the meaning of the program:

Find C, B, R, U, V as in the previous problem in this case also.

Spectral Decomposition

Вам также может понравиться