Você está na página 1de 14

Nonlinear Algebraic Systems

1. Iterative solution methods


2. Fixed-point iteration
3. Newton-Raphson method
4. Secant method
5. Matlab tutorial
6. Matlab exercise

Single Nonlinear Equation
Nonlinear algebraic equation: f(x) = 0
Analytical solution rarely possible
Need numerical techniques
Multiples solutions may exist
Iterative solution
Start with an initial guess x
0
Algorithm generates x
1
from x
0

Repeat to generate sequence x
0
, x
1
, x
2
,
Assume sequence convergences to solution
Terminate algorithm at iteration N when:
Many iterative algorithms available
Fixed-point iteration, Newton-Raphson method, secant
method
0 ) ( ~
N
x f
Fixed-Point Iteration
Formulation of iterative equation

A solution of x = g(x) is called a fixed point
Convergence
The iterative process is convergent if the sequence x
0
, x
1
, x
2
,
converges:
Let x = g(x) have a solution x = s and assume that g(x) has a
continuous first-order derivative on some interval J containing s, then
the fixed-point iteration converges for any x
0
in J & the limit of the
sequence {x
n
} is s if:


A function satisfying the theorem is called a contraction mapping:


K determines the rate of convergence
) ( ) ( ) ( 0 ) (
1 n n
x g x x g x x f x x f = + = =
+
0 ) ( lim
1
=
+

n n
n
x x
J x K
x
g
e < s
c
c
1
v x K v g x g s ) ( ) (
Newton-Raphson Method
Iterative equation derived from first-order Taylor
series expansion


Algorithm
Input data: f(x), df(x)/dx, x
0
, tolerance (o), maximum
number of iterations (N)
Given x
n
, compute x
n+1
as:




Continue until | x
n+1
-x
n
| < o|x
n
| or n = N
dx x df
x f
x x
n
n
n n
) (
) (
1
=
+
0 ) (
) (
) ( ) ( ) ( ) ( ) (
1 1
) (
= + ~
|
.
|

\
|
+ ~
+ + n n
n
n n
x
x x
dx
x df
x f x f x x
dx
df
x f x f
Convergence of the Newton-Raphson Method
Order
Provides a measure of convergence rate
Newton-Raphson method is second-order
Assume f(x) is three times differentiable, its first- and
second-order derivatives are non-zero at the solution x = s
& x
0
is sufficiently close to s, then the Newton method is
second-order & exhibit quadratic converge to s

Caveats
The method can converge slowly or even diverge for poorly chosen x
0

The solution obtained can depend on x
0
The method fails if the first-order derivative becomes zero
(singularity)
2
1 n n n n
c x s c c c =
+
Secant Method
Motivation
Evaluation of df/dx may be computationally expensive
Want efficient, derivative-free method
Derivative approximation


Secant algorithm


Convergence
Superlinear:
Similar to Newton-Raphson (m = 2)
1
1
) ( ) ( ) (

~
n n
n n n
x x
x f x f
dx
x df
) ( ) (
) (
1
1
1

=
n n
n n
n n n
x f x f
x x
x f x x
2 1
1
< < =
+
m c
m
n n
c c
Matlab Tutorial
Solution of nonlinear algebraic equations with
Matlab
FZERO scalar nonlinear zero finding
Matlab function for solving a single nonlinear algebraic
equation
Finds the root of a continuous function of one variable
Syntax: x = fzero(fun,xo)
fun is the name of the user provided Matlab m-file function
(fun.m) that evaluates & returns the LHS of f(x) = 0.
xo is an initial guess for the solution of f(x) = 0.
Algorithm uses a combination of bisection, secant, and
inverse quadratic interpolation methods.
Solution of a single nonlinear algebraic
equation:

Write Matlab m-file function, fun.m:


Call fzero from the Matlab command line to
find the solution:

Different initial guesses, xo, can give different
solutions:


Matlab Tutorial cont.
0 6
04 . 0 ) 9 . 0 (
1
01 . 0 ) 3 (
1
) (
2 2
=
+
+
+
=
x x
x f
>> xo = 0;
>> fzero('fun',xo)
ans =
0.5376
>> fzero('fun',1)
ans =
1.2694
>> fzero('fun',4)
ans =
3.4015
Nonisothermal Chemical Reactor
Reaction: A B
Assumptions
Pure A in feed
Perfect mixing
Negligible heat losses
Constant properties (, C
p
,
AH, U)
Constant cooling jacket
temperature (T
j
)
Constitutive relations
Reaction rate/volume: r = kc
A
= k
0
exp(-E/RT)c
A

Heat transfer rate: Q = UA(T
j
-T)
Model Formulation
Mass balance

Component balance


Energy balance

q q q q w w
dt
V d
i i i
= = = =

0
) (
A A Ai
A
A A A Ai i A
A A
C RT E Vk C C q
dt
dC
V
Vr M qC M C q M
dt
VC M d
) / exp( ) (
) (
0
=
=
| |
) ( ) / exp( ) ( ) (
) ( ) ( ) ( ) (
0
T T UA C RT E Vk H T T qC
dt
dT
VC
Q rV H T T wC T T C w T T VC
dt
d
j A i p p
ref p ref i p i ref p
+ A + =
+ A + =

Matlab Exercise
Steady-state model


Parameter values
k
0
= 3.493x10
7
h
-1
, E = 11843 kcal/kmol
(-AH) = 5960 kcal/kmol, C
p
= 500 kcal/m
3
/K
UA = 150 kcal/h/K, R = 1.987 kcal/kmol/K
V = 1 m
3
, q =1 m
3
/h,
C
Af
= 10 kmol/m
3
, T
f
= 298 K, T
j
= 298 K.
Problem
Find the three steady-state points:
0
0
0 ( ) exp( / )
0 ( ) ( ) exp( / ) ( )
Af A A
p f A j
q C C Vk E RT C
qC T T H Vk E RT C UA T T
=
= + A +
) , ( T C
A
Matlab Tutorial cont.
FSOLVE multivariable nonlinear zero finding
Matlab function for solving a system of nonlinear algebraic
equations
Syntax: x = fsolve(fun,xo)
Same syntax as fzero, but x is a vector of variables and the function,
fun, returns a vector of equation values, f(x).
Part of the Matlab Optimization toolbox
Multiple algorithms available in options settings (e.g. trust-
region dogleg, Gauss-Newton, Levenberg-Marquardt)
Syntax for fsolve
x = fsolve('cstr',xo,options)
'cstr' name of the Matlab m-file function (cstr.m) for the CSTR model
xo initial guess for the steady state, xo = [C
A
T] ';
options Matlab structure of optimization parameter values created with the
optimset function
Solution for first steady state, Matlab command line input and output:
Matlab Exercise: Solution with fsolve
>> xo = [10 300]';
>> x = fsolve('cstr',xo,optimset('Display','iter'))

Norm of First-order Trust-region
Iteration Func-count f(x) step optimality radius
0 3 1.29531e+007 1.76e+006 1
1 6 8.99169e+006 1 1.52e+006 1
2 9 1.91379e+006 2.5 7.71e+005 2.5
3 12 574729 6.25 6.2e+005 6.25
4 15 5605.19 2.90576 7.34e+004 6.25
5 18 0.602702 0.317716 776 7.26
6 21 7.59906e-009 0.00336439 0.0871 7.26
7 24 2.98612e-022 3.77868e-007 1.73e-008 7.26
Optimization terminated: first-order optimality is less than options.TolFun.

x =

8.5637
311.1702
Matlab Exercise: cstr.m
function f = cstr(x)

ko = 3.493e7;
E = 11843;
H = -5960;
rhoCp = 500;
UA = 150;
R = 1.987;
V = 1;
q = 1;
Caf = 10;
Tf = 298;
Tj = 298;

Ca = x(1);
T = x(2);

f(1) = q*(Caf - Ca) - V*ko*exp(-E/R/T)*Ca;
f(2) = rhoCp*q*(Tf - T) + -H*V*ko*exp(-E/R/T)*Ca + UA*(Tj-T);

f=f';

Você também pode gostar