o Newton Interpolation Formula. ⢠Central Differences. ⢠Linear Interpolation. ⢠Lagrange's Interpolation. ⢠Inverse Interpolation. 2. 4. 6. 8. 8. 8. 8. 9. 10. 11. 12. 13.
A Note Book On
NUMERICAL METHODS For BE-V Semester (Computer Engineering)
Prepared By Er. SriKisna
Inside o o o o o o o o o o o
Numerical Methods: Introduction & Scope Errors in Numerical Calculation Solution of Algebraic & Transcendental Equation Interpolation Curve Fitting, B Splines & Approximation Numerical Differentiation & Integration Matrices & Linear System of Equations Solution of Ordinary Differential Equations Solution of Partial Differential Equations Solution of Integral Equations Programming Examples
HWHIC GSSE BLEX IV
CONTENT Introduction to Numerical Methods (1 – 6) Course Plan & Strategy ----------------------------------Importance & Need of Numerical Methods Scope & Application of Numerical Methods
Chapter: 1
Error in Numerical Calculations (8 – 14) 1.1
1.2 1.3 1.4 1.5 1.6 1.7
Chapter: 2
Numbers & their accuracy -------------------------- Significant Digits Accuracy & Precision Rules for Rounding off Types of Errors & Numerical Examples Mathematical Preliminaries General Error Formula Convergence Assignment 1
8 8 8 8 9 10 11 12 13 14
Solutions of Algebric & Transcendental Equations (15 – 35) 2.1
2.2
2.3
Chapter: 3
2 4 6
Introduction to types of equations ---------------- Algebric Functions Transcendental Equations Polynomial Equations o Evaluation of Polynomial by Horner’s Method Linear & Non Linear Equations Solving Non Linear Equations by Iterative Methods Bisection Method & Its Convergence Regular Falsi Method & Its Convergence Newton Raphson Method & Its Variance and Convergence Secant Method & Its Converges Fixed Point Iteration Method & Its Convergence Horner’s Method of Finding Roots Assignment 2
16 16 16 16 16 17 18 18 20 22 28 31 33 35
Interpolations (36 – 49) 3.1 Introduction & Forms of Polynomial Equations ---------3.2 Errors in Polynomial Interpolation 3.3 Finite Difference Methods Forward Differences Backward Differences o Difference of a Polynomials o Newton Interpolation Formula Central Differences Linear Interpolation Lagrange’s Interpolation Inverse Interpolation
37 37 38 38 39 41 42 42 43 44 46 1
HWHIC GSSE BLEX IV
3.4 Divided Differences 3.5 Assignment 3
Chapter: 4
Curve Fittings, B-Splines & Approximations (50 – 63) 4.1 4.2
4.3 4.4 4.5 4.6
Chapter: 5
Introduction --------------------------------------Least Square Regression Fitting Linear Equation Fitting Transcendental Equation Fitting Polynomial Equation Multiple Linear Regression Spline Interpolation Cubic B-Spline Approximation of Functions Assignment 4
51 51 52 53 55 57 58 62 63
Differentiation & Integration (64 – 88) 4.1 4.2
4.3 4.4 4.5
4.6 4.7 4.8 4.9
Chapter: 6
47 49
Numerical Differentiation: Introduction -----------Differentiating Continuous Functions Forward & Backward Difference Method Central Difference Method Error Analysis High Order Derivatives Differentiating Tabulated Functions Numerical Integration: Introduction Newton Cote’s General Integration Formula Trapezoidal Rule Simpson’s Rule Numerical Double Integration Gaussian Integration Romberg Integration Assignment 5
65 65 65 66 67 69 70 73 73 74 77 80 81 86 88
Matrices & Linear System of Equations (89 – 104) 6.1 6.2 6.3 6.4
6.5
6.6
Introduction --------------------------------------Existence of Solution Method of Solving Linear Equations Solution by Elimination Basic Gauss Elimination & Its Limitation Gauss Elimination with Pivoting Gauss Jordan Method Triangular Factorization Method Singular Value Decompositions Solution by Iteration Jacobi Method Gauss Seidal Method Assignment 6
90 90 92 93 93 95 96 97 99 101 101 102 104 1
HWHIC GSSE BLEX IV
Chapter: 7
Numerical Solutions of Ordinary Differential Equations (105 – 120) 7.1
7.2 7.3 7.4 7.5 7.6 7.7
7.8
Chapter: 8
8.4 8.5 8.6
Introduction---------------------------------------Finite Difference Approximation Solution of Elliptic Equations Laplace Equations Poisson’s Equations Solution of Parabolic Equations Solution of Hyperbolic Equations Assignment 8
122 123 124 124 126 127 129 132
Numerical Solutions of Integral Equations (133 – 140) 9.1 9.2 9.3 9.4 9.5
Chapter: 10
106 107 107 107 107 108 109 110 112 114 116 118 120
Numerical Solutions of Partial Differential Equations (121 – 132) 8.1 8.2 8.3
Chapter: 9
Introduction & Types of ODEs ---------------------- Order & Degree of Differential Equations Linear & Non Linear Differential Equations General & Particular Solution One Step & Multi Step Solution Solution by Taylor’s Series Method Euler’s Method Heun’s Method Fourth Order Runge Kutta Method Simultaneous First Order Differential Equations Solution of ODEs as Boundary Value Problem Finite Difference Method Shooting Method Assignment 7
Introduction --------------------------------------Method of Degenerated Kernels Method of Generalized Quadrature Chebyshev Series & Cubic Spline Method Assignment 9
134 135 137 138 140
Programming Examples ( 141 – 156)
1
WhiteHouse Institute of Science & Technology Khumaltar, Lalitpur-Satdobato
Bachelor in E & C/Computer Engineering Bachelor in Information Technology
NUMRECIAL METHODS
Lecture Handouts Prepared by: Er Shree Krishna Khadka
Page
1
2012
Prepared By Er. Shree Krishna Khadka
1. Reference books: a. Numerical Methods by E. Balagurusamy b. Introductory Methods of Numerical Analysis by S.S. Sastry 2. Teaching Schedule: a. Theory: 3hrs/week b. Practical: 1.5hrs/week 3. Examination Scheme: a. Internal Assessment i. Theory: 20 marks ii. Practical: 50 marks b. Final Examination i. Theory: 80 marks c. Total: 150 marks 4. Internal marks evaluation: Theory (20) Practical (50) A &CP GD & P TP & MT PBE A & CP RS & P PE & MCQs 25% 25% 25% 25% 20% 40% 40% 5. Abbreviations: a. A & CP: Attendance & Class Participation b. GD & P: Group Discussion & Presentation c. TP & MT: Test Papers & Mid Term d. PBE : Pre Board Examination e. RS & P: Report Submission & Presentation f. PE & MCQs: Practical Exam & Multiple Choice Questions 6. Adjustments: a. 80-100% accomplishment: Full marks (100%) b. 60-80% accomplishment: Semi marks (80%) c. 40-60% accomplishment: Fair marks (60%)
Prepared By Er. Shree Krishna Khadka
Page
a. ***: Distinction with 100% marks. b. ** : First Division with up to 80% marks. c. * : Fair with up to 60% marks.
2
7. Ratings:
8. Final Examination: a. Board Exam: i. Full marks: 80 ii. Question Pattern: Generally consists of two groups
Pattern Question type Total question Attempt Marks/each Total
BIT Group A Long 3 2 12 24
Group B Short 10 8 7 56
BE C/C & E Group A Group B Long Long/Program 7 3 6 2 10 10 60 20
b. For BIT: Sometimes, one extra paper with 20 objectives questions can be asked each carrying 1 marks for twenty minutes as a Group A. In that case, long answer type questions weigh 10 marks each and short type questions weigh 5 marks for each. For BE: Choices may vary from more than one questions in each groups. c. Lab Exam
Page
3
i. Of about 12 exercises on lab - As per the syllabus, selected topics will be exercised. ii. Programming - Programming is done using C/C++ language in Visual Basic platform. iii. Submission of lab report is compulsory. iv. Practical Exam 1. Programming test. 2. Viva/MCQs test.
Prepared By Er. Shree Krishna Khadka
Introduction 1. Why to study Numerical Methods? a. Historical Review: - In early age of about 3000 BC, computing starts with a device called ABACUS by Chinese society, which was used for arithmetic operation only. - Slide rule by John Napier to compute a logarithmic problems in early 16th century. - An accounting machine by Blaise Pascal called Pascal Calculator. - Data storing facility at punched card by Loom Jacquard in 18th century. - 18th Century: Revolutionary invention of Difference Engine & Analytical Engine by Charles Babbage. - Later on till the date, all advanced/most recent computers are based on that principle. b. Present Context: Now-a-days, computers are great tools in numerical computation, which plays an indispensable role in solving real-life mathematical, physical and engineering problems. However, without fundamental understanding of engineering problems, they will be useless. 2. How is the engineering system understood? - By observation and experiment. - Theoretical analysis and generalization.
Problem Definition
Mathematical Model
Data
Problem solving tools: Computers, Statistics, Numerical Methods, Graphics etc.
Numerical/Graphical Result
Validation by: Societal interlaces, Scheduling, Optimization, Communication & Public Interaction
4
Implementation/ Application
Fig: Computing Process
Prepared By Er. Shree Krishna Khadka
Page
Theory
3. Example: Newton’s Second Law of Motion 1. Theory: The time rate of change of momentum of a body is equal to the resulting force acting on it. 2. Mathematical Model:
Where, F = Net force acting on the body. m = Mass of the object u = Initial velocity of the object v = Final velocity of the object t = time and a = acceleration
Data
3. Analysis: It characterizes the typical mathematical model of the physical world as: a. Natural process or system in mathematical term. b. Idealization and simplification of reality. c. Yields reproducible results. 4. Solution: Manipulation of mathematical model gives rise to the solution of the problem. Analytical Vs. Numerical Solution Analytical solution is like a ‘Math: a great example’, as we have been learning all the way. Numerical solution is computed via computer with some approximation but exact result. For example, the quadratic equation ax2+bx+c = 0 has: a) Analytic solution:
√
; which works for any set of values of a,
b & c. The real solution exists only if solution are transparent.
, i.e. the properties of the
b) Numerical solution: Can only deal with a given set (a, b, c) at a given time. Solution is approximate. So, error estimation is needed. We want the computer to do repeated search for the solution, but not blindly. A clear set of rules (steps) has to be designed based on the sound mathematical reasoning, which guarantee a solution at a desirable level of accuracy.
Prepared By Er. Shree Krishna Khadka
Page
This example is just a prototype; most of the real-world problems (99.9%) are complex in nature but can be approximately solved with numerical computation.
5
5. Validation & Implementation Now, numerical method is a tool that deals with the mathematical model (formulated to describe the theory) to give a valid numerical or graphical result.
4. Summary: a. Science and engineering study convert physical phenomena into mathematical model often with complex-analysis and calculation. b. Numerical analysis is the study of procedure for solving the problem with computer. c. It is the study of algorithms and further problems of mathematics. d. Numerical analysis is always numerical. e. Goal of numerical analysis is the design and analysis of techniques to give approximate but accurate solution to hard problems. 5. Applications:
6
Numerical weather forecasting. Computing transactory of space-craft (path-of-projectile). In super computers. In improvement of car safety to avoid accidents.
Page
a. b. c. d.
Prepared By Er. Shree Krishna Khadka
Errors in Numerical Calculation Contents:
7
Numbers & Their Accuracy Different Types of Errors Mathematical Preliminaries General Error Formula Convergence Assignment 1
Page
o o o o o o
Prepared By Er. Shree Krishna Khadka
NUMBERS & THEIR ACCURACY There are two kinds of numbers: i) Exact numbers, e.g. 1, 2, 3 …1/2, 5/2 etc. ii) Approximate numbers, e.g. PI, K … etc o Significant Digit: Digits that are used to express a number are called significant digits/figures. The following statements describe the notion of significant digits. - All non-zero digits. - All zeroes occurring between non- zero digits. - Trailing zeroes following a decimal point, e.g. 3.50, 65.0, 0.230 have three significant digits. - Zeroes between the decimal point are preceding a non-zero digits are not significant, e.g. 0.01234, 0.001234, 0.0001234 all have four significant digits. - When the decimal point is not written, trailing zeroes are not considered to be significant, e.g. 4500 contain only two significant digits. o Accuracy & precision The concept of accuracy and precision are closely related to significant digits. - Accuracy refers to the number of significant digits in a value. E.g. the number 57.345 is accurate to five significant digits. - Precision refers to the number of decimal position, i.e. the order of magnitude of last digit in a value. E.g. 57.396 have a precision of 0.001. In numerical computation, we come across numbers which have large numbers of digits and it will be necessary to cut them to usable numbers of figures. This process is known as rounding off. The error caused due to cut-off a large number into usable number of figure is called round-off error. o Rules for rounding off: To round off a number to n-significant digits, discard all digits to the right of the nth digit if this discarded number is: - Less than half a unit in the nth place, leave the nth digit unaltered. - Greater than half a unit in nth place, increase the nth digit by unity. - Exactly half a unit in the nth place, increase the nth digit by unity if it is odd; otherwise leave it unchanged.
Page
1.6583(1.658), 30.0567(30.06), 0.859378(0.8594), 3.14159(3.142)
8
Examples: Following numbers are rounded off to four significant figures.
Prepared By Er. Shree Krishna Khadka
DIFFERENT TYPES OF ERROR:
a) Absolute Error: Numerical difference between true value of a quantity and its approximate value. Mathematically;
b) Relative error: Ratio of absolute error to a true value of that quantity being concerned. Mathematically;
c) Percentage Error: The percentage value of relative error. Mathematically;
d) Truncation Error: Occurs due to truncation or terminating an infinite sequence of operation after a finite number have been performed. Example:
e) Relative Accuracy: Ratio of change in true value to the modulus of true value.
Page
9
Mathematically;
Prepared By Er. Shree Krishna Khadka
NUMERICAL EXAMPLES:
An approximate value of PI is given as 3.1428571 and its true value is 3.1415926. Find EA and ER. Solution: EA =| X-X1| = |3.1415926-3.1428571| = 1.265*10-3 ER = EA/X = 1.265*10-3/3.1415926 = 4.025*10-4
Three approximate values of the number 1/3 are given as 0.30, 0.33 and 0.34, which of these is the best approximation? Solution: E1 = |(1/3)-0.30| = 1/30 E2 = |(1/3)-0.33| = 1/300 E3 = |(1/3)-0.34| = 1/150 Since, E2