You are on page 1of 40

1

3. Mtodos de resolucin
Ecuaciones algebraicas lineales
Ecuaciones algebraicas no lineales
Mtodos para una variable
Mtodos para multivariable

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

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

Para problemas multidimensionales


Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas lineales

Analysis of System LAE


Consistent, independent equations

Systems of Linear Algebraic Equations

If equations are not contradictory and not simply multiplies of


the other, then solution to LAE problems will be unique.
Example:
3x 2 y 4
2x y 1

Inconsistent equations

General Representation
a11 x1 a12 x2 a1n xn b1

If equations are contradictory, then no solution exists.


Example: 2 x y 2
2x y 1

a21 x1 a22 x2 a2 n xn b2

an1 x1 an 2 x2 ann xn bn

as are constant coefficients, bs are constants, x are


the unknown variables, and n is the number of
equations

Analysis of System LAE (2)


Dependent equations
If equations are multiplies of others, many solutions can be
found
Example: 4 x 2 y 4
2x y 2

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas lineales

Gauss Elimination Algorithm

Gauss Elimination - Concept

Step 1: Forward elimination until we get the upper (or lower)


triangular matrix of LAE coefficients
Step 2: Backward substitution
1.

If two equations have a point in common, then that point also


satisfies any linear combination of the two equations.
Suppose that r r1 , r2 , , rn are the solutions to linear
equations
S : ao a1 x1 a 2 x 2 a n xn 0

Add a multiple m of row Ri onto row R j to form a new row R j

R j mRi R j
2.

Repeat (1) until we get an upper (or lower) triangular matrix of


LAE coefficients;

3.

Apply back substitution to solve for each variable

T : bo b1 x1 b2 x 2 bn x n 0

then r r1 , r2 , , rn also satisfies the linear combination of these


linear equations:
m1S m2T
m1ao m1a1 x1 a2 x2 m1an xn m2bo m2b1 x1 m2b2 x2 m2bn xn 0

Pitfalls of the Gauss Elimination


When does the Gauss elimination get solution?
When inverse of exists A x b
x A 1b

When equations are consistent and independent


Satisfy the following rank condition: rank ( A) dim( A)

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas lineales

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

Methods to find LU factors


Gauss elimination (Doolittle form)
Direct computation
Crout form (u ii 1 )
Cholesky form ( u ii ii )

Motivation for LU Decomposition


Solve the LAE Problems in a more efficient way
Algorithm for solving an LAE Problem using the LU
Decomposition
Find the LU factor of the A matrix: A = LU
Algebraic problem is transformed from Ax = b to LUx = b

Define y = Ux
Solve for y using the forward substitution
Solve for x using the backward substitution

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas lineales

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

Initialization: Let U = A and

21

31

32

41

42

43

0
0
0

Step 1: Row 1 is unchanged, and rows 2-4 are modified by:


4 12 8 4
to give:
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

Step 2: Rows 1 and 2 are unchanged. Rows 3 and 4 are


transformed by
32

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

Step 3: The fourth row is modified to complete the forward


eliminating stage by:
43

a 43 1

a33 4

to yield:

4 12 8 4
0 4 16 8

0 0 4 12

Hence, the LU factors are:

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas lineales

LU Decomposition
using Crout Method

Based on equating the elements of the product LU with the


corresponding elements of A , where the diagonal elements of U
are 1s . For a 3 x 3 matrix
11 0

21 22
31 32

0 1 u12
0 0 1
33 0 0

u13 a11 a12


u 23 a21 a22
1 a31 a32

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 Crouts Method

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

General formula for the last row of L

j 1

nn ann nk ukn
k 1

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas lineales

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.

Generalization of Choleskys Method


For the k-th row
i 1

ki

aki ij kj
j 1

ii

i 1,2, , k 1

k 1

xk akk 2kj
j 1

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

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

First row of U and first column of L


x1 .x1 a11 x1 1; x1 .u12 a12 u12 4; x1 .u13 a13 u13 5
21 .x1 a 21 21 4;

31 .x1 a31 31 5

