MTH 312: Numerical Analysis PDF Lecture Notes
Document Details
Uploaded by NicerInterstellar
Baze University
2022
Lukman O. AHMED
Tags
Related
- Mathematics III(A) Syllabus PDF
- Mathematics III(A) Syllabus and Introduction Lecture (C. V. Raman Global University 2021) PDF
- ELEN-30073 Numerical Methods Instructional Material PDF
- EPMATH235 Statistics Extra Exercises Worksheet PDF
- Numeration Systems Lecture 2024-2025 PDF
- Numerical Methods Lecture 1 PDF
Summary
These lecture notes cover MTH 312: Numerical Analysis, a course offered at Baze University in Nigeria during May-August 2022. The notes provide an introduction to numerical analysis, including methods for solving non-linear and transcendental equations, curve fitting, numerical differentiation, integration, and numerical solutions to ordinary and partial differential equations.
Full Transcript
MTH 312: Numerical Analysis Lukman O. AHMED LECTURE NOTE AND GUIDE FROM THE DEPARTMENT OF MATHEMATICS, FACULTY OF COMPUTING AND APPLIED SCIENCES, BAZE UNIVERSITY, ABUJA,...
MTH 312: Numerical Analysis Lukman O. AHMED LECTURE NOTE AND GUIDE FROM THE DEPARTMENT OF MATHEMATICS, FACULTY OF COMPUTING AND APPLIED SCIENCES, BAZE UNIVERSITY, ABUJA, NIGERIA Email: [email protected] Office: MAY-AUGUST, 2022 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND1APPLIE / 64 COURSE OUTLINE (1) Introduction: Review Taylor’s theorem, Need for numerical solutions (instead of analytic solution). (2) Numerical solution of Algebraic and transcendental equations, Bisection method, method of false position, Newton-Raphson method, Secant method, etc. (3) Curve fitting – Fitting of linear trend by least square method, Polynomial interpolation, Lagrange method of interpolation, Newton’s method of interpolations, Error analysis, Accuracy precision, Rounding and chopping off numbers. (4) Solution of linear equations, Least-square methods for curve fitting. (5) Numerical differentiation, Backward, forward and central differences, Rate of convergences of these methods. (6) Numerical integration: Trapezoidal and Simpson’s method etc. (7) Numerical solution of Ordinary and Partial Differential Equations, Euler’s Method, Runge-Kutta Method Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND2APPLIE / 64 AIM AND OBJECTIVES This study will imbibe in students the ability to write and execute algorithm, flowchart, and ultimately, code computer program. The objectives to achieve the aim basically utilize Numerical scheme/methods to solve non-linear and transcendental equations through: Interpolation methods, Numerical Differential (Forward and Backward Methods), Numerical Differentiation and Integration Numerical Approximation of Solution in Euler’s and Classical Runge-Kutta Methods Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND3APPLIE / 64 INTRODUCTION INTRODUCTION I Numerical analysis is the area of mathematics and computer science that cre- ates, analyzes, and implements algorithms for solving numerically the problems of continuous mathematics. Such problems originate generally from real-world appli- cations of algebra, geometry, and calculus, and they involve variables which vary continuously. In other words, Numerical Analysis naturally finds application in all fields of engineering, physical sciences, life sciences, social sciences, medicine, business and even the arts have adopted elements of scientific computations. This numerical technique is widely used by scientists and engineers for solving problems related to real life. One major beauty of numerical technique is that, some problems without analytical solution, yet, a numerical answer can still be obtained. However, result from numerical analysis is an approximation, in general, which can be made as accurate as desired. The reliability of the numerical result will depend on an error estimate or bound, therefore the analysis of error and the sources of error in numerical methods is also a critically important part of the study of numerical technique. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND4APPLIE / 64 INTRODUCTION INTRODUCTION II NEEDS FOR NUMERICAL ANALYSIS i. Learning different numerical methods and their analysis will make a person more familiar with the technique of developing new numerical methods. This is important when the available methods are not enough or not efficient for a specific problem to be solved. ii. In many circumstances, one has more methods for a given problem. Hence, choosing an appropriate method is important for producing an accurate result in lesser time. iii. With a sound background, one can use methods properly (especially when a method has its own limitations and/or disadvantages in some specific cases) and, most importantly, one can understand what is going wrong when results are not as expected. iv It helps build skill of computation Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND5APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE REVISION OF PREVIOUS KNOWLEDGE I What do you understand by Exactness of Number? Briefly explain, Approximation of numbers? What is significant figures? What is Round Off Rule? Briefly discuss Floating Point Number? Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND6APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE DEFINITION OF TERMS I (i) Exact Number:- Number with which no uncertainly is associated to, no ap- proximation is taken, is known as exact number e.g., 5, 21/6, 12/3,... etc. are exact numbers. (ii) √ Approximate of Number:- There are numbers, which are not exact, e.g., 2 = 1.41421..., e = 2.7183..., etc. are not exact numbers since they contain infinitely many non-recurring digits. Therefore, the numbers obtained by retaining a few digits, are called approximates numbers, e.g., 3.142, 2.718 are the approximate values of π and e. (iii) Significant Figures:- Are the number of digits used to express a number. The digits 1, 2, 3, 4, 5, 6, 7, 8, 9 are significant digits. ‘0’ is also a significant figure EXCEPT when it is used to fix the decimal point or to fill the places of unknown or discarded digits. Significant figures in other term, are the number of digits in a value, often a measurement, that contribute to the degree of accuracy of the value. We start counting significant figures at the first non-zero digit. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND7APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE DEFINITION OF TERMS II For more examples, each number 5879, 3.487, 0.4762 contains four significant fig- ures while the numbers 0.00486, 0.000382, 0.0000376 contains only three significant figures since zeros only help to fix the position of the decimal point. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND8APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE DEFINITION OF TERMS III Similarly, in the number 0.0002070, the first four ‘0’s are not significant figure since they serve only to fix the position of decimal point and indicate the place values of the other digits. The other two ‘0’s are significant. Some example to be more clearer, the number 2.0683 contain five significant figure. (iv) Floating Point Numbers:- As the name implies, floating point numbers are numbers that contain decimal points. For example, the numbers 5.5, 0.001, and -2,345.6789 are floating point numbers. Numbers that do not have decimal places are called integers. (v) Round Off Numbers:- If we divide 2 by 7, we get 0.285714... a quotient which is a non-terminating decimal fraction. For using such a number in practical computation, it is to be cut-off to a manageable size such as 0.29, 0.286, 0.2857,... etc. The process of cutting off super-flouts digits and retaining as many digits as desired is known as rounding off a number or we can say that process of dropping unwanted digits is called rounding-off. Number are rounded-off according to the following rules: To round-off the number to n significant figures, discard all digits to the right of nth digit and if this discarded number is Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND9APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE DEFINITION OF TERMS IV (1) Less than 5 in (n + 1)th place, leave the nth digit unaltered e.g., 8.893 to 8.89 (2) Greater than 5 in (n + 1)th place, increase the nth digit by unity e.g., 5.3456 to 5.346 (3) Exactly 5 in (n + 1)th place, increase the nth digit by unity if it is odd otherwise leave it unchanged. e.g., 11.675 to 11.68, 11.685 to 11.68. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 10APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE DEFINITION AND EXAMPLES I Shifting of the Mantissa to the left to its most significant digit, is nonzero and it is called Normalization Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 11APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE DEFINITION AND EXAMPLES II Example:- Round-off the following numbers correct to four significant figures: 58.3643, 979.267, 7.7265, 56.395, 0.065738 and 7326853000. Solution After retaining first four significant figures we have: (i) 58.3643 becomes 58.36 (ii) 979.267 becomes 979.3 (iii) 7.7265 becomes 7.726 (digit in the fourth place is even) (iv) 56.395 becomes 56.40 (digit in the fourth place is odd) (v) 0.065738 becomes 0.06574 (because zero in the left is not significant) (vi) 7326853000 becomes 7327 × 106. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 12APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE ERROR A computer has a finite word length and so only a fixed number of digits are stored and used during computation. This would mean that even in storing an exact decimal number in its converted form in the computer memory, an error is introduced. This error is machine dependent and is called machine epsilon. After the computation is over, the result in the machine form (with base b) is again converted to decimal form understandable to the users and some more error may be introduced at this stage. In general, we can say that: Error = True value – Approximate value Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 13APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE TYPES OF ERROR I The errors may be divided into the following different types: (1) Inherent error:- is that quantity which is already present in the statement of the problem before its solution. The inherent error arises either due to the simplified assumptions in the mathematical formulation of the problem or due to the errors in the physical measurements of the parameters of the problem. Inherent error can be minimized by obtaining better data, by using high preci- sion computing aids and by correcting obvious errors in the data. (2) The round-off error:- is the quantity, which arises from the process of rounding off numbers. It sometimes also called numerical error. Also round-off denote a quantity, which must be added to the finite representation of a compound number in order to make it the true representation of that number. The round-off error can be reduced by carrying the computation to more significant figures at each step of computation. At each step of computations, retain at least one more significant figure than that given in the data, perform the last operation, and then round off. (3) Truncation error:- Three types of errors caused by using approximate formulae in computation or on replace an infinite process by a finite one that is when a function f (x) is evaluated from an infinite series for x after ’truncating’ it at a Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 14APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE TYPES OF ERROR II certain stage, this type of error is experienced. The study of this type of error is usually associated with the problem of convergence. (4) Absolute error:- This type of error is the numerical difference between the true value of a quantity and its approximate value. Thus, if x̄ is the approximate value of quantity x, then, |x − x̄| is called the absolute error and denoted by Ea. Therefore, Ea = |x − x̄|. (5) Relative error:- The relative error Er defined by the ratio of absolute error to the true value i.e. Ea Er = x The percentage error is independent of units. (6) Percentage error:- The percentage error in x̄, which is the approximate value of x is given by Ea Ep = 100 × Er = 100 × x The percentage error is also independent of units. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 15APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE EXAMPLES ON ERROR I EXAMPLE 1: Find the absolute, percentage and relative errors if x is rounded-off to three decimal digits. Given x = 0.005998. SOLUTION If x is rounded-off to three decimal places we get x = 0.006. Therefore, Error = True value – Approximate value Error =0.005998-0.006 =-0.000002 Absolute Error (Ea ) = | − 0.000002| = 0.000002 Ea 0.000002 Relative Error (Er ) = True value = 0.005998 = 0.0033344, and Percentage Error (Ep ) = Er × 100 = 0.33344. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 16APPLIE / 64 REVISION OF PREVIOUS KNOWLEDGE EXAMPLES ON ERROR II EXAMPLE 2 If 0.333 is the approximate value of 13 , then, find its absolute, relative and percentage errors. Solution Given that True value (x) = 31 , and its Approximate value Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 17APPLIE / 64 SOLVING NONLINEAR EQUATIONS EXAMPLES OF LINEAR AND NONLINEAR EQUATION Solve the following equation −b i. ax + b = 0, therefore, the result is x = a ∀ a, b ∈ R and a 6= 0 √ 2 −b± b 2 −4ac ii. ax + bx + c = 0, thus, the result is obtained as; x1,2 = 2a iii. x 3 − x + 1 = 0 iv. x 4 − 2x 2 + 3 = 0 v. x 5 − 4x − 2 = 0 Note: there is no general formula for the solution of polynomial equations of orders higher than three(2), no general solution for solution of an arbitrary non-linear equation of the form f (x) = 0 (1) where f is a continuous real-valued function. Our goal is to develop simple numerical methods for the approximate solution of the equation (1), which is defined and continuous on a bounded and closed interval of real line. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 18APPLIE / 64 SOLVING NONLINEAR EQUATIONS INTRODUCTION TO NUMERICAL ANALYSIS IMPORTANT DEFINITIONS I The following are some important mathematical preliminaries useful in numerical computation: i If f (x) is continuous in a ≤ x ≤ b and if f (a) and f (b) are opposite sign, then, there exist c such that f (c) = 0. Thus, a < c < d. ii Mean Value Theorem for Derivative: If f (x) is Continuous in [a, b] and f 0 (x) exists in (a, b), then, there exists at least one value of x, say c such that f (b) − f (a) f 0 (c) = , ∀a < c < b (2) b−a iii Taylor series for a function of one variable: If f (x) is continuous and possesses continuous derivatives of order n in an interval that includes x = a, then, f 00 (a) f 000 (a) f (n−1) (a) f (x) u f (a)+f 0 (a)(x−a)+ (x−a)2 + (x−a)3 +...+ (x−a)n−1 +Rn ( 2! 3! (n − 1)! (3) where Rn (x) the reminder term, can be expressed in the form f (n) (c) Rn (x) = (x − a)n , a < c < x (4) (n)! Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 19APPLIE / 64 SOLVING NONLINEAR EQUATIONS INTRODUCTION TO NUMERICAL ANALYSIS IMPORTANT DEFINITIONS II iv If a = 0 in equation (3), we have Maclaurin’s Expansion f 00 (0) f 000 (0) f (n) (a) f (x) = f (0)+f 0 (0)(x −a)+ (x −a)2 + (x −a)3 +... (x −a)n +... 2! 3! n! (5) Consider, f (x) = a0 x n + a1 x n−1 +... + an−1 x + an Where a’s are constant (a0 6= 0) and n is a positive integer; is called a polynomial in x of degree n, and the equation f (x) = 0 is called an algebraic equation of degree n. If f (x) contains some other functions like exponential, trigonometric, logarithmic etc., the f (x) = 0 is called transcendental equation. for examples: x 3 − 3x + 6 = 0, x 5 − 7x 4 + 3x 2 + 36x − 7 = 0, x 2 − 3cos x + 1 = 0, xe x − 2 = 0 If the coefficients are pure numbers, they are called numerical equations. Therefore, we shall be describing some numerical methods for the solution of f (X ) = 0 where f (x) is algebraic or transcendental or both. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 20APPLIE / 64 SOLVING NONLINEAR EQUATIONS INTRODUCTION TO NUMERICAL ANALYSIS METHODS FOR FINDING THE ROOTS OF AN EQUATION I There two methods of finding roots of the equation f (x) and they are direct and indirect methods. DIRECT METHOD:- In some cases, roots can be found using direct analytical methods e.g. quadratic equations ax 2 + bx + c = 0, which has the roots √ −b ± b 2 − 4ac x1,2 = 2a and these are called closed form solution. For higher order polynomial equations and non-polynomial equations, it is difficult and in many cases, impossible, to get closed form solutions. Besides this, when numbers are substituted in available closed form solutions, rounding erors reduce their accuracy. INDIRECT METHOD:- These methods, also known as TRIAL and ERROR methods, are based on the idea of successive approximations, i.e., starting with one or more initial approximations to the value of the root, we obtain the sequence of approximations by repeating a fixed sequence of steps over and over again till we get the solution with reasonable accuracy. These methods generally Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 21APPLIE / 64 SOLVING NONLINEAR EQUATIONS INTRODUCTION TO NUMERICAL ANALYSIS METHODS FOR FINDING THE ROOTS OF AN EQUATION II give only one root at a time. For the human problem solver, these methods are very cumbersome, tiring and time consuming, but on other hand, more natural for use on computers, due to the following reasons: (1) These methods can be concisely expressed as computational algorithms. (2) It is possible to formulate algorithms which can handle class of similar problems. For example, algorithms to solve polynomial equations of degree n may be written. (3) Rounding errors are negligible as compared to methods based on closed form solutions. Theorem 1: Let f be a real-valued function, defined and continuous on a bounded closed interval [a, b] of the real line. Assuming further that, f (a)f (b) ≤ 0 then there exist e ∈ [a, b] such that f (e) = 0 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 22APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD ITERATION METHODS: Bisection method We shall discuss iterative methods for solving non-linear equations. These are (i) Bisection, (ii) Newton-Raphson method, (iii) Secant and (iv) Newton-Falsi method. The Bisection Method is based on the intermediate value theorem. Intermediate-Value Theorem Suppose h : R → R is a continuous function and there are two real numbers a & b such that f (a)f (b) < 0. Then, f (x) has at least one zero between a and b. BISECTION ALGORITHM (i) Find two numbers; a and b at which their functional values f (x) has two different signs, b+a (ii) Define c = 2 (iii) if b − c ≤ , then, accept c as the new root and stop (iv) if f (a)f (c) ≤ 0 then, set c as the new b and if f (a)f (c) > 0, set c as new a. return to step (ii) (v) Stop when the accuracy is achieved Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 23APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Example on Bisection Method Ėx. 1) Find the root of the equation x 6 − x − 1 = 0, with accuracy of = 0.001 Solution Step 1: we shall obtain two numbers where f (x) changes sign. suppose (a, b) = (1, 2); then f (1)f (2) < 0 since f (1) < 0 and f (2) > 0 so we take a = 1 and b = 2 Step 2: c = b+a 2+1 2 = 2 = 1.5 Step 3: 2 − 1.5 = 0.5 > Step 4: f (a) = f (1) = −1 and f (c) = f (1.5) = 8.890625 ∴ f (a)f (c) = −8.890625 Thus, (a,b)=(a,c)=(1,1.5). (Note: c becomes new b and this completed the first circle of the algorithm)... (The procedure continues until convergence is obtained) At 10th Iteration, a = 1.12890625, b = 1.1348, c = 1.131835938 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 24APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD The above solution can be presented in a tabular form as n a b f(a) f(b) c f(c) b-c 1 1.0000 2.0000 -1 61 1.5 8.8906 0.5000 2 1.0000 1.5000 -1 8.890625 1.25 1.564697266 0.2500........................ 10 1.12890625 1.134765625 -0.0590 0.0004 1.1318 -0.0295 0.00295 Ex. 2) Find the root of the equation x 3 − x − 1 = 0, lying between 1 and 2 by bisection method with accuracy of = 0.004. Ex. 3) Use the bisection method to find the smallest root of the function f (x) = 1 − 3x + 21 xe x correct to 2 significant figure. (NOTE: Ans x=0.45) Ex. 4) Using√Bisection method to find the real root of the equation f (x) = 3x − 1 + sinx = 0 correct to 4 decimal places. (ANS: x = 0.3985) Ex. 5) Using Bisection method obtain a real root of the equation f (x) = xe x = 3x correct to 4 significant figure. (ANS: x = 1.512) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 25APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Error bounds Let α be value of the root, a ≤ α ≤ b. Let an , bn and cn be the values of a, b, and c on the nth iteration of the algorithm. Then the error bound for cn is defined as 1 |α − cn | ≤ n (b − a) (6) 2 This inequality gives number of iterations needed for the required accuracy . To see how many iterations will be necessary in a problem, equation (6) can provide with the answer. PRACTICE EXAMPLES Determine the number of iterations to be perform for obtaining solution to the function f (x) = x 3 − x − 1 lying between 1 and 2 by Bisection Method correct to three decimal places. Then, approximate to the nearest whole number Ans: 10 Iterates Obtain the number of iterates to determine convergence of the equation x − cos x = 0 defined on the interval [0, 1] correct to four decimal places. Then, approximate to the nearest whole number Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 26APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Method of Successive Approximation I Method of Successive Approximation (simply refers to as fixed Iterative scheme) and also known as direct substitution method has the following procedure for solving problems: Given f (x) = 0 (7) Procedure for the Method of Successive Approximation i determine the interval for the solution using the intermediate value theorem (f (a) × f (b) < 0 =⇒ α ∈ [a, b] and where α being one of the root) ii rewrite the given equation (7) in the form x = g (x) (8) iii take an initial guess (approximation) as x0 iv find the 1st approximation x1 by using x1 = g (x) v obtain the successive approximant scheme (xi+1 ) by repeating and updating step iv vi stop evaluation when relative error is less or equal prescribed accuracy. NOTE: Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 27APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Method of Successive Approximation II The iteration method x = g (x) is convergent if |g 0 (x)| < 1 when |g 0 (x)| > 1 =⇒ −1 > g 0 (x) > 1, then, the iteration is divergent. Example Find a real root correct up to four decimal places of the equation 2x − logx − 7 = 0 using direct substitution methods. SOLUTION The given f (x) = 2x − logx − 7 = 04 step i f (1) = 2(1) − log (1) − 7 = −5 and f (2) = 2(2) − log (2) − 7 = −3.30102996 f (3) = 2(3) − log (3) − 7 = −1.477121255 and f (4) = 2(4) − log (4) − 7 = 0.397940008 Since f (3) × f (4) < 0, ∴ f (α) ∈ [3, 4] step ii Rewrite the given f (x) by making x the subject of the formula i.e. logx + 7 x= = g (x) 2 investigate whether or not g (x) converges or diverges. i.e. 0 0 g (x) = 2x1 ∀ x ∈ N, |g (x) | < 1 =⇒ convergence. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 28APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Method of Successive Approximation III step iii Take an initial approximation (say average of the interval of the solution) and determine the first approximation (x0 = 3.5) step iv log x0 + 7 log 3.5 + 7 x1 = = = 3.772034022 2 x0 =3.5 2 step v log xi + 7 xi+1 = ∀i ≥ 1 and k= any constant from step iv 2 xi =k for i = 1 log x1 + 7 x2 = = 3.788287801 2 x1 =3.772034022 log x1 + 7 x3 = = 3.789221483 2 x1 =3.788287801 log x1 + 7 x4 = = 3.789274995 2 x1 =3.789221483 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 29APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Newton-Raphson Method Newton-Raphson Method f (xi ) xi+1 = xi − , i = 0(1)... (9) f 0 (xi ) The proof of this shall be done in the class during the lesson. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 30APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD ALTERNATIVE PROVE OF N-R-METHOD This method can also be derived from Taylor’s series as follows: Let f(x) = 0 be the equation for which we are assuming x0 be the initial approximation and h be a small corrections to x0 , so that f (x0 + h) = 0 Expanding it by Taylor’s series, we get h2 00 f (x0 + h) = f (x0 ) + hf 0 (x0 ) + f (x0 ) +... 2! Since h is small, we can neglect second and higher degree terms in h and therefore, we get f (x0 + h) = f (x0 ) + hf 0 (x0 ) = 0 f (x0 ) =⇒ h = − 0 f (x0 ) Recall, interval on the x − axis is Hence, if x0 be the initial approximation, then, the subsequent iteration f (xn ) xn+1 = xn + h = xn − for n = 0, 1, 2, 3,... f 0 (xn ) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 31APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD N-R ALGORITHM Given f (x) = 0, the following steps are evaluated: 0 i Calculate f (x) symbolically, ii Choose an initial guess, x0 , f (x) iii Compute xi+1 = xi − f 0 (x) , ∀i = 0, 1, 2,... iv Stop the process when |xn+1 − xn | < , where is the prescribed accuracy v Suppose, it is required to find percentage error, |a | = | xi+1x−x i i | × 100 vi Check if || ≤ s It might sometime not converge because it is an open ended root selection. Thus, number of iteration may be specify to prevent divergence of solution. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 32APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Example 1 Find the real root of the equation x 2 − 5x + 2 = 0 between 4 and 5 by Newton-Raphson’s Method. Sol. Let f (x) = x 2 − 5x + 2 (10) Now, f (4) = 42 − 5 × 4 + 2 = −2 (11) f (5) = 52 − 5 × 5 + 2 = 2 Therefore, the root lies between the given 4 and 5. From (10), we get f 0 (x) = 2x − 5 (12) Transforming (10) and (12) into N-R-M to have f (xn ) xn+1 = xn − for n = 0, 1, 2, 3,... f 0 (xn ) (13) x 2 − 5xn + 2 xn+1 = xn − n for n = 0, 1, 2, 3,... 2xn − 5 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 33APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Example 1 (Contd.) Take x0 = 4 to iterate (13) First Approximation, i.e. for n = 0 x02 − 5x0 + 2 x1 = x0 − 2x0 − 5 2 4 − 5(4) + 2 x1 = 4 − = 4.6667 2(4) − 5 Second Approximation, i.e. for n = 1 x12 − 5x1 + 2 x2 = x1 − 2x1 − 5 4.66672 − 5(4.6667) + 2 x2 = 4.6667 − = 4.5641 2(4.6667) − 5 Third Approximation, i.e. for n = 2 x22 − 5x2 + 2 x3 = x2 − 2x2 − 5 4.56412 − 5(4.5641) + 2 x3 = 4.5641 − = 4.5616 2(4.5641) − 5 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 34APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Example 1 (Contd.) Fourth Approximation, i.e. for n = 3 x32 − 5x3 + 2 x4 = x2 − 2x3 − 5 4.56162 − 5(4.5616) + 2 x4 = 4.5616 − = 4.5616 2(4.5616) − 5 Since x3 = x4 , hence the root of the equation is 4.5616, correct to four decimal places. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 35APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Example 2 Question: Find the root of the equation x 6 − x − 1 = 0, with accuracy of = 0.001 Solution From previous example on Bisection method, the root of the function is 0 between 1 and 2, so we take x0 = 1.5, f (x) = x 6 − x − 1, f (x) = 6x 5 − 1 and accuracy of = 0.001 as our first/initial guess and the following results were obtained for few iterations i x1 = 1.300490884 ii x2 = 1.181480416 iii x3 = 1.13945559 iv x4 = 1.134777625 v x5 = 1.134724145 vi x6 = 1.134724138 stopping criterion |xn+1 − xn | = |x5 − x4 | < Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 36APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Example 3 Use Newton’s method to find the zeros of f (x) = 1 − 3x + 12 xe x accurate to five decimal places. x0 = 0.5, x1 = 0.450200, x2 = 0.451541, x3 = 0.451542, x4 = 0.451542 STUDENTS’ ACTIVITY: Try same problem (Example 2) but with x0 = 1.6. You will observed that x0 = 1.6, x1 = 1.552769, x2 = 1.549552, x3 = 1.549538, x4 = 1.549538, so to an accuracy of five decimal places the largest zero of f (x) is 1.54954. DRAWBACK OF NEWTON-RAPHSON METHOD This examples illustrate the speed with which Newton’s method can converge to a zero when a good starting approximation is used and the tangent to the graph y = f (x) at a zero is not inclined at a small angle to the x-axis making high accuracy difficult to obtain. A poor starting approximation can cause Newton’s method to diverge from the required zero. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 37APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD FLOW CHART FOR NEWTON-RAPHSON METHOD Figure 1: Newton Raphson’s Flowchart Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 38APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Secant Method Newton’s method is very powerful but has the disadvantage of derivative. The 0 derivative f (x) may sometimes be a far more difficult expression than f (x) itself and its evaluation becomes computationally expensive. This situation suggests the idea of replacing the derivative with the difference quotient defined as 0 f (xn ) − f (xn−1 ) f (xn ) ≈ (14) xn − xn−1 equation (14) is obtained from Taylor’s series expansion of f (x). That is; 0 f (xn+1 ) ≈ f (xn ) + (xn+1 − xn )f (xn ) = 0 (15) Hence, the Secant Method is xn − xn−1 xn+1 = xn − f (xn ) ,n ≥ 1 (16) f (xn ) − f (xn−1 ) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 39APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Procedure for Implementing Secant Method Choose the interval [x0 , x1 ] in which f (x) = 0 has a root, where x1 > x0 , Find the next approximation, x2 of the required root using expression (x1 − x0 ) x2 = x1 − f (x1 ) f (x1 ) − f (x0 ) Find the successive approximations of the required root using the formula (xn − xn−1 ) xn+1 = xn − f (xn ) n = 1, 2, 3,... f (xn ) − f (xn−1 ) Stop the process when the prescribed accuracy is obtained. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 40APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD Examples on Secant Method (1) Find the positive solution of f (x) = Cosx − xe x = 0 by the secant method, starting x0 = 0, x1 = 1 correct to 5 Decimal Places. Solution Using f (xn )(xn − xn−1 ) xn+1 = xn − for n ≥ 1 f (xn ) − f (xn−1 ) − xn e xn + Cos (xn ) (xn − xn−1 ) (17) = xn − − xn e xn + Cos (xn ) − − xn−1 e xn−1 + Cos (xn−1 ) For n = 1 − x1 e x1 + Cos (x1 ) (x1 − x0 ) x2 = x1 − − x1 e x1 + Cos (x1 ) − − x0 e x0 + Cos (x0 ) = 0.314665337... x7 = 0.51775737 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 41APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD PRACTICE QUESTION AND WEEK 6 QUIZ PRACTICE QUESTION Find the root of the equation x x 2 e 2 = 1 ∈ [0, 2] defined on the corresponding interval correct to three decimal places. QUIZ QUESTION (A) Define Secant Iterative Scheme (B) Use the scheme defined in (A) above to compute the root of the equation x x 2e − 2 = 1 in the interval [0, 2] correct to 3 decimal places Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 42APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD SOLUTION TO THE WEEK 6 QUIZ I Solution (A) The Secant Iterative Scheme is defined as f (xn )(xn − xn−1 ) xn+1 = xn − for n ≥ 1 (18) f (xn ) − f (xn−1 ) (B) Using the scheme f (xn )(xn − xn−1 ) xn+1 = xn − for n ≥ 1 f (xn ) − f (xn−1 ) x Given f (x) = x 2 e − 2 − 1 = 0 ∈ [0, 2], Let x0 = 0, x1 = 2, f (0) = −1, f (2) = 0.471517764 Now, xn xn2 e − 2 − 1 (xn − xn−1 ) xn+1 = xn − xn xn−1 xn2 e − 2 − 1 − xn−1 2 e− 2 − 1 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 43APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD SOLUTION TO THE WEEK 6 QUIZ II x1 x12 e − 2 − 1 (x1 − x0 ) 0.471517764 (2 − 0) for n = 1, x2 = x1 − x1 x0 =2− x12 e − 2 − 1 − x02 e − 2 − 1 0.471517764 − − 1 = 1.359140914 x2 x22 e − 2 − 1 (x2 − x1 ) x3 = x2 − x2 x1 x22 e − 2 − 1 − x12 e − 2 − 1 − 0.06742579 (1.359140914 − 2) = 1.359140914 − 1.359140914 − 0.471517764 = 1.435458937... x5 = 1.429611805 and f (x5 ) = −0.000000017 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 44APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD SOLUTION TO THE WEEK 6 QUIZ III The stopping criterion is |x5 − x4 | = 0.000036112 < 10−4 and the root of equation x x 2 e − 2 − 1 = 0 ∈ [0, 2] is 1.429 to 3D.P. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 45APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD (2) Find the root of the equation x 6 − x − 1 = 0, with accuracy of = 0.001 and α = 1.134724138 Solution Similarly to example in the last frame, for n = 1, x0 = 1 and x1 = 2 f (x1 )(x1 − x0 ) x2 = x1 − f (x1 ) − f (x0 ) (1.06 − 1.0 − 1) (2 − 1) =1− 1.06 − 1.0 − 1 − (2.06 − 2.0 − 1) 1 =1− = 1.016129032 −62 n xn f (xn ) xn − xn−1 α − xn−1 0 1.000000 1 2.0000000 2 1.016129032 3 1.030674754 4 1.175688945............ Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 46APPLIE / 64 SOLVING NONLINEAR EQUATIONS ITERATIVE METHOD SUMMARY OF SECANT METHOD WITH ESTIMATED ERROR i Choose i = 1 ii Start with initial guess xi , xi−1 (xi −xi−1 )f (xi ) iii Use xi+1 = xi − f (xi )−f (xi−1 ) i ≥1 −xi iv Determine |Ea | = | xi+1xi+1 | × 100 v |Ea | ≤ Es (Pre-specified Tolerance ), If TRUE, stop, ELSE, Step 3. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 47APPLIE / 64 CURVE FITTING CURVE FITTING: PRINCIPLE OF LEAST SQUARES I Principle of Least Square The principle of least sqaure consists of determining the values of the unknown parameters that will minimize the sum of squares of error. Let the curve y = a + bx + cx 2 +... + kx m−1 (19) be fitted to the set of n data points (x1 , y1 ), (x2 , y2 ), (x3 , y3 ),... , (xn , yn ) At x = xi , the observed value of the ordinate is yi = pi mi and the corresponding value on the fitting curve in (19) is a + bxi + cxi2 +... + kxim−1 = Li Mi (20) which is the expected/calculated value. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 48APPLIE / 64 CURVE FITTING CURVE FITTING: PRINCIPLE OF LEAST SQUARES II The difference of the observed and the expected value Pi Mi − Li Mi = ei (21) Some of the error will be positive and others negative. To make all errors positive, we square each of the errors and sum S = e12 + e22 + e32 +... + en2 (22) The curve of best fit is that for which e 0 s are small as possible. The sum of the square of the errors is a minimum and it is known as the principle of least square. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 49APPLIE / 64 CURVE FITTING FITTING OF STRAIGHT LINE FITTING OF STRAIGHT LINE I Let a straight line y = a + bx (23) which is fitting to the given points (x1 , y1 ), (x2 , y2 ), (x3 , y3 ),... , (xn , yn ) Suppose, yλ be the theoretic value for x, then, e1 = y1 − yλ (24) Assume equation (23) to be theoretic value fitted and substitute it in equation (24) to have e1 = y1 − (a + bx1 ) (25) e12 = (y1 − a − bx1 )2 (26) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 50APPLIE / 64 CURVE FITTING FITTING OF STRAIGHT LINE FITTING OF STRAIGHT LINE II We have n X S = e12 + e22 + e32 +... + en2 = ei2 (27) i=1 Simply, n X S= (yi − a − bx)2 (28) i=1 By the principle of least square, the value of S is minimum. ∴ ∂S =0 ∂a (29) ∂S =0 ∂b solving the last two equations (29) and dropping the higher orders to have X X y = na + b x (30) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 51APPLIE / 64 CURVE FITTING FITTING OF STRAIGHT LINE FITTING OF STRAIGHT LINE III X X X xy = a x +b x2 (31) The equations(30) and (31) are known as normal equations. On solving the equations, the value of 0 a0 and 0 b 0 is obtained. Then, put the values in equation (23), the result is referred to as the line of best fit. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 52APPLIE / 64 CURVE FITTING FITTING OF PARABOLA FITTING OF PARABOLA I Similarly to prove in the last frame, let a parabolic equation be defined as y = a + bx + cx 2 (32) which is fitting to the given points (x1 , y1 ), (x2 , y2 ), (x3 , y3 ),... , (xn , yn ) Let yλ be the theoretic value for x, then, e1 = y1 − yλ (33) Assume equation (32) to be theoretic value fitted and substitute it in equation (33) to have e1 = y1 − (a + bx1 + cx12 ) (34) e12 = (y1 − a − bx1 − cx12 )2 (35) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 53APPLIE / 64 CURVE FITTING FITTING OF PARABOLA FITTING OF PARABOLA II In a general form, n X S= (yi − a − bxi − cxi2 )2 (36) i=1 Applying the principle of least square, the value of S becomes minimum. ∂S =0 ∂a ∂S ∴ =0 (37) ∂b ∂S =0 ∂c solving the last two equations (37) and dropping the higher orders to have X X X y = na + b x +c x2 (38) X X X X xy = a x +b x2 + c x3 (39) Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 54APPLIE / 64 CURVE FITTING FITTING OF PARABOLA FITTING OF PARABOLA III X X X X x 2y = a x2 + b x3 + c x4 (40) The equations (38), (39) and (40) are known as normal equations of parabola. On solving the equations, the value of 0 a0 and 0 b 0 is obtained. Then, put the values in equation (32), the result is referred to as the line of best fit. Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 55APPLIE / 64 CURVE FITTING CHANGE OF SCALE CHANGE OF SCALE Change of scale is required when the magnitude of the given variable is large, then, calculation becomes very much tedious. overcome this difficulty, taking suitable scale for the given value of x at equally spaced intervals. Let h be the width of the interval at which the values of x are given and let the origin of x and y be taken at the point (xo , yo ) respectively, then, putting x − xo U= , and v = y − yo (41) h If x is odd, then, x-middle term U= (42) h If x is even, then, x − mean of two middle term U= 1 (43) 2h Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 56APPLIE / 64 CURVE FITTING CHANGE OF SCALE EXAMPLES I EXAMPLE 1 Find the best fit values of a and b so that y = a + bx fits the data given in the table x 0 1 2 3 4 y 1.0 1.8 3.3 4.5 6.3 Solution Recall: The equation of a straight line is y = a + bx and Normal equations are X X y = na + b x X X X (44) xy = a x +b x2 Then, we prepare table for parameters of the equations Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 57APPLIE / 64 CURVE FITTING CHANGE OF SCALE EXAMPLES II x y x2 xy 0 1 0 0 1 3 1 3 3 2 9 6 6 5 36 30 8 4 64 32 18 15 110 71 Using equation of straight line in least square in (44) and for n = 5 15 = 5a + 18b (45) 71 = 18a + 110b Solving (45) simultaneously, we have a = 1.6460, b = 0.3761. Hence, the fitted equation of straight line is y = 1.646 + 0.376x Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 58APPLIE / 64 CURVE FITTING CHANGE OF SCALE EXAMPLES III Figure 2: Plot of actual data and approximate (curve fitted) data Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE Numerical DEPARTMENT Analysis OF MATHEMATICS, FACULTY OF COMPUTING AND 59APPLIE / 64 CURVE FITTING CHANGE OF SCALE EXAMPLES IV EXAMPLE 2 Fit a straight line to the given data regarding x as the independent variable x 1 2 3 4 5 6 y 1200 900 600 200 110 50 EXAMPLE 3 Fit a straight line to the given data regarding x as the independent variable x 1 2 3 4 6 8 y 2.4 3.1 3.5 4.2 5.0 6.0 Lukman O. AHMED[0.2cm] LECTURE NOTE AND GUIDE[0.2cm] MTH FROM 312:THE