1. Trang chủ
  2. » Luận Văn - Báo Cáo

Assignment report group 1 solve equations in 1 variable using many methods)

16 0 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Solve Equations in 1 Variable Using Many Methods
Tác giả Phan Phỳc Phi, Lương Quang Khỏnh, Nguyễn Minh Khang, Dương Tiờu Hồng Chõu, Nguyễn Minh Nhật
Người hướng dẫn Phan Th`anh An, Lecturer
Trường học HCMC University of Technology
Chuyên ngành Numerical Analysis
Thể loại Assignment Report
Thành phố Ho Chi Minh City
Định dạng
Số trang 16
Dung lượng 2,31 MB

Nội dung

Numerical AnalysisProject 3 Method 1: the Method of False Position Contributed by Dương Tiêu Hồng Châu and Nguyễn Minh Khang I.. Each successive pair of approximations in the Bisection

Trang 1

HCMC UNIVERSITY OF TECHNOLOGY

ASSIGNMENT REPORT Lecturer: Phan Th`anh An

Class: CC01

GROUP 1 (Solve equations in 1 variable using many methods) Group member :

Phan Phúc Phi -1752410

Lương Quang Khánh -2053115

Nguyễn Minh Khang _ 1952762

Dương Tiêu Hồng Châu - 1852275

Nguyễn Minh Nhật - 2053297

Trang 2

Table of Contents

Catalog

ASSIGNMENT REPORT 1

Method 1: the Method of False Position 3

I THEOREM 3

II PROGRAMING CODE 5

III Example 6

Method 2 :the Secant Method 8

I THEOREM 8

II PROGRAMING CODE 10

III.EXAMPLE 10

Method 3 : the Modified Newton method 12

I THEOREM 12

II PROGRAMING CODE 13

III Example 14

References 15

Trang 3

Numerical AnalysisProject

3

Method 1: the Method of False Position

