0% found this document useful (0 votes)
35 views52 pages

Numerical 1

Tuba Karagül Yıldız is a faculty member in the Department of Engineering who teaches numerical analysis. Her document outlines her contact information, office hours, course goals and content, learning outcomes, schedule, required textbooks, grading policy, class attendance policy, and provides overviews of key topics in numerical analysis including roots of equations, systems of equations, curve fitting, numerical integration and differentiation, ordinary and partial differential equations, and Taylor and McLaurin series expansions.
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)
35 views52 pages

Numerical 1

Tuba Karagül Yıldız is a faculty member in the Department of Engineering who teaches numerical analysis. Her document outlines her contact information, office hours, course goals and content, learning outcomes, schedule, required textbooks, grading policy, class attendance policy, and provides overviews of key topics in numerical analysis including roots of equations, systems of equations, curve fitting, numerical integration and differentiation, ordinary and partial differential equations, and Taylor and McLaurin series expansions.
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/ 52

Tuba KARAGÜL YILDIZ

 Address: Faculty of Engineering, M2, OfficeNo:313

 E-mail: [email protected]

 Web: http://akademik.duzce.edu.tr/tubakaragul

 Office hours: Tuesday – 10:10-10:50 , Wednesday - 16:20-17:00

 NOTE: Please make an appointment by e-mail.

Tuba Karagül Yıldız 2


 Goals
 Teaching the numerical solution methods and algorithms of the engineering problems

 Course Content
 Errors, root finding methods, interpolation, numerical derivative, integration and solutions of
differential equations

 Learning Outcomes
 To help the gain of how to do all computations which is done by hand in theoretical lessons by using
computers and how to be solved these problems by using computers.
 Understands that numerical solving approaches rely on an algorithm structure.

 Knows how the computer and software languages function in engineering life.

3
1.Week Introduction to Numerıcal Analysıs, Numerical Methods, Errors..
2. Week Building an algorithm and introducing the algorithm sub-units..
3. Week The matrices and matrix operations
4. & 5. Week Solution methods of linear equations systems
6. & 7. Week Solution methods of non-linear equations systems
8. Week Curve fitting
9. Week Interpolation and extrapolation methods
10. Week Numerical differentiation methods
11. Week Numerical integration methods
12. & 13. Week Solution Methods of differential equations
14. Week Complex numbers
4
 Numerical Methods for Engineers, S.C.C, R.P.C (Çeviri-H. Heperkan, U. Keskin), Literatur

publishing, 2003. ISBN: 9789758431830

 Practical numerical analysis, Gwyne A. Evans, John Wiley&Sons publishing, 1995. ISBN-

13: 978-0471955351

5
Event (%)

Midterm exam %50

Final exam %50

NOTE: The passing grade will be calculated using the absolute assessment method.

Tuba Karagül Yıldız 6


Most class attendance is OPTIONAL — Announcements will be posted on
the web page.
If/when you attend class:
 Please be on time.

 Please pay attention.

 Please turn off mobile phones.

 Please be courteous to other students and the instructor.


Tuba Karagül Yıldız 7
. Mathematical
Model
Engineering Problem
. Application
Analysis/ Coding /
. Algorithm Testing

Tuba Karagül Yıldız 8


 Numerıcal Analysıs, is the arrangement of numerical operations
performed in a certain number and order in order to obtain
results with a certain precision in the solutions of real world
problems expressed with mathematical models.
 Numerıcal Analysıs, is a branch of mathematical science that
provides solutions to problems that seem difficult or impossible
to solve analytically, through four operations and algorithms.

Tuba Karagül Yıldız 9


 While the events and formations in nature are examined by
scientific methods, the magnitudes that affect the course of
events or the outcome of the formations as their value changes
are called variables.
 As a result of the examinations, tabular values, various graphs or
algebraic, differential and integral equations or systems are
obtained from the relationships between the variables.

Tuba Karagül Yıldız 10


 Complex equations and systems are not easy to solve by
analytical methods, and often even impossible. For this reason,
numerical solution methods are applied to solve the problems.
Advances in computer technology have also increased the
effectiveness of numerical methods.

. Mathematical
Model

Engineering Problem. Application


Analysis/ Coding /
. Algorithm Testing

