1 Solution of Nonlinear Equation Dr. Asaf Varol [email protected].

34
1 Solution of Nonlinear Equation Dr. Asaf Varol [email protected]

Transcript of 1 Solution of Nonlinear Equation Dr. Asaf Varol [email protected].

Page 1: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

1

Solution of Nonlinear Equation

Dr. Asaf Varol

[email protected]

Page 2: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

2

Introduction

• Solutions to algebraic, differential, and integral equations relating certain physical parameters for a given problem

• Algebraic equations divided into two categories: (1) Linear and (2) Nonlinear

• Linear: an equation which contains the first power of the unknown, explicitly or implicitly, indicating a linear variation of the unknown parameter as a function of the other known parameters.

• Example: distance, s, traveled by an object which was originally at a location s = s0 at time t = 0, and moving at constant speed, v, is related to time by

s = s0 + vt • which is a linear relationship between s and v , and also between s

and t since v is assumed not changing with time.

Page 3: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

3

Introduction (Cont’d)

• Nonlinear: an equation involving variables which contains at least one term with an exponent other than unity and/or any explicit or implicit non-linear function of that particular parameter which we want to solve for.

• Example: Suppose that dv/dt = constant = a 0, i.e. there is a constant acceleration (or a body force such as gravity) acting on the object, then the relation between s and t becomes

s = s0 + v0t + (a/2)t2

• where v0 is the initial speed. This equation has a nonlinear relationship between the distance, s, and the time, t, because it involves the square of the parameter t.

• Example: the following relation between the angle, , of a pendulum at time, t, is a nonlinear relation.

= 0cos(t)

where = (g/L)1/2 is the frequency of the oscillations , 0 is the initial starting angle , g is the acceleration of the gravity, and L is the length of the connecting rod. This equation is nonlinear because the trigonometric function cos() is a nonlinear function.

Page 4: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

4

Introduction (Cont’d)• Case for an object with changing acceleration as a result of drag

• Case of motion of an object which was thrown vertically upward with an initial velocity of v0 = 100 m/s; hence b0 = -g = -9.8 m/s2; let c = 0.1 (1/s) and s0 = 0

v e t 100 198 1 01

s t e t 98 1980 1 0 1.

Find the velocity and the time at which the distance s = 0; (Note that t = 0, s = 0, v = 100 m/s is the trivial solution and we are not looking for this trivial solution). The equation to be solved first is s e tt 0 1980 1 98 00 1 .

d s

d tv s s ; ( )0 0 ( 2 . 1 . 4 a )

00 0; vvcvbdt

dv ( 2 . 1 . 4 b )

w h e r e b 0 i s a b o d y f o r c e p e r u n i t m a s s s u c h a s a c c e l e r a t i o n o f g r a v i t y , c i s a d r a g c o e f f i c i e n t w h i c h c a n b e t a k e n a s c o n s t a n t . T h e s o l u t i o n t o t h e E q s ( 2 . 1 . 4 a , b ) i s g i v e n b y

v vc

b c v e c t 0 0 0

11 ( 2 . 1 . 5 a )

s sb

ct

cb c v e c t

00

2 0 0

11 ( 2 . 1 . 5 b )

Page 5: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

5

Graphical Method and Scanning

for t=-10:30 ft=(1-exp(-0.1*t)-0.05*t) plot(t,ft,'r*') hold on grid onendxlabel('t(sec)')ylabel('F(t)')

Page 6: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

6

Graphical Method and Scanning (Cont’d)

for t=-10:30 ft1=exp(-0.1*t) ft2=1-0.05*t plot(t,ft1,'r*',t,ft2,'b+') hold onendtext(10,2.5,'* f(t)=exp(-0.1t)')text(10.,2.2,'+ f(t)=1-0.05t')xlabel('t(sec)')ylabel('F(t)')

Page 7: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

7

Example E.2.1 P r o b l e m : F i n d a n a p p r o x i m a t e r o o t b y s c a n n i n g o f t h e f u n c t i o n

F t t e t( ) . . 4 0 8 3 3 1 0 1

S o l u t i o n : L e t t = 1 0 s e c o n d s a n d s c a n s t a r t i n g f r o m t = 0 . F r o m T a b l e 2 . 1 w e d e t e c t t h a t t = 4 0 i s a na p p r o x i m a t e r o o t . T h e e x a c t r o o t i s s o m e w h e r e i n t h e i n t e r v a l ( 4 0 , 5 0 ) b e c a u s e t h e f u n c t i o n c h a n g e ss i g n i n t h i s i n t e r v a l .

T a b l e 2 . 1 V a l u e s o f t h e f u n c t i o n F t t e t( ) . . 4 0 8 3 3 1 0 1

t f ( t ) 0 0 . 0 1 0 - 1 5 . 8 1

2 0 - 1 5 . 3 1 3 0 - 8 . 8 0 4 0 - 0 . 0 8 5 5 0 9 . 4 4

Page 8: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

8

Example E.2.2

Problem: Find two smallest positive roots of the nonlinear equation F( ) exp . sin 1 05 100 0 by scanning. Table E2.2 Scanning of F( ) of Example E.2.2 using various intervals

F()0 -1.0001 -0.5062 -0.5053 -0.5544 -0.4455 -0.139

root1(5.5)6 0.2937 0.7258 1.0229 1.087

10 0.88811 0.469

root2(11.5)12 -0.061

F()0.0 -1.0000.1 -1.400

root1(0.15)0.2 0.1890

root2(0.25)0.3 -1.591

(iii) =0.01 F()

