Sie sind auf Seite 1von 44

TEKNIK KOMPUTASI

(TEI 116)
3 SKS
Oleh: Husni Rois Ali, S.T., M.Eng.
Noor Akhmad Setiawan, S.T., M.T., Ph.D.

Email : husni.rois.ali@ugm.ac.id or
husni.rois.ali@gmail.com
Personal web: husniroisali.staff.ugm.ac.id


Grading
First Half (tentative)
Midterm (80%)
Homework, quiz, etc. (20%)
Second Half (?)
References:
Numerical Methods for Engineers, Sixth Edition
by Steven Chapra (Author), Raymond
Canale (Author)
http://numericalmethods.eng.usf.edu

What are we going to learn?
Finding the root of the equations i.e. solve for





Linear algebraic equation i.e. given and solve
( ) 0 f x =
x
2
3 2 0 x x + =
' a s ' b s
What are we going to learn? (2)
Curve fitting



Integration
What are we going to learn? (3)
Ordinary differential equations (ODE)



Partial differential equation
Analytic vs Numerical Approach
Analytic
You obtain the exact
solution
It is single step
There is no error (since it is
exact)
Normally used for simple
problem
This is how you work

Numerical
You obtain approximate
solution
It is an iterative approach
The error is a crucial factor
Used for complex problems
This is how your computer
and all computational
software works
Analytic vs. Numerical Approach (2)
suppose you want to find the roots of 2
Analytic
Formulate to mathematical
equation
Factorize

Then

Numerical
Formulate to mathematical
equation
Start from an arbitrary initial
value of , e.g.
You update the value of to
better approximation, until you
close enough




How you move from one point to
another depends on the the
algorithm

2
( ) 2 0 f x x = =
( 2)( 2) 0 x x + =
2 x =
2
( ) 2 0 f x x = =
x
0
1 x =
x
Introduction
Mathematical Modeling and Engineering Problem solving

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.


1-11
A mathematical model is represented as a functional
relationship of the form

Dependent independent forcing
Variable = f variables, parameters, functions

It ranges from a simple equation to very complex ones
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 systems properties or composition
Forcing functions: external influences acting upon the system



Newtons 2
nd
law of Motion
The model is formulated as
F = m a
F=net force acting on the body (N)a forcing
function
m=mass of the object (kg) a parameter
a=its acceleration (m/s
2
) -> the dependent variable


Formulation of Newtons 2
nd
law has several
characteristics that are typical of mathematical
models of the physical world:
It describes a natural process or system in
mathematical terms
It represents an idealization and simplification of
reality
Finally, it yields reproducible results,
consequently, can be used for predictive purposes.

1-14
Some mathematical models of physical phenomena
may be much more complex.
Complex models may not be solved exactly or
require more sophisticated mathematical techniques
than simple algebra for their solution

Example, modeling of a falling parachutist:




with , and
D U D U
dv F
dt m
F F F F mg F cv
dv mg cv
dt m
dv c
g v
dt m
=
= + = =

=
=
This is a differential equation and is written in
terms of the differential rate of change dv/dt
of the variable that we are interested in
predicting.
If the parachutist is initially at rest (v=0 at t=0),
using calculus
( )
t m c
e
c
gm
t v
) / (
1 ) (

=
Independent
variable
Dependent
variable
Parameters
Forcing
function
Write the velocity equation as


We may obtain


Rearranging yields
Computer software
Excel
Matlab
Scilab
Fortran 90 (IMSL)
C++

20
Approximations 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?
21
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.

22
Significant Figures
24
Significant Figures (2)
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 10
4
3
5.380 x 10
4
4
5.3800 x 10
4
5

Zeros are sometimes used to locate the decimal point not significant
figures.

0.00001753 4
0.0001753 4
0.001753 4




Significant Figures (3)
Implication :
1. Numerical methods yield approximate results. We must develop
criteria to specify how confident we are in our approximate result.
One way to do this is in terms of significant figures.
2. Although quantities such as , e, or 7 represent specific quantities,
they cannot be expressed exactly by a limited number of digits.
Because computers retain only a finite number of significant figures,
such numbers can never be represented exactly. The omission of the
remaining significant figures is called round-off error.
26
Error Definitions
True Value = Approximation + Error

E
t
= True value Approximation (+/-)


value true
error true
error relative fractional True =
% 100
value true
error true
error, relative percent True
t
= c
True error
27
For numerical methods, the true value will be
known only when we deal with functions that can
be solved analytically (simple systems). In real
world applications, we usually not know the answer
a priori. Then



Iterative approach, example Newtons method

% 100
ion Approximat
error e Approximat
a
= c
% 100
ion approximat Current
ion approximat Previous - ion approximat Current
a
= c
(+ / -)
28
Use absolute value.
Computations are repeated until stopping criterion is
satisfied.





If the following criterion is met



you can be sure that the result is correct to at least n
significant figures.
s a
c c (
Pre-specified % tolerance based on
the knowledge of your solution
)% 10 (0.5
n) - (2
s
= c
31
Two sources of numerical error
1) Round off error
2) Truncation error