Tuba Karagül Yıldız . 11


 Finding and developing the methods to perform these
operations, examining the existing methods and determining the
most effective ones are among the subjects of NUMERICAL
ANALYSIS.
 These operations and processes are done with the help of
computers today.
 NUMERICAL ANALYSIS is a multidisciplinary field of study.

 As computer technology has developed, numerical analysis


techniques have also developed. 12
 Numerical solution methods are used to solve mathematical
problems on electronic calculators.
 As the precision in the solutions is increased, so does the
processing load. This load can be overcome thanks to electronic
calculators.
 Errors that occur during these processes are also among the
subjects of Numerical Analysis.

Tuba Karagül Yıldız 13


 The process required to solve a problem is called an algorithm
that is arranged and/or calculated step by step, with a certain
number and sequence. In other words the algorithm is a finite
list of instructions.

INPUT ALGORITHM OUTPUT

Tuba Karagül Yıldız 14


 The process of repeatedly applying a function or solution
method is known as iteration.
 When choosing an algorithm, the algorithm with the least
error should be preferred.

Can be experimental There may be situations such


measurements, as an interrupt error caused
by the algorithm's own Total error
INPUT observations, tabular
values, or calculated
ALGORİTHM method or a rounding error OUTPUT can be
caused by arithmetic calculated
function values. Inputs operations performed on the
may have a data error. computer.

Tuba Karagül Yıldız 15


 Roots of Equations

 Solution of Linear and Non-linear Equations Systems

 Curve Fitting

 Numerical Integral

 Numerical Derivative

 Ordinary differential equations

 Partial derivative differential equations 16


Calculation of x values satisfying the equation f(x)=0

the root

Tuba Karagül Yıldız 17


the solution

Tuba Karagül Yıldız 18


(approximation) (finding the approximate value)

Tuba Karagül Yıldız 19


I = area under
the curve

Tuba Karagül Yıldız 20


Tuba Karagül Yıldız 21
 An equation; containing an unknown function and its derivatives.

𝑑𝑦 1
 = 𝑥 a y(x) function whose derivative is equal to x 𝑦 𝑥 = 𝑥2 + 𝐶
𝑑𝑥 2

𝑑𝑦
 = 𝑦 a y(x) function whose derivative is equal to itself 𝑦 𝑥 = 𝐶𝑒 𝑥
𝑑𝑥

 𝑦𝑦 ′ + 𝑥 = 0 … 𝑦(𝑥)2 + 𝑥 2 = 𝐶

Tuba Karagül Yıldız 22


u is calculated based on the x and y values.

Tuba Karagül Yıldız 23


 Taylor series is the writing of a function as an infinite-term

polynomial if a function has all derivatives and the function


is continuous in the interval [0, a].

𝑓′ 𝑎 𝑓′′ 𝑎 𝑓𝑛 𝑎
𝑓 𝑥 = 𝑓 𝑎 + (𝑥 − 𝑎) + 𝑥−𝑎 2 + ⋯+ (𝑥 − 𝑎)n
1! 2! 𝑛!

Tuba Karagül Yıldız 24


 If exceptional case a=0 is received in Taylor series, the

resulting series is called the McLaurin series.

𝑥 𝑥2 𝑥𝑛
𝑓 𝑥 = 1 + + + ⋯+
1! 2! 𝑛!

Tuba Karagül Yıldız 25


 Expansion of the function 𝑦 = 𝑒 𝑥 to Taylor series at x=0:

𝑓′ 𝑒 𝑥 𝑓′′ 𝑒 𝑥 𝑓𝑛 𝑒 𝑥 𝑥 𝑥2 𝑥𝑛
𝑦 = 𝑒𝑥 + (𝑥) + 𝑥 2 +⋯+ (𝑥)n = 1 + + + ⋯+
1! 2! 𝑛! 1! 2! 𝑛!

 Expansion of the function 𝑦 = 𝑒 𝑥 to McLaurin series at x=0,5:

𝑥 𝑥2 𝑥𝑛 0,5 0,52 0,5𝑛


𝑦=1 + + + ⋯+ = 1+ + + ⋯+
1! 2! 𝑛! 1! 2! 𝑛!

Tuba Karagül Yıldız 26


 The error is the difference between the actual/exact result

(α) and the found/approximate result (ά).

 ε= α- ά