0.00 -1.0000.01 -0.1440.02 -0.0610.03 -0.8140.04 -1.6980.05 -1.8850.06 -1.1920.07 -0.241

root1(0.075)0.08 0.105

root2(0.085)0.09 -0.458

(iv) =0.005 F()

0.00 0.0000.005 -0.5130.010 -0.144

root1(0.0125)

0.015 0.020 root2(0.0175)

0.020 -0.061

(i) =1.0 (ii) =0.1

Page 9: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

9

Bisection Method

• Bisection is a systematic search technique for finding a zero of a continuous function. The method is based on first finding an interval in which a zero is known to occur because the function has opposite signs at the ends of the interval, then dividing the interval into two equal subintervals, and determining which subinterval contains a zero, and continuing the computations on the subinterval that contains the zero.

• Suppose that an interval [a, b] has been located which is known to contain a zero, since the function changes signs between a and b. The midpoint of the interval ism=(a+b)/2and a zero must lie in either [a, m] or [m, b].

Page 10: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

10

Bisection method

• The appropriate subinterval is determined by testing the function to see whether it changes sign on [a, m]. If so, the search continues on that interval; otherwise, it continues on the interval [m, b]. Figure illustrates the first approximation to the zero of the function

• Y=f(x)=x2-3, starting with the interval [1, 2] [2].

Page 11: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

11

Example

Page 12: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

12

Example (Cont’d)

• It is convenient to keep track of the calculations in tabular form.

Page 13: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

13

Matlab program for Bisection Method

Page 14: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

14

Results

Page 15: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

15

Bisection Method (sometimes does not work at all)

• Bisection method frequently converges slowly and sometimes does not work at all.

Figure 2.2.3 Illustration of a situation where bisection method will not work F(x)0 in the interval (x1,x2); F(x)0 in the interval (x3,x4):in both intervals there is a root.

Page 16: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

16

Example E2.2.1

Page 17: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

17

Example E2.2.3

Page 18: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

18

Example E2.2.3 (Cont’d)

Page 19: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

19

False-Position (Regula Falsi) Method

• False-Position (or Regula-Falsi) Method is similar to the bisection method, with a slight improvement in the convergence rate.

• Upper and lower bound of the root are used to locate a usually better estimate.

Page 20: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

20

False-Position (Regula Falsi) Method (Cont’d)

x x

x x F x

F x F xr lu l l

u l

similarly one can show

x xx x F x

F x F xr uu l u

u l

Figure 2.2.4 Illustration of the false-position method

Page 21: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

21

False-Position Method (Cont’d)

• However, there are special cases where the false-position method does not give a better estimate than bisection method.

Figure 2.2.5 Special case for which the false-position method is not better than the bisection method.

Page 22: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

22

Matlab program for Regula Falsi

Page 23: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

23

Results

Page 24: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

24

Fixed-Point Iteration Method

• Simplest method for finding roots of nonlinear equations (also known as the “Simple Iteration Method”)

• Equations need to be of the form a = g(a)– Example:

F(x) = x – ln (4 + x) = 0

can be rearranged to

x = ln (4 + x) = f(x)

• General Iteration Procedure:

xi+1 = f(xi)

Page 25: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

25

Matlab program for fixed point Method

Page 26: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

26

Diagram

Page 27: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

27

Results

Page 28: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

28

Newton-Raphson Method

Newton-Raphson method can be derived using a Taylor series expansion about the point x = xi

F(xi+1) = F(xi) + F(xi)h + F(xi)h2/2 + F(xi)h3/6 + ...

where xi+1 is the next estimate to the root, and h = xi+1 - xi

• If the next iterate (xi+1) is approximately the root, then F(xi+1) 0

• The Newton-Raphson method is obtained by truncating the Taylor series at the second term and solving for xi+1

)x('F

)x(Fxx

i

ii1i

Page 29: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

29

Flow Diagram (Newton Raphson)

Page 30: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

30

Newton-Raphson Method (Cont’d)

• Error - the error is determined from the leading truncation error of the Taylor series.

where Ei = xr - xi is the error in the previous iteration and Ei+1 is the error in the current iteration

• Convergence - such that successive errors become smaller, the convergence of the method is sufficient that

• Since the error in the next iteration is proportional to the square of the error is the previous iteration, the Newton-Raphson method has quadratic convergence, and thus is a second-order method

2i

i

i1i )E(

)x('F2

)x(''FE

1E)x('F2

)x(''FAbs i

i

i

Page 31: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

31

Matlab Program for Newton-Raphson Method

Page 32: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

32

Results for the Method of Newton-Raphson

Page 33: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

33

End of Chapter 2a•

Page 34: 1 Solution of Nonlinear Equation Dr. Asaf Varol avarol@mix.wvu.edu.

34

References• Celik, Ismail, B., “Introductory Numerical Methods for Engineering Applications”,

Ararat Books & Publishing, LCC., Morgantown, 2001 • Fausett, Laurene, V. “Numerical Methods, Algorithms and Applications”, Prentice

Hall, 2003 by Pearson Education, Inc., Upper Saddle River, NJ 07458

• Rao, Singiresu, S., “Applied Numerical Methods for Engineers and Scientists, 2002 Prentice Hall, Upper Saddle River, NJ 07458

• Mathews, John, H.; Fink, Kurtis, D., “Numerical Methods Using MATLAB” Fourth Edition, 2004 Prentice Hall, Upper Saddle River, NJ 07458

• Varol, A., “Sayisal Analiz (Numerical Analysis), in Turkish, Course notes, Firat University, 2001