Applied Mathematics & Engineering Numericals
(AMEN)
M. Sc. Anoj Winston
Lehrstuhl CVT Gladius
BCI – TU Dortmund
Prof. Dr. D. W. Agar
02/04/2020
Motivation
▪ Topics found challenging?
▪ Topics unclear/skipped in lectures/exam preparations
▪ Not just Reaction Engineering, Chemical Engineering in
general
▪ Ever wondered why something works/how something works
w.r.t solvers and calculation methods
▪ Course will not be answering every such question
▪ Merely a guidance as to how to search for answers
▪ A way to preach Mathematics as a way of looking at
Engineering problems and solving them logically
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -2-
(AMEN)
How will this course help me?
▪ Equipping you with techniques to tackle basic mathematical
problems
▪ Increasing the fundamental understanding of mathematical
problems
▪ Understanding how mathematics and engineering are
simultaneously different and similar
▪ How and when to appproach a situation with both tools and
use the best available combination to solve a problem
▪ Solve problems in general rather than emphasising individual
problems and theory behind them
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -3-
(AMEN)
How to ace this course
▪ Register for the course and submit the final assignment – get a grade
-???
▪ No attendance – no one but yourself should care about your grades –
if you don‘t come very well – all of our times saved
▪ Those who come – it will be made worth their time
▪ No substitute for smart work and experience – more time spent
thinking about such problems – better you become at solving them –
get a better grade
▪ Lectures and tutorials – guidance as to how problems could be
solved and discussions regarding different solutions if it applies
▪ Participation and discussions encouraged – new problem ideas / old
unsolved problems always welcome – could be tried in class
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -4-
(AMEN)
MATLAB is an integrated technical computing environment that
combines numeric computation, advanced graphics and
visualization, and a high level programming language
-The MathWorks, Inc.
Widely used for,
▪ Math and computation
▪ Algorithm development
▪ Modeling, simulation, and prototyping
▪ Data analysis, exploration, and visualization
▪ Scientific and engineering graphics
▪ Application development, including Graphical User Interface building
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -5-
(AMEN)
Course Contents
▪ Basic linear Algebra (Simple Vector and Matrix operations)
▪ Setting up the equations, analytical and numerical solutions
▪ Linear and non linear-equations and matrices
▪ Matrix inversions – Rank and Gaussian elimination
▪ Solution using non-linear iterators
▪ Simple ODEs, Coupled ODEs, simple PDEs, Coupled PDEs
▪ Solution using inbuilt solvers and self coded numerical solvers
(Backward, Forward and central difference methods with shooting)
▪ Critical thinking and error debugging in complex problem steps
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -6-
(AMEN)
Course Contents
Date Time Course contents
02.04.2020 12:00-13:30 Introduction to MATLAB, Vector and Matrix algebra
07.04.2020 10:00-11:30 Functions and its scope
09.04.2020 12:00-13:30 Functions (cont.), Loops
14.04.2020 10:00-11:30 Interpolation and Plotting
16.04.2020 12:00-13:30 Data extraction (Grabit )
21.04.2020 10:00-11:30 Matrix Operations, Solving system of linear equations
23.04.2020 12:00-13:30 Flowsheet Balancing
28.04.2020 10:00-11:30 fsolve() basics
30.04.2020 12:00-13:30 Solving system of non-linear equations
05.05.2020 10:00-11:30 Solving system of linear and non-linear equations
07.05.2020 12:00-13:30 Solving system of linear and non-linear equations
12.05.2020 10:00-11:30 Numerical Solutions for simple ODE's (Forward, Backward difference)
14.05.2020 12:00-13:30 Shooting method
19.05.2020 10:00-11:30 Shooting method (cont.), Runge Kutta method
21.05.2020 12:00-13:30 Holiday
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -7-
(AMEN)
Course Contents
26.05.2020 10:00-11:30 Runge Kutta method (cont.)
28.05.2020 12:00-13:30 Solving Coupled ODE's - Battle of Trafalgar problem
02.06.2020 10:00-11:30 Solving Coupled ODE's (cont.)
04.06.2020 12:00-13:30 Solving higher order ODE - RK and Shooting
09.06.2020 10:00-11:30 Solving higher order ODE - RK and Shooting
11.06.2020 12:00-13:30 Holiday
16.06.2020 10:00-11:30 Introduction to PDE's
18.06.2020 12:00-13:30 Solving 1-D PDE: Finite differences and Orthogonal Collocation
23.06.2020 10:00-11:30 Solving 1-D PDE: Finite differences and Orthogonal Collocation
25.06.2020 12:00-13:30 Solving 1-D PDE: Finite differences and Orthogonal Collocation
30.06.2020 10:00-11:30 Solving coupled PDE's
02.07.2020 12:00-13:30 Solving coupled PDE's
07.07.2020 10:00-11:30 Solving coupled PDE's
09.07.2020 12:00-13:30 Extra class (if necessary)
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -8-
(AMEN)
Introduction
▪ Command window is where you type the command and
instructions
▪ Current folder is the directory where you can save your work
▪ Workspace is where all the variables in the MATLAB’s current
session are stored and accessed
▪ Editor window is where you create and debug scripts and
function files
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 -9-
(AMEN)
Introduction
▪ Creating MATLAB variables:
• Assignment operator (=) is used to assign value to a variable
• Variables are case-sensitive
• Variable name can be used instead of value in further operations
▪ Overwriting can be done by reassigning to the same variable
▪ Semi-colon( ; ) is used to suppress the numerical output
▪ “clc” command is used to clear the command window
▪ “clear all” is used to clear the variables from the workspace
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 10 -
(AMEN)
Basic mathematical functions
➢ sqrt(m) => returns the square root of m
➢ exp(m) => returns the exponential em
➢ log(m) => returns the natural logarithm ln(m)
➢ log10(m) => returns the common logarithm to the base 10
➢ factorial(m) => returns the product of all positive integers less
than or equal to m, where m is a nonnegative integer value
➢ sin(x) => sine of argument in radians
➢ sind(x) => sine of argument in degrees
➢ round(x) => rounds to the nearest integer
➢ rem(x,y) => returns the remainder after division of x by y
m can be a scalar or an array. In case of arrays, the operations are carried element by
element
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 11 -
(AMEN)
Basic mathematical functions
➢ acsc(x) => returns inverse cosecant in radians
➢ acscd(x) => returns inverse cosecant in degrees
➢ deg2rad => convert angle from degrees to radians
➢ rad2deg => convert angle from radians to degrees
➢ round(x,n) rounds to n digits:
• n > 0: round to n digits to the right of the decimal point
• n = 0: round to the nearest integer
• n < 0: round to n digits to the left of the decimal point
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 12 -
(AMEN)
MATLAB as calculator
▪ Find the value of the “y” in the following expressions
rounded to 2 decimal places:
2
1 (𝑎+𝑏 )
• 1. 𝑦 = +𝑒 ; a = 2 and b = 0.02
𝑎
sin ϴ
• 2. 𝑦 = 𝑒 𝑎 . + 𝑒 −𝑎 ; a=2 ; b=30 and ϴ = 45o
ln 𝑏
𝑎 sin−1 0.5+𝑏𝑐𝑜𝑠 −1 0.5
• 3. 𝑦 = ; a = 24 and b = 48
2𝑎
3
1 1 1−𝑎
𝑇2 + ln1−𝑏
𝑀1 𝑀2
• 4. 𝑦 = ; a = -1.5; b = 0.5; M1=28;M2=44;T=273
𝑎2
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 13 -
(AMEN)
Vector and Matrix Algebra
▪ Vector (1D array) : an array/set of numbers in one horizontal
row or in one vertical column
• a = [1,2,3] => row vector
• b = [5;6;7] => column vector
▪ Matrix (2D array): an array with m rows and n columns
• c = [1 2 3 4;5 6 7 8] => 2 x 4 matrix
• d = [9 5 6; 5 3 9; 4 8 1] => 3 x 3 matrix
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 14 -
(AMEN)
Vector and Matrix Algebra
➢ Command for array and matrices
• zeros(1,n) => returns a row vector with n zeros
• zeros(m,n) => returns an m x n matrix of 0’s
• ones(n) => returns an n x n matrix of 1’s
• eye(n) => returns an identity matrix of size n x n
• length(x) => returns the number of elements in an array
• size(x) => returns a row vector whose elements are the
lengths of the corresponding dimensions of A
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 15 -
(AMEN)
Vector and Matrix Algebra
▪ Addition, subtraction, multiplication and division of
vectors/matrix with a scalar or with a vector/matrix of same
size
• “*” operator for scalar or matrix multiplication
• “.*” operator for element-by-element vector multiplication
• “/” operator for scalar or matrix division
• “./” operator for element-by-element vector division
▪ Transpose operation
• A.' returns the non-conjugate transpose of A matrix
• A' can also be used as it produces same result for real values,
incase of complex number it gives conjugate transpose of A
matrix
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 16 -
(AMEN)
Vector and Matrix Algebra
▪ Array indexing
Consider a matrix A,
A = 11 12 13 14
26 42 56 89
45 39 78 12
20 99 10 36
➢ Command:
• To access an element at mth row and nth column from the matrix A,
h=A(m,n)
Example: h=A(3,2) gives h=39
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 17 -
(AMEN)
Vector and Matrix Algebra
▪ To access elements in a range of rows or columns, use
the colon(:)
• To access elements in all columns of row n of matrix A,
row vector, r = A(n,:)
• To access elements in all rows of column n of matrix A,
column vector, c = A(:,n)
• To access all rows between columns m and n,
b = A(:,m:n)
• To access all columns between rows m and n,
u = A(m:n,:)
Example: To access a specific sub matrix from matrix A,
p = A(2:3,1:3) => p = 26 42 56
45 39 78
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 18 -
(AMEN)
Vector and Matrix Algebra
▪ Linear indexing:
• Accessing the elements of a matrix with single subscript
1 5 9 13
A= 2
11
6
12
10
13
14
14
26 42 56 89
3 7 11 15
45 39 78 12
4 8 12 16
20 99 10 36
• The linear index of each element is shown on the top left
• MATLAB stores the matrix as a single column with individual
columns appended at the last
• Here, the element A(3,3) = A(11)
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 19 -
(AMEN)
Vector and Matrix Algebra
▪ find(x) => returns a vector containing the linear indices of each
nonzero element in array x.
• If x is a vector, then find returns a vector with the same orientation as x
• If x is a multidimensional array, then find returns a column vector of the
linear indices of the result
• If x contains no nonzero elements or is empty, then find returns an empty
array
▪ find(x,n) => returns the first n indices corresponding to the nonzero
elements in x
▪ find(x==m) => return the index of the element equal to m
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 20 -
(AMEN)
Vector and Matrix Algebra
▪ Generate a 3 x 3 matrix (A) with row vectors [1 4 7], [7 14 31] and
[43 10 19]
▪ Generate a 3x3 matrix with two’s and add with A matrix resulting in
matrix B
▪ Generate a 3x3 matrix C by dividing B matrix element by element with
matrix E with column vectors [3;3;5],[2;8;6],[1;11;7]
▪ Generate a 3x3 identity matrix (D) and multiply it with a scalar value 4
▪ First, concatenate matrix A and B, matrix C and D separately and
combine then to form a 6x6 matrix
▪ Extract a 4x4 sub-matrix at the center , find the transpose of it and then
find the value of the element in 4th row and 2nd column
Applied Mathematics & Engineering Numericals
Anoj Winston Gladius| 01.04.2020 - 21 -
(AMEN)