Tuba Karagül Yıldız 27


 Absolute Error

 Relative Error

 Approximate Relative Error

 Truncation Error

 Approximation Error

 Round-off Error
Tuba Karagül Yıldız 28
 Operations with numbers are carried out according to the

decimal system in daily life. For example, the operations


for the number 298 are as follows:

298 = 2x102 + 9x101 + 8x100

11.10.2021 29
 There are also 8 octal and 16 hexadecimal number systems. In
computers, on the other hand, the binary number system is used
because the computer architecture is built on 2-bit (binary)
systems. For example, the number 298 is stored in the computer
memory as follows:
 298 =1x28 + 0x27 + 0x26 + 1x25 + 0x24 + 1x23 + 0x22 + 1x21 + 0x20
= (100101010)2

Tuba Karagül Yıldız 30


 The above shows how integers are held in memory. If the number is
fractional, the situation is slightly different. This process is related to the
hardware and identification of the numbers of the computers used.

 For example, the computer writes the fraction 1/3 using a certain number of
digits, such as 0.33333....

 It is about how many digits are used to define numbers, how the numbers
are defined, and the architecture of the computer.

 Errors that occur in such operations are called round-off errors.

Tuba Karagül Yıldız 31


 To do some operations numerically instead of analytically; we discontinuous
the field of the f(x) function by dividing it into small particles instead of a
continuous this function, that we can find in the easy way. These
discontinuities also cause errors. This type of errors are called as truncation
error.

11.10.2021 32
 As an example, the first four terms used to find the approximate value of
the function sin(x) do not give the correct answer. The reason for this error
is the use of a certain number of elements of the sinuse series. In iterative
methods, the amount of this error can be reduced according to the number
of iterations, but since it is not possible to reach the real result by using an
infinite number of terms, a value very close to the real result can be found
by using a certain number of terms. Such errors that occur due to the use of
a certain number of terms are called interrupt errors.

11.10.2021 33
Number
of terms Function Value .

11.10.2021 34
 As can be seen, as the number of terms used increases, the
function will approach its analytical value. If the number of
terms is reduced, the amount of errors will increase. Since
an infinite number of steps cannot be used in computer
operations, the process must be stopped after a certain
number of terms have been used or when it reaches a
certain error interval.
 These error quantities are typically defined using absolute
error, relative error, approximate relative error, and
sentiment errors.
11.10.2021 35
 The error can be positive or negative. Therefore,
usually the absolute value of the error is used.

 This type of errors are called as the absolute errors.

 |ε|= |α- ά|

Tuba Karagül Yıldız 36


 It is the ratio of absolute error to actual result value.

|ε| α−ά
 𝑟= =
|α| |α|

Tuba Karagül Yıldız 37


 The approximate relative error is the ratio of the absolute

error to the calculated result value.

|ε| α −ά
 ѓ= =
|ά | |ά|

Tuba Karagül Yıldız 38


x3 x5 x7
 sin x = x- + - +...
3! 5! 7!

 Calculate sin(0,5) using the first 5 terms of the series


above, find the absolute and relative error values.

Tuba Karagül Yıldız 39


 Solution:

 a=sin(0,5)=0,008726

x3 x5 x7 x9 (0,5)3 (0,5)5 (0,5)7 (0,5)9


 a’=sin(0,5)= x- + - + = (0,5)- + - +
3! 5! 7! 9! 3! 5! 7! 9!

 =0,5-(0,125/6)+(0,03125/120)-

(0,0078125/5040)+(0,001953125/362880)

 =0,5-0,020833+0,000260-0,000001+0,00000000538=0,479426
Tuba Karagül Yıldız 40
 Absolute Error:
 |e|=|a-a’|=| 0,008726 -0,479426|=0,470699

 Relative Error:
|𝑒| 0,470699
r = = =53,942126
|𝑎| 0,008726

 Approximate relative error:


|e| 0,470699
 ѓ= = =0,981796
|a′| 0,479426
Tuba Karagül Yıldız 41
 Errors caused by truncating numerical methods or terms are
called as truncation errors.
 It occurs when complex mathematical expressions are
intended to be expressed in formulas containing simple
operations.

 Truncation error = Actual value - Calculated value