MATLABs Code

Note that due the symmetric: a1 j a j1 j1 u1 j


1 0
4 x
2

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

Second row of U and second column of L


(4).( 4) x 22 20 x 2 2;
(4).(5) x 2 u 23 32 u 23 6;
(5).(4) 32 x 2 32 21 6;

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

function [L,U] = Cholesky(A)


%
% A is assumed to be symmetric
%
[n,m] = size(A);
L = zeros(n,n);
for k=1:n,
L(k,k) = sqrt(A(k,k)-L(k,1:k-1)*L(k,1:k-1)');
for i=k+1:n,
L(i,k) = (A(i,k) - L(i,1:k-1)*L(k,1:k-1)')/L(k,k);
end
end
U = L';

(5).(5) (6).(6) x32 64 x33 3;


1 0
L 4 2
5 6

0
1 4
0 ; U 0 2
0 0
3

5
6
3

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

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

Ecuaciones algebraicas lineales

Iterative Methods: Concept


Basic Idea
To solve the i-th equation in the system for the i-th variable by
converting the given system to be suitable for finding the solution in
the iterative manner.

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).

Successive Over Relaxation (SOR) Method


Like Gauss-Seidel method, but we introduce an additional
parameter , that may accelerate the convergence of iteration. For
0 1 , the method is known as successive under relaxation,
while for 1 2 is known as successive over relaxation.

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

12

Ecuaciones algebraicas lineales

Implementation for Different Methods


Jacobi Method
Iterative Scheme:

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

a11 x1 a12 x 2 a13 x3 b1


a 21 x1 a 22 x 2 a 23 x3 b2
a31 x1 a32 x 2 a33 x3 b3

SOR Iterative Scheme x new (1 ) x old b a x old a x old


1
1
1
12 2
13 3
a11

b2 a 21 x1new a 23 x3old
a 22

x3new (1 ) x3old

b3 a31 x1new a 32 x 2new


a 33

new
2

(1 ) x

old
2

It can be seen that if 1, it becomes the iterative scheme for


Gauss-Seidel method. The parameter is selected to improve the
convergence of algorithm.

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

13

Simple Example of Transformation


2 x1 x 2 x3 1
x1 2 x 2 x3 6
x1 x 2 2 x3 3

Ax b

x1 0.5 x2 0.5 x3 0.5


x2 0.5 x1 0.5 x3 3
x3 0.5 x1 0.5 x2 1.5

x Cx d

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

14

Ecuaciones algebraicas no lineales


Objetivo
Sea f(x) una funcin no lineal en x. Hallar el valor
de x, x*, tal que se cumple f(x*)=0.
x* se suele denominar el cero o raz de f(x)
x* se puede determinar por medios analticos
(solucin exacta) o por medios numricos
(solucin aproximada)
La eleccin del mtodo numrico depende del
problema a resolver (estructura del problema, tipo
de ecuaciones, precisin requerida, rpidez del
clculo,....).
Por tanto no existe un mejor mtodo universalmente
Tipos de mtodos
aplicable.
Mtodos acotados (bracketing methods)

Mtodos abiertos (open methods)

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

15

Mtodos
acotados

Base: Una funcin cambia de signo en la proximidad de


una raz
Una raz est acotada en el intervalo [a,b] si el signo de
f(a) es diferente al signo de f(b)
Mtodo de la biseccin (o intervalo
medio) Bisection Method
Algoritmo

f(x)
f(b)

[nuevo
punto]

Mid-point

[a,b
]Next estimate of Bisection

f(a)

1.

Selecciona un intervalo [a,b] donde


halla un cero

2.

Calcula el punto medio como nuevo


punto

3.

Comprueba si hay cambio de signo


en [a,p] o en [p,b]. Comprobacin:
f(a)*f(p).

4.

Si el producto es cero, entonces p es


una raz. Si no es cero volver al
punto 2.
Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

16

Ejemplo Mtodo biseccin (Intervalo medio)

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

17

Ecuaciones algebraicas no lineales

Mtodo de la posicin falsa


False-Position Method
f(x)
f(b)

[nuevo
punto]point
Intersection

Algoritmo

[a,b
]
Next estimate of False-position

f(a)

1.

Selecciona un intervalo [a,b] donde


halla un cero

2.

Calcula un punto interseccin como


nuevo punto
f (a)
f (b)
f (b)[a - b])
=
m =b m- a m- b
f (a ) - f (b)

