0% found this document useful (0 votes)
19 views31 pages

Lecture 1

The document provides information about the KIL1005: Numerical Methods for Engineering course. It outlines the course details including the lecturer, class schedule, course outcomes, assessment components and introduction. Numerical methods are techniques to solve mathematical problems using computers and programming. Structured programming and modular design help develop efficient codes.

Uploaded by

haqeemifarhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views31 pages

Lecture 1

The document provides information about the KIL1005: Numerical Methods for Engineering course. It outlines the course details including the lecturer, class schedule, course outcomes, assessment components and introduction. Numerical methods are techniques to solve mathematical problems using computers and programming. Structured programming and modular design help develop efficient codes.

Uploaded by

haqeemifarhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

KIL1005: Numerical Methods for Engineering

Semester 2, Session 2022/2023


Lecture W1
14/3/2023 & 15/3/2023

Dr. Mahar Diana Hamid


Department of Chemical Engineering
Universiti Malaya

1
Lecturer : Dr. Mahar Diana Hamid
Email : mahar.diana@um.edu.my
Tel. No. : 03-79675295
Office : G11, Ground Floor, Block V

Before you come to see me, please set up an


appointment!

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

2. H. Moore. “MATLAB for


Engineers”, Prentice-Hall, 3rd Exam
Edition, 2012. questions
Tutorials
(adapted)

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

Tips: Refer to previous paper of KIL1005 for general format etc.


9
First Homework
› Update your picture in the spectrum’s website
› Download MATLAB from MAYA

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

Dependent independent forcing


Variable =f variables, parameters, functions

› Dependent variable: Characteristic that usually reflects the state of


the system
› Independent variables: Dimensions such as time and space along
which the systems behavior is being determined
› Parameters: reflect the system’s properties or composition
› Forcing functions: external influences acting upon the system
1-12
Programming and Software
› Objective is how to use the computer as a › To be able to perform engineering-oriented
tool to obtain numerical solutions to a numerical calculations, you should be
given engineering model. There are two familiar with the following programming
ways in using computers: topics:
– Use available software – Simple information representation
– Or, write computer programs to extend (constants, variables, and type
the capabilities of available software, declaration)
such as Excel and Matlab. – Advanced information representation
(data structure, arrays, and records)
› Engineers should not be tool limited, it is
important that they should be able to do – Mathematical formulas (assignment,
both! priority rules, and intrinsic functions)
– Input/Output
› Computer programs are set of instructions
that direct the computer to perform a – Logical representation (sequence,
certain task. selection, and repetition)
– Modular programming (functions and
subroutines)
13
Structured Programming
› Structured programming is a set
of rules that prescribe god style
habits for programmer.
– An organized, well structured code
– Easily sharable
– Easy to debug and test
– Requires shorter time to develop,
test, and update
› The key idea is that any
numerical algorithm can be
composed of using the three
fundamental structures:
– Sequence, selection, and repetition

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

› Selection. Splits the


program’s flow into
branches based on
outcome of a
logical condition.

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

› Accuracy. How close is a


computed or measured value to
the true value
› Precision (or reproducibility).
How close is a computed or
measured value to previously
computed or measured values.
› Inaccuracy (or bias). A
systematic deviation from the
actual value.
› Imprecision (or uncertainty).
Magnitude of scatter.

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.

53,800 How many significant figures?


5.38 x 104 3
5.380 x 104 4

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

You might also like