((Contributed by Dương Tiêu Hồng Châu and Nguyễn Minh Khang)

I. THEOREM

The term Regula Falsi, literally a false rule or false position, refers to a technique that uses results that are known to be false, but in some specific manner, to obtain convergence to a true result False position problems can be found on the Rhind papyrus, which dates from about 1650 b.c.e

Each successive pair of approximations in the Bisection method brackets a root of thep

equation; that is, for each positive integer , a root lies between and This implies that, forn

each , the Bisection method iterations satisfyn

| −p| < | − |,

which provides an easily calculated error bound for the approximations Root bracketing

is not guaranteed for either Newton’s method or the Secant method In Example 1, Newton’s method was applied to f(x) =cosx−x, and an approximate root was found to be 0.7390851332 Table 2.5 shows that this root is not bracketed by either and or and The Secant method approximations for this problem are also given in Table 2.5 In this case the initial approximations and bracket the root, but the pair of approximations and fail to do so

The method of False Position (also called Regula Falsi) generates approximations in the same manner as the Secant method, but it includes a test to ensure that the root is always bracketed between successive iterations Although it is not a method we generally recommend, it illustrates how bracketing can be incorporated

First choose initial approximations and with f()·f()<0 The approximation is chosen in the same manner as in the Secant method, as the x-intercept of the linejoining (,f()) and

(,f()).To decide which secant line to use to compute , consider f()·f(), or more correctly sgnf()·sgnf()

• If sgnf()·sgnf()<0, then and bracket a root Choose as the x-intercept of the line joining

(,f()) and (,f()).

• If not, choose as the x-intercept of the line joining (,f()) and (,f()), and then interchange the indices on and

In a similar manner, once p3 is found, the sign of f()·f() determines whether we use and

or and to compute In the latter case a relabeling of and is performed The relabeling ensures that the root is bracketed between successive iterations The process is described

in Algorithm 2.5, and Figure 2.11 shows how the iterations can differ from those of the Secant method In this illustration, the first three approximations are the same, but the fourth approximations differ

Trang 4

Numerical AnalysisProject

4

Algorithm 2.5

False Position

To find a solution to f(x) = 0 given the continuous function on the interval [ ] where f , f()

and have opposite signs:f()

INPUT initial approximations ,; tolerance TOL; maximum number of iterations OUTPUT approximate solution p or message of failure

Step 1 Set i=2;

= f();

= f()

Step 2 While do Steps 3–7 i≤

Step 3 Set p= − ( −)/( −) (Compute pi.)

Step 4 If|p−| < TOL then

OUTPUT (p) (The procedure was successful.) ;

STOP

Step 5 Set i=i+1;

q= f(p)

Step 6 If q· < 0 then set =;

=

Step 7 Set =p;

=q

Step 8 OUTPUT (‘Method failed after iterations, =’, );

(The procedure unsuccessful.)

STOP

II.PROGRAMING CODE

Code for C++:

Trang 5

Numerical AnalysisProject

5

Trang 6

III. Example

Excerpted from Question a, Exercise set 9 2.3 in Numerical Analysis (9th Edition) :

Given function = x - 2x - 5 = 0 within the interval [1, 4] approximately accurate within3 2

10 −4

Manual Solution:

Write the original equation:

Assume that: , with opposite signs:

we use the endpoints of the interval [1,4] as and , that is, take and as two initial approximations

We have the following table:

→ thus, we get 2.690642 after 18 interations (not inclue n=1)

Trang 7

C++ solution:

Trang 8

Method 2 :the Secant Method

(Contributed by Nguyễn Minh Nhật and Dương Tiêu Hồng Châu )

I. THEOREM

Newton’s method is an extremely powerful technique, but it has a major weakness: the need to know the value of the derivative of f at each approximation Frequently, f(x) is far more difficult and needs more arithmetic operations to calculate than f(x)

To circumvent the problem of the derivative evaluation in Newton’s method, we introduce

a slight variation By definition,

f =

If is close to , then:

f =

Using this approximation for f’ in Newton’s formula gives

Trang 9

This technique is called the Secant method and is presented in Algorithm 2.4 (See Figure 2.10.) Starting with the two initial approximations and , the approximation is the x-intercept of the line joining (,f()) and (,f()).The approximation is the x-intercept of the line joining (,f()) and (,f()), and so on Note that only one function evaluation is needed per step for the Secant method after has been determined In contrast, each step of Newton’s method requires an evaluation of both the function and its derivative

The word secant is derived from the Latin word “secan”, which means to cut The secant method uses a secant line, a line joining two points that cut the curve, to approximate a root

Algorithm 2.4

Secant

To find a solution to f(x) = 0 given initial approximations and :

INPUT initial approximations ,; tolerance TOL; maximum number of iterations

OUTPUT approximate solution p or message of failure

Step 1 Set i=2;

q0 = f();

q1 = f()

Step 2 While i ≤ do Steps 3–6

Step 3 Set p = − ( −)/( −) (Compute )

Step 4 If |p−p1| < TOL then

OUTPUT ( ); (The procedure was successful.) p

STOP

Step 5 Set i=i+1.

Step 6 Set =;(Update ,,,.)

Trang 10

=;

= ; p

= f(p)

Step 7 OUTPUT (‘The method failed after iterations, =’, );

(The procedure was unsuccessful.) STOP

II.PROGRAMING CODE

C++ code:

Trang 11

III.EXAMPLE

Trang 12

Example from the book Numerical Analysis, 9th Edition by Richard L Burden, J Douglas

Faires:

Use Secant’s method to find solutions accurate to within for the following problem:

for 0

 Actual root:

Using Wolfram Alpha, we can calculate the actual root:

 The Secant program method:

First we transform the equation:

=>

The function in C++:

Input:

Output:

Error:

Which is less then , satisfying the requirement

Trang 13

Method 3 : the Modified Newton method

(Contributed by Phan Phúc Phi and Lương Quang Khánh)

I. THEOREM

II.PROGRAMING CODE

Trang 14

Code Matlab:

Trang 15

III. Example

We use the following input for Modified Newton method function:

a The manual method

We have:

From that, we can calculate step-by-step like so

1

2

3

4

5

b Program method

We can see that both manual method and program method yield same results

Trang 16

[1] Burden, R L., Faires, J D., & Burden, A M (2016) Chapter 2: Solutions of Equations in One Variable In Numerjcal Analysis (10th Edition,

p 49) Cengage Learning

[2] Burden, R L., Faires, J D., & Burden, A M (2010) Chapter 2: Solutions of Equations in One Variable In Numerical Analysis (9th Edition,

p 54) Cengage Learning

[3] Burden, R L., Faires, J D., & Burden, A M (2016) Chapter 2: Solutions of Equations in One Variable In Numerical Analysis (10th Edition,

p 59) Cengage Learning

[4] Lˆe, T T (2019) Chuong 2 In Ph ng uo Ph´ap T´ınh (p 22)

VNU- HCMC

[5] Burden, R L., Faires, J D., & Burden, A M (2016) Chapter 2: Solutions of Equations in One Variable In Numerical Analysis (10th Edition,

p 67) Cengage Learning

[6]Newton Raphson Method Brilliant orf Retrieved May1, 2021, from https://brilliant.org/wiki/newton-raphson-method/

Ngày đăng: 08/11/2024, 17:22