32
Round-off Error


33
Round off Error
Caused by representing a number approximately


It is due to the limited sources of computer in
representing the number

1
0.333333
3
~
2 1.4142... ~
34
Problems created by round off error
28 Americans were killed on February 25,
1991 by an Iraqi Scud missile in Dhahran,
Saudi Arabia.
The patriot defense system failed to track and
intercept the Scud. Why?
35
Problem with Patriot missile
Clock cycle of 1/10 seconds was
represented in 24-bit fixed point
register created an error of 9.5 x 10
-8

seconds.


The battery was on for 100
consecutive hours, thus causing an
inaccuracy of

1hr
3600s
100hr
0.1s
s
10 9.5
8
=

s 342 . 0 =
36
Problem (cont.)
The shift calculated in the ranging system of
the missile was 687 meters.
The target was considered to be out of range
at a distance greater than 137 meters.
37
Truncation Error


38
Truncation error
Error caused by truncating or
approximating a mathematical procedure.
39
Example of Truncation Error
Taking only a few terms of a Maclaurin series to
approximate
.......... ..........
! 3 ! 2
1
3 2
+ + + + =
x x
x e
x
x
e
If only 3 terms are used,
|
|
.
|

\
|
+ + =
! 2
1
2
x
x e Error Truncation
x
40
Another Example of Truncation Error
Using a finite x A to approximate ) (x f
'
x
x f x x f
x f
A
A +
~
'
) ( ) (
) (
P
Q
secant line
tangent line
Figure 1. Approximate derivative using finite x
41
Another Example of Truncation Error
Using finite rectangles to approximate an
integral.
y = x
2
0
30
60
90
0 1.5 3 4.5 6 7.5 9 10.5 12
y
x
42
Example 1 Maclaurin series
Calculate the value of
2 . 1
e
with an absolute
relative approximate error of less than 1%.
......... ..........
! 3
2 . 1
! 2
2 . 1
2 . 1 1
3 2
2 . 1
+ + + + = e
n
1 1 __ ___
2 2.2 1.2 54.545
3 2.92 0.72 24.658
4 3.208 0.288 8.9776
5 3.2944 0.0864 2.6226
6 3.3151 0.020736 0.62550
a
E
%
a
e
2 . 1
e
6 terms are required.
43
Example 2 Differentiation
Find
) 3 ( f
'
for
2
) ( x x f =
using
x
x f x x f
x f
A
A +
~
'
) ( ) (
) (
and
2 . 0 = Ax
2 . 0
) 3 ( ) 2 . 0 3 (
) 3 (
'
f f
f
+
=
2 . 0
) 3 ( ) 2 . 3 ( f f
=
2 . 0
3 2 . 3
2 2

=
2 . 0
9 24 . 10
=
2 . 0
24 . 1
= 2 . 6 =
The actual value is
, 2 ) (
'
x x f = 6 3 2 ) 3 (
'
= = f
Truncation error is then, 2 . 0 2 . 6 6 =
Can you find the truncation error with 1 . 0 = Ax
44
Example 3 Integration
Use two rectangles of equal width to approximate
the area under the curve for
2
) ( x x f =
over the interval ] 9 , 3 [
y = x
2
0
30
60
90
0 3 6 9 12
y
x
}
9
3
2
dx x
45
Integration example (cont.)
) 6 9 ( ) ( ) 3 6 ( ) (
6
2
3
2
9
3
2
+ =
= =
}
x x
x x dx x
3 ) 6 ( 3 ) 3 (
2 2
+ =
135 108 27 = + =
Choosing a width of 3, we have
Actual value is given by
}
9
3
2
dx x
9
3
3
3
(

=
x
234
3
3 9
3 3
=
(


=
Truncation error is then
99 135 234 =
Can you find the truncation error with 4 rectangles?

Das könnte Ihnen auch gefallen