3.

Comprueba si hay cambio de signo


en [a,p] o en [p,b]. Comprobacin:
f(a)*f(p).

4.

Si el producto es cero, entonces p es


una raz. Si no es cero volver al
punto 2.
Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

18

Ejemplo mtodo de la posicin falsa (Regula Falsi)

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

Ecuaciones algebraicas no lineales

Comparacin entre ambos


mtodos.
Similaridades:
Ambos mtodos necesitan DOS valores
iniciales
Requieren un procedimiento para determinar
el cambio de signo.
Acaban convergiendo a la raz con cierta
tolerancia

Diferencias:
El clculo del nuevo punto estimado se hace
con diferentes estrategias

Convergence Rate

Relative Errors

En general el mtodo de la posicin falsa 10


1
converge ms rpido que el de la biseccin.
Bisection method

False-position method

Number of iterations

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

20

Ecuaciones algebraicas no lineales

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)

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

21

Ecuaciones algebraicas no lineales

Metodos acotados vs. Mtodos


abiertos
Mtodos acotados
La raz est situada en un intervalo (necesita dos puntos).
Acaba convergiendo dentro de una tolerancia.
Mtodos abiertos
Slo emplean un punto inicial (o dos puntos que no tienen
por qu contener a la raz) y una frmula para encontrar la
raz. No siempre convergen, pero cuando lo hacen son
mucho ms rpidos que los mtodos acotados.

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

22

Ecuaciones algebraicas no lineales

Sustitucin
y
sucesiva

Problema f(x)=0
y=x

y=g(x)
Raiz

x2

1.

Transformar a x=g(x)

2.

Seleccionar un punto inicial x0

3.

Calcular nuevo valor xi+1=g(xi)

4.

Repetir hasta llegar a la tolerancia


requerida

y
x1

x0

y=x

Si:

y=g(x)

|g(x)|<1 El algoritmo converge


linealmente
|g(x)|>=1 El algoritmo diverge

x3 x1

x0 x2

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

23

Ejemplo Mtodo punto fijo (Sustitucin directa/sucesiva)

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

24

Ecuaciones algebraicas no lineales

Newton Raphson

Problema g(x)=0
1.

Seleccionar un punto inicial x0

2.

Calcular g(xi) y g(xi)

3.

Aplicar la tangente en ese punto y en el corte


con el eje de abcisas tenemos el nuevo punto
estimado

xi+1=xi4.

g(xi)
g(xi)

Repetir hasta llegar a la tolerancia requerida

g(x)
Necesita conocer la derivada de
la funcin
Convergencia cuadrtica
(rpida)

x2

x1

x0

Puede no converger (depende


de la funcin y de la
estimacin inicial)

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

25

Ejemplo Newton Method

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

26

Ecuaciones algebraicas no lineales

Problema g(x)=0

Secante

1.

Seleccionar dos puntos iniciales x0,x1

2.

Calcular la recta que pasa por esos puntos

3.

El corte con el eje de abcisas da el nuevo


punto estimado. Volver a calcular la recta.

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

27

Ecuaciones algebraicas no lineales

False-position

Secant method

x0

x3 x2

x3
x1

x0

x2

x1

La primera iteracin da el mismo resultado, luego


cada uno obtiene un nuevo punto estimado
At the diferente
first iteration, both methods produce the same estimate. After
that, each method has a different estimate.

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

28

Ecuaciones algebraicas no lineales

Mullers Method

Mullers Algorithm
f(x)

x0

x1
x2

1.
2.

Select three points [xo,f(xo)]; [x1,f(x1)] and [x2,f(x2)]


Compute the coefficients a, b and c *