Tuba Karagül Yıldız 42


 Lets expanse the number e1,5 to the McLaurin series, and
 a) find the terms up to 3rd degree
 b) find the terms up to 5th degree
Then calculate the truncation error by retrieving it.

Solution:
 𝑒 1,5 =4,4816890703380650..
𝑥2 𝑥3 𝑥4
𝑒 𝑥
=1+x+ + + +…
2! 3! 4!
Tuba Karagül Yıldız 43
(1,5)2 (1,5)3 2,25 3,375
 a) 𝑒 1,5
=1+1,5+ + = 1+1,5+ + =1+1,5+1,125+0,5625
2! 3! 2 6

 xa=4,1875

 Et=xe-xa= 4,4816890703380650- 4,1875=0,2941890703380650

(1,5)2 (1,5)3 (1,5)4 (1,5)5 2,25 3,375 5,0625 7,59375


 b) 𝑒 (1,5)
=1+ (1,5) + + + + = 1+1,5+ + + +
2! 3! 4! 5! 2 6 24 120

 =1+1,5+1,125+0,5625+0,2109375+0,06328125

 xa= 4,46171875

Et=xe-xa= 4,4816890703380650- 4,46171875=0,0199703203380650


44
 In problems where the real value is not known, the solution values

obtained step by step – iteratively are found. The value obtained in the
previous iteration is used in the new iteration to estimate the amount of
error proportionally.

|Ynew−Yold|
 ε𝑦 =
|Ynew|
 Ynew: Solution value obtained in the current iteration

 Yold: Solution value obtained in the previous iteration 45


 Find the approximation and absolute error percentages by accepting
 𝑒 0,5 = 1,648721271
Solution:
𝑥1 𝑥2 𝑥3 𝑥𝑛
Infinite ∞ serial expansion of function 𝑒𝑥 : 𝑒 =1+
𝑥 + + +…+
1! 52! 3! 𝑛!
 For x=0,5 ;
 First term: 𝑒 𝑥 = 1
 First 2 terms: 𝑒 𝑥 =1+0,5 = 1,5
 First 3 terms: 𝑒 𝑥 =1+0,5+0,125 = 1,625

Tuba Karagül Yıldız 46


|𝑦−𝑦new | |𝑒 0,5 −1| |𝑦new −𝑦𝑜𝑙𝑑 |
 First term: 𝑒 𝑥 =1 𝜀𝑏 = = = 0,3934 , 𝜀𝑦 =
|𝑦| |𝑒 0,5 | |𝑦new |

|𝑒 0,5 −1,5| |1,5−1|


 First 2 terms: 𝑒 𝑥 =1,5 𝜀𝑏 = 0,5 = 0,0902 , 𝜀𝑦 = =0,3333
|𝑒 | |1,5|

|𝑒 0,5 −1,625| |1,625−1,5|


 First k 3 terms: 𝑒 𝑥 =1,625 𝜀𝑏 = = 0,0143 , 𝜀𝑦 = =0,0769
|𝑒 0,5 | |1,625|

…

Tuba Karagül Yıldız 47


Number of terms Result 𝜀𝑏 (%) 𝜀𝑦 (%)
1 1 39,3 -
2 1,5 9,02 33,3
3 1,625 1,44 7,69
4 1,64583333 0,175 1,27
5 1,64843750 0,0172 0,158
6 1,64869791 0,00142 0,0158
7 1,64871961 0,0001007 0,001316

Tuba Karagül Yıldız 48


 Some rational and irrational numbers must all be expressed
in an infinite number of digits in the decimal system. In a
64-bit computer system, a certain number of digits of a real
number can be represented after the comma, so the
remaining digits are removed from the number. This creates
a round-off error.

Tuba Karagül Yıldız 49


 Round the number A=2,3456738475 after the comma to 8 digits

 A=2,3456738475 → 2,34567385

 Round the following numbers after the decimal point to 3 digits.

 B=2,15550 → B=2,156

 C=85,12449999 → C=85,124

 D=0,71849999 → D=0,719

 E=3,666666666 → E=3,667
50
 Algorithms

Tuba Karagül Yıldız 51


 NUMERICAL ANALYSIS - Personal Lecture Notes of Tuba KARAGÜL YILDIZ

Tuba Karagül Yıldız 52

You might also like