Lecture 1
Lecture 1
1
Lecturer : Dr. Mahar Diana Hamid
Email : mahar.diana@um.edu.my
Tel. No. : 03-79675295
Office : G11, Ground Floor, Block V
2
Class schedule
Day Time Location
Tuesday 3.00 pm– 4.00 pm BKK3/4 or ECC4/ECC5
Friday 10.00 am – 12.00 pm BKK3/4 or ECC4/ECC5
3
Course Outcomes (VERY IMPORTANT)
1. Describe the numerical methods used for root finding, linear
and non-linear equations, integration, differentiation, ordinary
& partial differential equations (ODE & PDE) and optimisation
problems.
2. Solve problems manually related to roots finding, linear and
non-linear equations, integration, differentiation, ODE, PDE
and optimisation problems using appropriate numerical
method.
3. Write computer programs for root finding, linear and non-linear
equations, integration, differentiation, ODE and PDE.
4
Components of the course
Algorithmic aspects of
numerical methods
Practical use
Applications
of Matlab
5
References
1. S.C. Chapra & R.P. Canale.
“Numerical Methods for
Engineers”, McGraw-Hill. 7th Extra notes
Edition, 2015.
RM124.80
Exercises
6
› Two important rules to talk/write to me:
1. Make sure you thought about the problem and have some
analysis to offer together with your question
2. Make sure you can explain you problem or make the question
in one-two sentences.
› Student with less than 80% attendance will be barred from
examination.
7
• Notes, assignments, solutions, grades etc. will be posted on
SPECTRUM.
http://spectrum.um.edu.my
Please print the notes yourself before coming to the class.
Homework:
All work will be performed in class. Homework will be assigned
only if students run out of time.
8
Assessment
› Continous assessment : 50%
– Tests
› Test 1 – Week 8 (20%) MATLAB
› Test 2 – Week 14 (20%)
– Mini project submitted at Week 14 (10%)
Mini project will be submitted in groups (5 students per group)
› Final examination: 50% (Closed-book) –All theories and hand
calculations
10
Introduction
• Numerical methods are techniques
by which mathematical problems
are formulated so that they can be
solved with arithmetic operations.
• Requires understanding of
engineering systems
• By observation and experiment
• Theoretical analysis and
generalization
• Computers are great tools,
however, without fundamental
understanding of engineering
problems, they will be useless.
11
› A mathematical model is represented as a functional relationship of
the form
14
Fig.2.2
› Sequence.
Computer code
must be
implemented one
instruction at a
time, unless you
instruct otherwise.
The structure can
be expressed as a
flowchart or
pseudocode.
15
Fig. 2.3
16
› Repetition. A means to implement instructions repeatedly.
Fig. 2.4
17
Fig. 2.5
18
Figure 2.6
19
Modular Programming
› The computer programs can be
divided into subprograms, or
modules, that can be developed and
tested separately.
› Modules should be as independent
and self contained as possible.
› Advantages to modular design are:
– It is easier to understand the underlying
logic of smaller modules
– They are easier to debug and test
– Facilitate program maintenance and
modification
– Allow you to maintain your own
library of modules for later use
20
EXCEL
› Is a spreadsheet that allow the user to enter and perform calculations on
rows and columns of data.
› When any value on the sheet is changed, entire calculation is updated,
therefore, spreadsheets are ideal for “what if?” sorts of analysis.
› Excel has some built in numerical capabilities including equation solving,
curve fitting and optimization.
› It also includes VBA as a macro language that can be used to implement
numerical calculations.
› It has several visualization tools, such as graphs and three dimensional plots.
21
Fig. 2.8
22
MATLAB
› Is a flagship software which was originally developed as a matrix
laboratory. A variety of numerical functions, symbolic
computations, and visualization tools have been added to the
matrix manipulations.
› MATLAB is closely related to programming.
Others
› Fortran 90 (IMSL)
› C++
23
Fig. 2.9
24
Approximations and Round-Off Errors
› For many engineering problems, we cannot obtain analytical solutions.
› Numerical methods yield approximate results, results that are close to the
exact analytical solution. We cannot exactly compute the errors associated
with numerical methods.
– Only rarely given data are exact, since they originate from measurements. Therefore
there is probably error in the input information.
– Algorithm itself usually introduces errors as well, e.g., unavoidable round-offs, etc …
– The output information will then contain error from both of these sources.
› How confident we are in our approximate result?
› The question is “how much error is present in our calculation and is it
tolerable?”
25
Fig. 3.2
26
Significant Figures
› Number of significant figures indicates precision. Significant digits of a
number are those that can be used with confidence, e.g., the number of
certain digits plus one estimated digit.
Zeros are sometimes used to locate the decimal point not significant figures.
0.00001753 4
0.0001753 4
0.001753 4
27
MATLAB
› Short for MATrix Advantages:
LABoratory
1. Ease of use
› Optimized to perform
engineering and 2. Platform
scientific calculations. independence
› Initially designed to 3. Pre-defined functions
perform matrix 4. Device-independent
mathematics
plotting
› Provides a very
5. MATLAB Compiler
extensive library of
predefined functions to Disadvantages:
make technical
programming tasks 1. Interpreted language
easier and more – execute more 28
MATLAB Environment: MATLAB Desktop
The MATLAB
Workspace
Stores the
The Command Window: variable name
User can enter interactive commands at the and value
command prompt (>>) and it will be executed
on the spot. The Command
It is easier to use script files / M-files History Window
Displays the
commands that
user has entered
29
Getting Help
› Help Browser Other Important Functions
› Type help on the › Type demo to run
command window MATLAB’s built-in
› Using lookfor command demonstrations.
› clc : clear the Command
Window’s content.
› clear : clear the variables
in the Workspace
› abort command by typing
control-c
30
Important Programming Pitfalls
› Never use a variable with the same name as a MATLAB
function or command. If you do so, that function or
command will become inaccessible.
› If there is more than one function or command with the
same name, the first one found on the search path will be
executed.
› Never create an M-file with the same name as a MATLAB
function or command.
31