Nonlinear Algebraic Equations Example

20 downloads 56228 Views 54KB Size Report
November 2001. 10.001 Introduction to Computer. Methods. Nonlinear Algebraic Equations Example. (in) s i. (in). (in) p,i r. Continuous Stirred Tank Reactor ...
Nonlinear Algebraic Equations Example Continuous Stirred Tank Reactor (CSTR). Look for steady state concentrations & temperature. In: N s spieces with concentrations ci

(in )

,

) (in) heat capacities c(in and temperature T p,i

Inside: N r reactions with stoichiometric coefficients σ α ,i and reaction constants rα . Out: N s spieces with concentrations ci (c-s may be equal to zero), heat capacities cp,i and temperature T. November 2001

10.001 Introduction to Computer Methods

(in )

Nonlinear Algebraic Equations Example Nr

(F/ V) ci(in) − ci  + ∑σα ,i rα = 0

i = 1, 2,..., Ns

α =1

Mass balancefor spieces1, 2,..., Ns Ns

Nr

i =1

α =1

(in) (F/ V)∑ ci(in)c(in) T − ci cp,i T − ∑ ∆Hα rα = 0 p,i

Energy balance Column of unknown variables :x = [c1 ,c2 ,...,cNs ,T]

T

November 2001

10.001 Introduction to Computer Methods

Nonlinear Algebraic Equations Example Each of the above equations may be written in the general form: f i (x1 , x 2 ,..., x N ) = 0 : In vector form: f(x)=0

f1 (x1 , x 2 ,..., x N ) = 0

f1 (x)  f (x)   f(x)=  2 ...    f (x)  N 

f 2 (x1 , x 2 ,..., x N ) = 0 ... f N (x1 , x 2 ,..., x N ) = 0 ∧

Let x be the solution staisfying f(x)=0. ∧

We do not know x and take x[0] as initial guess. November 2001

10.001 Introduction to Computer Methods

Nonlinear Algebraic Equations We need to form a sequence of estimates to the solution: [1]

[2]



[3]

x , x , x ,... that will hopehully converge to x . Thus we want: lim x m →∞

[m]



=x



lim x − x[m] = 0

m →∞

Unlike with linear equations, we can’t say much about existence or uniqueness of solutions, even for a single equation. November 2001

10.001 Introduction to Computer Methods

Single Nonlinear Equation ∧

We assume f(x) is infinitely differentiable at the solution x . ∧

Then f(x) may be Taylor expanded around x : ∧

∧ ∧ 1 1 2 ’’ f (x) = f (x) + (x − x)f (x) + (x − x) f (x) + (x − x)3 f ’’’(x) + ... 2 3!

Assume x



[0]

f (x ) ≈ (x [0]





being close to x so that the series may be truncated:

[0]



− x)f ’(x[0] ),

or

f (x[0] ) ≈ (x[0] − x[1] )f ’(x[0] )

[0] f (x ) [1] [0] x = x − ’ [0] − f (x )

− Newton ’s method Example : f (x) = (x − 3)(x − 2)(x − 1) = x 3 − 6x 2 + 11x − 6 November 2001

10.001 Introduction to Computer Methods

Single Nonlinear Equation

November 2001

10.001 Introduction to Computer Methods

Single Nonlinear Equation

November 2001

10.001 Introduction to Computer Methods

Single Nonlinear Equation For f(x)=(x-3)(x-2)(x-1)=x3-6x2+11x+6=0, we se that Newton’s method converges to the root at x=2 only if 1.60 such that J(y)-J(z) ≤ L y − z or there is some upper bound on the "stretching" effect of J. 1

f (x + sp) =

∫ [ J(x + sp) − J(x) ]p ds 0

1



∫ [ J(x + sp) − J(x) ] ds 0

1

and

∫ [ J(x + sp) − J(x) ] ds

≤ L s p , so in this case

0

1

f (x + sp) =

∫ [ J(x + sp) − J(x) ] pds ≤ ( L s p ) p 0

( )

≤ (L s ) p = O p 2

November 2001

10.001 Introduction to Computer Methods

2

p

Systems of Nonlinear Equations Thus if we are at distance p from the solution, our error scales as ||p||2. What about convergence? How the error scales with the number of iterations? The answer is: ∧ 2  x[i +1] − x = O  x[i] − x  - local quadratic convergence,   a very fast one! Works when you are close enough to the solution. ∧

November 2001

10.001 Introduction to Computer Methods

Systems of Nonlinear Equations ∧

x − x : 0.1 = 10−1 [i]

x x x

[i +1]

[i + 2]

[i + 3]



− x : 0.01 = 10−2 ∧

− x : 0.00001 = 10−4 ∧

− x : 0.000000001 = 10−8

Works if we are close enough to an isolated  ∧  (non-singular) solution: det  J( x )  ≠ 0.   November 2001

10.001 Introduction to Computer Methods

Systems of Nonlinear Equations, Example Let’s examine how Newton’s method works for a simple system : f1 = 3x + 4 x 2 − 145 = 0 ∧ 3  x=  2 3 f 2 = 4 x1 − x 2 + 28 = 0 4 3 1

2

The Jacobian is :  ∂f1  ∂x J= 1  ∂f 2  ∂x1 November 2001

∂f1  2   9 x1 ∂x 2 = ∂f 2   8x 1 ∂x 2 

8x 2  2 − 3x 2 

10.001 Introduction to Computer Methods

Systems of Nonlinear Equations, Example At each step we have the following system to solve :

( )

[i ] 2 [i ]   9 x1 8x 2 [i] J =  [i ] [i ] 2 − 3 x 2   8x1 3 x [i ] 3 + 4 x [i ] 2 − 145 1 2 [i ]   f = 4 x [i ] 2 − x [i ] 3 + 28  2  1  [i] [i ] [i ] [ i +1] [i ] [i ] = x + ∆x J ∆x = −f x

( ) ( ) ( ) ( ) ( )

November 2001

10.001 Introduction to Computer Methods

Systems of Nonlinear Equations, Example Let us examine performance of Newton’s method with the convergence

criterion f = max{f1 , f 2 } < δ abs

δ bs = 10

November 2001

−10

10.001 Introduction to Computer Methods

Newton’s Method Newton’s method works well close to the solution, but otherwise takes large erratic steps, shows poor performance and reliability. Let’s try to avoid such large steps: employ reduced step Newton’s algorithm. “Full” Newton’s step gives x[i+1]=x[i]+p[i]. We’ll use only fraction of of the step: x[i+1]=x[i]+λi p[i], 0