3.

Apply a quadratic formula to calculate the next


estimate of the zero

Parabolic

x3 x2

Next estimate of Muller

4.

2c
2

b b 4ac

Real and complex root


Can be located

Repeat step 2-3 until satisfying the convergent


criteria

Which point is discarded in Muller Algorithm


Two general strategies are typically used:
If only real roots are being located, we choose the two original
points that are nearest the new root estimate, x3
If both real and complex roots are being evaluated, a sequential
approach is employed. That is just like the secant method, x1, x2
and x3 take place of x0, x1 and x2.

* Se computan obligando a que g(x) pase


por los 3 puntos seleccionados.

g ( x) =a ( x - xi ) 2 +b( x - xi ) +c

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

29

Ecuaciones algebraicas no lineales

Difficulties with multiple root problems


The fact that the function does not change sign at even multiple
roots. So, the bracketing strategy cannot be applied!
The fact that not only f(x), but also f(x), goes to zero at the root.
Possible problems for Newton-Raphson and Secant methods!
SOLUTION: Use the modified Newton-Raphson methods
Alternative one: If we have m multiple roots, the updated estimate
follows:

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 )

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

30

Ecuaciones algebraicas no lineales

Sistemas de ecuaciones algebraicas no


lineales
f1 ( x1 , x2 , x3 ,..., xn ) 0
f 2 ( x1 , x2 , x3 ,..., xn ) 0
f 3 ( x1 , x2 , x3 ,..., xn ) 0
M
f n ( x1 , x2 , x3 ,..., xn ) 0
F(X ) 0

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

31

Ecuaciones algebraicas no lineales

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas no lineales

32

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

33

En los problemas de diagrama de flujo las variables de iteracin no estn todas


muy acopladas ni todas desacopladas, nos podemos encontrar:
1)

Todas las especies dbilmente acopladas a travs de equilibrio L-V (no ideal)

2)

Especies muy acopladas si participan en una reaccin

3)

Si hay ms de una corriente de rasgado, hay un fuerte acoplamiento entre los


flujos de cada corriente de rasgado.

Cuando las variables estn desacopladas o dbilmente acopladas es necesario un


parmetro de aceleracin diferente para cada variable.

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

Ecuaciones algebraicas no lineales

34

El mtodo de Wegstein es muy bueno para particiones en las que


hay una nica corriente de rasgado. O cuando hay reciclo sin estar
los componentes muy acoplados (presencia de reaccin)

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

35

Ecuaciones algebraicas no lineales

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?

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

36

Ecuaciones algebraicas no lineales

Newton Raphson- procedimiento de resolucin

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

Ecuaciones algebraicas no lineales

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

38

Ventajas:

Slo requiere una pasada por el diagrama de flujo en cada

Tiene en cuenta de forma aproximada la interaccin entre variables.


Bueno para diagramas de flujo con alta interaccin.
Desventajas:

Convergencia ms lenta que Newton. Necesita ms pasos que el


mtodo de Newton pero el costo computacional de cada mtodo es

Muy utilizado si el nmero de ecuaciones no es muy


grande (<100)
Utilizado para convergencia de reciclos en diagramas
de flujo.
Para los mtodos de Newton o Broyden es deseable escoger el mnimo
nmero de variables de corriente que rasgan todos los lazos (es decir
buscar el menor nmero de ecuaciones).
Si todos los bucles estn rasgados la eleccin de las corrientes de rasgado
no influye mucho en la convergencia de estos dos mtodos.

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

39

Ecuaciones algebraicas no lineales

MATLAB Built in Function (1)


The built in fzero function (Optimization Toolbox) is a hybrid
method that combines bisection, secant and reverse quadratic
interpolation to a find the root of f(x) = 0

MATLAB Built in Function (2)


The built in fsolve function (Optimization Toolbox) is an M-file
function to solve a system of nonlinear equations:

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

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

40

Ecuaciones algebraicas no lineales

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(...)

Modelado y simulacin en Ingeniera Qumica. Manuel Rodrguez

You might also like