7/31/2019 SSG 314 Lists & Other Structures
1/26
Lists & Other StructuresSets, vectors, matrices and tensors
7/31/2019 SSG 314 Lists & Other Structures
2/26
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 andacted upon in specific ways.
Formally, we say these are structured data.
Structuring Data
7/31/2019 SSG 314 Lists & Other Structures
3/26
Other structures occur in tensor calculus, set theory,
graph theory, etc. In many cases, these structures behave in peculiar
ways. For computational purposes, these areencapsulated 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.
Other Structures
7/31/2019 SSG 314 Lists & Other Structures
4/26
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.
List as the fundamental structure
7/31/2019 SSG 314 Lists & Other Structures
5/26
Generating Lists
7/31/2019 SSG 314 Lists & Other Structures
6/26
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 cansee from the cookbook.
In addition to these, lists can be amended byfunctions created for that purpose.
List Generation
7/31/2019 SSG 314 Lists & Other Structures
7/26
Amending Lists
7/31/2019 SSG 314 Lists & Other Structures
8/26
Other commands are used to analyse and take listsapart. Some of these commands are used to extractparts of lists:
Part, First, Last, Rest, Most, Take, Drop, Select, CasesReverse, RotateLeft, RotateRight, Flatten, Partition,Transpose, and Sort
Consider Take and Drop:
Analysing Lists
7/31/2019 SSG 314 Lists & Other Structures
9/26
In Mathematica, A set is a list. In conformity with the
mathematical definition of a set, the elements areunique so that duplicates are eleminated when setoperations such as Union, Intersection or Complimentare applied to them.
You can also check if a particular element belongs to aset. The set itself can be a set of scalars or of lists.
Sets
7/31/2019 SSG 314 Lists & Other Structures
10/26
There are several set operations that can be
performed by in-built functions. In the examplesbelow, we generate all the subsets of a particular setand later check if a specific element belongs to aparticular defined set:
Set Operations
7/31/2019 SSG 314 Lists & Other Structures
11/26
A Tensor is a more complicated structure as a matrix.
For the purpose of this course we consider a matrixto be a second order tensor. This is a defectivedefinition but will serve our purpose.
Higher order tensors can be created by adding more
dimensions to our table as before. Try this:
Matrix and Tensor Functions
7/31/2019 SSG 314 Lists & Other Structures
12/26
The contraction operation can be performed on
Vectors, matrices and tensors. It is up tp theprogrammer to ensure that these products makesense and that what you are getting out ofMathematica is not simply garbage:
Matrix & Tensor Operations
7/31/2019 SSG 314 Lists & Other Structures
13/26
Mathematica Generalizes the Inner Product in a
powerful way. The easiest way to understand this isto compare it to the Dot product already seen:
Inner Product
7/31/2019 SSG 314 Lists & Other Structures
14/26
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:
Inner Product
7/31/2019 SSG 314 Lists & Other Structures
15/26
Sorting a list of scalars is a very simple matter.
Mathematica sorts in ascending order. The Greaterargument can be used to change that default todescending if so desired,:
Sorting
7/31/2019 SSG 314 Lists & Other Structures
16/26
Study the example on page 98 to get a better grasp
on an application of list sorting.
Sorting Lists
7/31/2019 SSG 314 Lists & Other Structures
17/26
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 thecomputation of matrix and tensor functions that arevery useful in this area.
For this, let us recap on some basic definition fromlinear algebra:
Trace The sum of the elements on the diagonal
Matrix Analysis
7/31/2019 SSG 314 Lists & Other Structures
18/26
There are three invariants of a 3 by 3 matrix. Trace,
Square of the trace minus the trace of the square, andthe determinant.
The characteristics values of a matrix are called theeigenvalues. Check from you math books how togenerate the eigenvalues.
A matrix whose eigenvalues are positive is said to bepositive definite. Many matrices (actually tensors) ofengineering importance are positive definite.
Properties
7/31/2019 SSG 314 Lists & Other Structures
19/26
Mathematica can be used to compute the
eigenvalues and eigenvectors of your tensor directly.
Properties
7/31/2019 SSG 314 Lists & Other Structures
20/26
Take the simple example of a 3 by 3 tensor F with a
non-vanishing determinant. The polar decompositiontheorem states that there is a rotation tensor R(Determinant = +1) and positive definite tensors U andV such that
F=RU=VR Given a tensor F, the homework is to find the tensors
R, U and V
Tensor Decompositions
7/31/2019 SSG 314 Lists & Other Structures
21/26
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.
Right and left tensors
7/31/2019 SSG 314 Lists & Other Structures
22/26
1. Given that =
1
3
2
4
3
0 1 0
0 0 1
Find the rotation tensor, the right stretch tensor and theleft stretch tensor. Demonstrate that the Rotation tensor
is true orthogonal.
Homework
7/31/2019 SSG 314 Lists & Other Structures
23/26
Find the eigenvalues and eigenvectors of C
Demonstrate numerically that the eigenvalues of Band C are the same.
Demonstrate that the eigenvectors of C and U are thesame
Show that the eigenvectors of B and V are the same.
Show that the determinant of each tensor is simplythe product of the eigenvalues.
HW Continued
7/31/2019 SSG 314 Lists & Other Structures
24/26
2. Explain the meaning of the program:
HW continued
7/31/2019 SSG 314 Lists & Other Structures
25/26
Find C, B, R, U, V as in the previous problem in this
case also.
7/31/2019 SSG 314 Lists & Other Structures
26/26
Spectral Decomposition
Top Related