• 沒有找到結果。

Solutions of equations in one variable

N/A
N/A
Protected

Academic year: 2022

Share "Solutions of equations in one variable"

Copied!
4
0
0

加載中.... (立即查看全文)

全文

(1)

Solutions of equations in one variable

December 23, 2013

Problem: Solve the following nonlinear equation f (x) ≡ π +1

2sinx 2

− x = 0, x ∈ [0, 2π]. (1)

• Bisection method: Iff (x) ∈ C[a, b]and f (a)f (b) < 0, then ∃ c ∈ (a, b)such thatf (c) = 0.

Figure 1: Bisection method

Given f (x) defined on (a, b), the maximal number of iterations M , and stop criteria δ and ε, this algorithm tries to locate one root of f (x).

Compute u = f (a), v = f (b), and e = b − a If sign(u) = sign(v), then stop

For k = 1, 2, . . . , M

e = e/2, c = a + e, w = f (c) If |e| < δ or |w| < ε, then stop If sign(w) 6= sign(u)

b = c, v = w Else

a = c, u = w End If

End For

Algorithm 1: Bisection method

• Fixed-point iteration or functional iteration: Given a continuous function g, choose an initial point x0 and generate {xk}k=0 by

xk+1= g(xk), k ≥ 0.

Take g(x) = π +12sin x2.

1

(2)

Given x0, tolerance T OL, maximum number of iteration M . Set i = 1 and x = g(x0).

While i ≤ M and |x−x|x|0| ≥ T OL Set i = i + 1, x0= x and x = g(x0).

End While

Algorithm 2: Fixed point iteration

• Newton’s method: Starts with an initial approximation x0 and generates the sequence {xn}n=0 defined by

xn+1= xn− f (xn) f0(xn).

Given x0, tolerance T OL, maximum number of iteration M . Set i = 1 and x = x0− f (x0)/f0(x0).

While i ≤ M and |x−x|x|0| ≥ T OL

Set i = i + 1, x0= x and x = x0− f (x0)/f0(x0).

End While

Algorithm 3: Newton’s method

Figure 2: Newton’s method

Consider the nonlinear eigenvalue problem

A(v)v ≡



A0+ sin v>Bv v>v

 A1



v = λv, where

A0= 1 10

10 21 13 16

21 −26 24 2

13 24 −26 37

16 2 37 −4

, A1= β 10

20 28 12 32

28 4 14 6

12 14 32 34 32 6 34 16

 ,

B = 1 10

−14 16 −4 15

16 10 15 −9

−4 15 16 6

15 −9 6 −6

 .

2

(3)

The Jacobian matrix of A(v)v is

J (v) = ∂

∂v(A(v)v) = A(v) + 2 cos

v>Bv v>v



(v>v)2 A1v v>v v>B − v>Bv v>

Apply Newton method to solve the nonlinear eigenvalue problem and rewrite the nonlinear eigen- value problem as

F

 v λ



=

 A(v)v − λv

`Tv − 1



= 0, (2)

where ` ∈ Rn is a suitable fixed nonzero vector. The Jacobian matrix of (2) is J F

 vk

λk



=J(vk) − λkI −vk

`T 0



. (3)

The Newton iteration is of the form

 vk+1

λk+1



= vk

λk



 J F

 vk

λk

−1A(vk)vk− λkvk

`Tvk− 1



. (4)

• Secant method: Using the approximation

f0(xn−1) ≈ f (xn−1) − f (xn−2) xn−1− xn−2

. for f0(xn−1) in Newton’s formula gives

xn = xn−1−f (xn−1)(xn−1− xn−2) f (xn−1) − f (xn−2) .

Given x0, x1, tolerance T OL, maximum number of iteration M . Set i = 2; y0= f (x0); y1= f (x1); x = x1− y1(x1− x0)/(y1− y0).

While i ≤ M and |x−x|x|1|≥ T OL

Set i = i + 1; x0= x1; y0= y1; x1= x; y1= f (x);

x = x1− y1(x1− x0)/(y1− y0).

End While

Algorithm 4: Secant method

Figure 3: Secant method

3

(4)

Home works

1. Plot the figure of the function f (x) on [0, 2π].

2. Use Bisection method, fixed point iteration and Newton’s method to solve (1). In each iteration, please output the approximation x1 and the relative error |x1|x−x0|

1| . Use MATLAB command function:

1. Build two functions, said “fun f” and “fun df”, to compute the values f (x) and f0(x), respectively.

2. Rewrite your previous MATLAB code of Bisection method, fixed point iteration and Newton’s method with using the functions “fun f” and “fun df”.

4

參考文獻

相關文件