Professional Documents
Culture Documents
Raices de Ec
Raices de Ec
3. Mtodos de resolucin
Ecuaciones algebraicas lineales
Ecuaciones algebraicas no lineales
Mtodos para una variable
Mtodos para multivariable
Ecuaciones Algebraicas
Lineales
No lineales
Interval
Interval
Halving
Halving
(obisection)
bisection)
(o
Metodos
Numericos
Succesive
Succesive
Substitution
Substitution
(ofixed-point)
fixed-point)
(o
Wegstein
Wegstein
Metodos
Analiticos
Brent
Brent
False
False
Position
Position
(oregula
regulafalsi)
falsi)
(o
Secant
Secant
Ridder
Ridder
Muller
Muller
Newton
Newton
Raphson
Raphson
Broyden
Broyden
Homotopy
Homotopy
Hookstep
step
Hook
Doglegstep
step
Dogleg
Inconsistent equations
General Representation
a11 x1 a12 x2 a1n xn b1
a21 x1 a22 x2 a2 n xn b2
an1 x1 an 2 x2 ann xn bn
Ill-conditioned equations
If a small change in any of the coefficients will change the
solution set from unique to either infinite or empty, the
system of LAE is called to be ill-conditioned.
Numerical solution will be difficult
Example: (4 ) x 2 y 4
2x y 1
R j mRi R j
2.
3.
T : bo b1 x1 b2 x 2 bn x n 0
Limitation of algorithm
When pivot element equals zero
When pivot element is significantly smaller than the coefficient
being used to eliminate (or Ill-conditioned)
Round-off errors
LU Decomposition - Concept
A matrix A is decomposed (or factorised) into lower and upper
matrix factors, for example if A is a 3x3 matrix:
A L.U
11
21
31
0
22
32
0
0
33
u11 u12
. 0 u 22
0
0
u13 a11
u 23 a 21
u 33 a31
a12
a 22
a32
a13
a23
a33
Define y = Ux
Solve for y using the forward substitution
Solve for x using the backward substitution
LU Decomposition
using Gauss Elimination
Suppose we try to find LU factors of the following matrix:
A
4 12 8
1 7 18
2 9 20 20
3 11 15 14
21
31
32
41
42
43
0
0
0
4
3
2
16 8
16 18
9 11
21
a 21 1
a11 4
31
a31 1
a11 2
41
a 41 3
a11 4
a32 3
a 22 4
42
a 42 1
a 22 2
to yield:
4 12 8 4
0 4 16 8
U
0 0 4 12
0 0 1 7
a 43 1
a33 4
to yield:
4 12 8 4
0 4 16 8
0 0 4 12
1
0
0.25
1
0.5 0.75
0.75
0 .5
0
;
0
0.25 1
0
1
4 12 8 4
0 4 16 8
0 0 4 12
LU Decomposition
using Crout Method
21 22
31 32
0 1 u12
0 0 1
33 0 0
a13
a23
a33
Algorithm
Step 1: Set 11 a11 , then solve for the remaining elements in
the first row of U and the first column of L .
Step 2: Find 22 , then solve for the remainder of the second
row of U and the second column of L
Continue for the rest
General formula for the first column of L, the first row of U and the
diagonal element of U
i1 ai ,1;
u1 j
a1 j
11
uii 1
General formula for the j-th row of L and the j-th column of U:
For j= 2, 3, , n-1; i = j, j+1, , n; and k = j+1, j+2, , n
j 1
ij aij ik ukj
k 1
j 1
u jk
a jk ji uik
i 1
jj
j 1
nn ann nk ukn
k 1
LU Decomposition
using Choleskys Method
The matrix A is symmetric and positive definite.
L UT
For a 3 x 3 matrix: x
1
21
31
0
x2
32
0
0
x3
A LLT
x1 u12
0 x
2
0 0
u13 a11
u 23 a 21
x3 a31
a12
a 22
a32
a13
a 23
a33
Algorithm:
1/ 2
Find x1 (a11 ) , then solve for the remaining elements in the
first row of U and the first column of L .
Find x 2, then solve for the remainder of the second row of U
and the second column of L
Continue for the rest.
ki
aki ij kj
j 1
ii
i 1,2, , k 1
k 1
xk akk 2kj
j 1
1 4 5
A 4 20 32
5 32 64
x1
21
31
0
x2
32
0
0
x3
x1 u12
. 0 x 2
0 0
u13 1 4 5
u 23 4 20 32
x3 5 32 64
31 .x1 a31 31 5
MATLABs Code
5 32
0 1 4
0 . 0 x 2
x3 0 0
5 1 4 5
u 23 4 20 32
x3 5 32 64
We get:
1 0 0
4 2 0
5 6 x3
1 4 5 1 4 5
. 0 2 6 4 20 32
0 0 x3 5 32 64
0
1 4
0 ; U 0 2
0 0
3
5
6
3
10
Ejemplo
3x1+2x2=4
2x1+x2=1
Inversa de la matriz
Ax=b
x=A-1 b
x1=-2
x2=5
Descomposicin de Gauss
[32 21]
[41 ]
f1=f1-2f2
[ ]
-1 0
2 1
[]
2
1
f1=-f1
[12 01 ]
[ -21]
f2=-2f1+f2
[10 01 ]
[ -25]
Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez
11
Algorithm
Transform Ax b to x Cx d so that we can solve iteratively for x
as
.
(k )
( k 1)
Cx
Stopping Conditions
To stop the iterations when the norm of the change in the solution
vector from one iteration to the next is sufficiently small.
To stop the iterations when the norm of the residual vector is below
a specified tolerance.
Variations of Algorithm
Jacobi Method
Based on the transformation of Ax b to x Cx d , in which the
matrix C has zeros on the diagonal. The vector x is updated using
the previous estimate for all components of x to evaluate the right
hand side of the equation (simultaneous updating).
Gauss-Seidel Method
Based on the transformation of Ax b to x Cx d , in which the
matrix C has zeros on the diagonal as in Jacobi method, but each
component of the vector x is updated immediately as each iteration
progresses (sequential updating).
12
x1k
0
0.5 0.5 x1k 1 0.5
0.5 x 2k 1 3
x 0.5 0
x
0 x3k 1 1.5
0.5 0.5
k
2
k
3
Initial condition/guess: x o 0 0 0
Stopping criteria x x 0.001
Gauss-Seidel Method
x1new 0.5 x 2old 0.5 x3old
Iterative Scheme
T
k 1
new
2
0.5 x
new
3
0.5 x
Initial condition/guess x
Stopping criteria x new x old
new
1
new
1
0 0 0
0.5
0.5 x
old
3
0.5 x
new
2
1. 5
SOR Method
0.001
Example
b2 a 21 x1new a 23 x3old
a 22
x3new (1 ) x3old
new
2
(1 ) x
old
2
13
Ax b
x Cx d
14
15
Mtodos
acotados
f(x)
f(b)
[nuevo
punto]
Mid-point
[a,b
]Next estimate of Bisection
f(a)
1.
2.
3.
4.
16
x2 4 0
0,6 3,6
0,3 0,1.5 no cambia signo
1.5,3 2.25,3 no cambia signo
1.5,2.25 1.5,1.875 no cambia signo
1.875,2.25
17
[nuevo
punto]point
Intersection
Algoritmo
[a,b
]
Next estimate of False-position
f(a)
1.
2.
3.
4.
18
x 40
2
[ 0,6]
2
y + 4 = 6x x =
3
2
, 6
3
32 20
2
18
y+
=
(x - ) x =
9
3
3
15
18
, 6
15
L
Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez
19
Diferencias:
El clculo del nuevo punto estimado se hace
con diferentes estrategias
Convergence Rate
Relative Errors
False-position method
Number of iterations
20
Mtodos abiertos
Emplean una aproximacin funcional para obtener el nuevo valor
estimado de la raz (lnea recta, cuadrtica, polinomio)
Mtodos:
Punto-fijo (sustitucin sucesiva o directa)
Newton-Raphson (lnea recta empleando informacin del
gradiente)
Secante (lnea recta empleando dos puntos)
Muller (aprox. cuadrtica empleando tres puntos)
21
22
Sustitucin
y
sucesiva
Problema f(x)=0
y=x
y=g(x)
Raiz
x2
1.
Transformar a x=g(x)
2.
3.
4.
y
x1
x0
y=x
Si:
y=g(x)
x3 x1
x0 x2
23
x2 4 0
g' (x 0 ) = 3x 2 - 3 = 3 - 3 = 0 < 1
x = x -4+x
2
x = x(x - 3)
x k+1Converge
= xk (x k 2 - 3)
x0 1
x1 = 1(12 - 3) = -2
g(x) = x(x 2 - 3)
x0 3
x 2 = -2((-2)2 - 3) = -2
g' (x 0 ) = 3x 2 - 3 = 3 * 9 - 3 = 24 > 1
2
x1 = 3(3Converge
- 3) = 18
x 2 = 18(18 2 - 3) = 5778
24
Newton Raphson
Problema g(x)=0
1.
2.
3.
xi+1=xi4.
g(xi)
g(xi)
g(x)
Necesita conocer la derivada de
la funcin
Convergencia cuadrtica
(rpida)
x2
x1
x0
25
x 40
2
x0 1
2
x0 3
2
( x0 4)
x1 x0
2 x0
( x0 4 )
x1 x0
2 x0
(12 4)
x1 1
1.5
2 1
(1.52 4) 23
x 2 1 .5
2 1.5
12
(32 4)
x1 3
2.1666
23
(2.1666 2 4)
x2 2.1666
2,006
2 2.1666
26
Problema g(x)=0
Secante
1.
2.
3.
xi+1-xi
g (xi+1)
g (xi+1)-g
(xla
i) tolerancia requerida
Repetir hasta llegar a
xi+1=xi-
4.
g(x)
No Necesita conocer la
derivada de la funcin (la
aproxima).
Necesita dos puntos iniciales.
Puede no converger.
x3 x2
x1
x0 x
27
False-position
Secant method
x0
x3 x2
x3
x1
x0
x2
x1
28
Mullers Method
Mullers Algorithm
f(x)
x0
x1
x2
1.
2.
3.
Parabolic
x3 x2
4.
2c
2
b b 4ac
g ( x) =a ( x - xi ) 2 +b( x - xi ) +c
29
xk 1 xk m
f ( xk )
f ( xk )
Alternative two: Use the ratio of the function to its derivative, and
then apply the Newton-Raphson formula for this ratio function
u ( xk )
f ( xk )
f ( xk )
xk 1 xk
u ( xk )
f ( xk ) f ( xk )
xk
u ( xk )
f ( xk ) 2 f ( xk ) f ( xk )
30
31
Sustitucin sucesiva
acelerada
La sobrerelajacin es una tcnica para acelerar la convergencia de
mtodos iterativos en la solucin de ecuaciones lineales. La idea es
aplicarlo al mtodo de sustitucin sucesiva.
Se dan pesos a los valores anteriores y a los previos con el fin de dar
pasos mayores hacia la solucin.
Xk+1=qXk+(1q)g(Xk)
q=0 sustitucin sucesiva
q<0 aceleracin de la convergencia
0<q<1 estabilizacin de la convergencia por
amortiguamiento
32
33
Todas las especies dbilmente acopladas a travs de equilibrio L-V (no ideal)
2)
3)
34
35
Newton Raphson
En lugar de la derivada emplea el jacobiano (matriz de
derivadas parciales)
La estimacin del nuevo conjunto de races se computa
mediante la siguiente ecuacin:
X i 1 X i J 1 ( X i ) F ( X i )
f1
x1
x1,i
f 2
Jacobian J ( X ) x1 x
i
1,i
M
f
n
x1 x
1,i
f1
x2
f 2
x2
L
x2,i
L
x2,i
M
f n
x2
O
L
x2,i
f1
xn
xn ,i
f 2
xn x
n ,i
M
f n
xn x
n ,i
Cmo resolveras la
ecuacin anterior sin tener
que calcular la inversa de la
matriz jacobiana?
36
J ( X i )( X i 1 X i ) F ( X i )
Resuelve un
sistema de
ecuaciones
lineales!
Actualiza el valor hasta
que X es tan pequeo
como se haya requerido
J ( X i ) X F ( X i )
AX b
X ( X i 1 X i )
X i 1 X i X
Ventajas:
a) Buena convergencia (cuadrtica)
b) Bueno para diagramas de flujo con mucha interaccin, ya que esta
interaccin se tiene en cuenta en el Jacobiano.
Desventajas:
a) Requiere unas estimaciones iniciales buenas
b) Como las funciones no se conocen explcitamente, el Jacobiano se
aproxima de forma numrica.
Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez
37
Mtodo de Broyden
No calcula el jacobiano, lo aproxima empleando valores
previos de x y f(x).
W es la aproximacin a la negativa de la inversa del
jacobiano.
Es una extensin del mtodo de la secante (o mtodo quasiNewton)
X i 1 X i W i F ( X i )
p i X i 1 X i
min W i +1 - W i
y i f ( X i 1 ) f ( X i )
W i pi = yi
W i 1 W i
iT
( p W y ) p W i
i
iT
p W i yi
38
Ventajas:
39
f1 ( x1 , x 2 , , x n ) 0
f 2 ( x1 , x 2 , , x n ) 0
Syntax:
f n ( x1 , x 2 , , x n ) 0
x = fzero(fun,x0)
X0 can be scalar or a two element vector
If x0 is a scalar, fzero tries to create its own bracket
If x0 is a two element vector, fzero uses the vector as a bracket
Syntax:
x = fsolve(fun,x0)
x0 is a vector of initial estimate of the roots
40
fsolve
Solve a system of nonlinear equations
for x, where x is a vector and F(x) is a function that returns a
vector value.
Syntax
x = fsolve(fun,x0) x = fsolve(fun,x0,options)
x = fsolve(fun,x0,options,P1,P2, ... )
[x,fval] = fsolve(...)
[x,fval,exitflag] = fsolve(...)
[x,fval,exitflag,output] = fsolve(...)
[x,fval,exitflag,output,jacobian] = fsolve(...)