Está en la página 1de 27

Problemas de frontera para

ecuaciones diferenciales
Clculo Numrico
Prctica 3
Algoritmos de resolucin
Algoritmos auxiliares
Problema de valor inicial
Sistemas lineales tridiagonales
Mtodos de disparo
Problema lineales y no lineales
Mtodos de diferencias finitas
Problema lineales y no lineales
Mtodos variacionales
Elementos lineales y cbicos
Problema de valor inicial


siendo,
' = e = y f y y y ( ) ( , ( )) , [ , ] , ( ) t t t t a b t
0 0
y
y
f y y y y
y
( ) ( ( ), ( ), ... , ( ))
( ) ( ( ), ( ), ... , ( ))
( , ) ( ( , ), ( , ), ... , ( , ))
( , , ... , )
t y t y t y t
t y t y t y t
t f t f t f t
y y y
m
m
m
m
=
' = ' ' '
=
=
1 2
1 2
1 2
0 01 02 0
T
T
T
T
Algoritmo de MATLAB 5.2 para
el Problema de Valor Inicial
[X,Y] = ode23(fun, [a, b], y0)
fun.m: fichero que calcula las derivadas
function z=f(x,y)
% Ecuacin no lineal de segundo orden
% y" = (32 + 2x^3 -yy')/8
z=[y(2);(32 + 2*x^3 - y(1)*y(2))/8];
[T,Y] = ode23('fun',[1,3],[17,0])

Sistemas lineales tridiagonales
|
|
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
|
|
.
|

\
|


n
n
n
n
n n
n n n
d
d
d
d
d
x
x
x
x
x
a c
b a c
b a c
b a c
b a
1
3
2
1
1
3
2
1
1
1 1 2
3 3 2
2 2 1
1 1

Algoritmo de Crout
% Eliminacin
l(1)=a(1); y(1)=d(1)/l(1);
for i=2:n
u(i-1)=b(i-1)/l(i-1);
l(i)=a(i)-c(i-1)*u(i-1);
y(i)=(d(i)-c(i-1)*y(i-1))/l(i);
end
% Sustitucin regresiva
x(n)=y(n);
for i=n-1:-1:1
x(i)=y(i)-u(i)*x(i+1);
Resolver el problema de contorno


iterando las soluciones de los PVI


eligiendo los parmetros t = t
k
para que
| |
| = o =
e =
) b ( y ) a ( y
b , a x ) ' y , y , x ( f ' ' y
| |
k
t ) a ( ' y ) a ( y
b , a x ) ' y , y , x ( f ' ' y
= o =
e =
| = =

) b ( y ) t , b ( y
k
lim
k
Mtodo de disparo no lineal
Disparo con la secante
t
k
: ngulo de tiro,
y'(a) = t
k
,
k=1,2,...

Iterar los t
k
segn
la frmula
1 k k
1 k k
k
k 1 k
t t
) t , b ( y ) t , b ( y
) t , b ( y
t t

|
=
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6
12
13
14
15
16
17
18
19
20
21
k
y(b,t
k
)
Algoritmo de disparo secante
Entradas: f, a, b, o, |, tol, maxiter
Proceso
Estimar t
0
y t
1

Disparar con y(a) = o, y(a) = t
0
para hallar y(b,t
0
)
Disparar con y(a) = o, y(a) = t
1
para hallar y(b,t
1
)
Mientras |y(b,t
k
) |)| > tol y k < maxiter
Hallar t
k+1
por la frmula de la secante
Disparar con y(a)=t
k+1
para hallar y(b,t
k+1
)
Salida: y


Solucin exacta:


Criterio de parada:

( ) | |
3
43
) 3 ( y 17 ) 1 ( y
3 , 1 x ' yy x 2 32
8
1
' ' y
3
= =
e + =
x
16
x ) x ( y
2
+ =
5
k
10
3
43
) t , 3 ( y

s
Ejemplo
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
11
12
13
14
15
16
17
Diferencias finitas: caso no lineal
Problema de contorno

Nodos de discretizacin
a = x
0
< x
1
< ... < x
n
< x
n+1
= b
Aproximaciones en los nodos
| | | = o = e = ) b ( y , ) a ( y ; b , a x ), ' y , y , x ( f " y
2
1 1
1 1
2
2
h
y y y
) x ( " y " y
h
y y
) x ( ' y ' y ) x ( y y
i i i
i i
i i
i i i i
+
+
+
~ ~

~ ~ ~
Discretizacin del problema no
lineal
| =
o =
=
|
.
|

\
|

+
+

=
+
+ +
1
0
1 1
2
1 1


0
2
2
2 1
N
i i
i i
i i i
y
y
h
y y
, y , x f
h
y y y
N ,...., , i Para
Derivada
segunda
Condiciones de contorno
Derivada
primera z
i

( )
( )
( )
( )

= | + +
= + +
= + +
= o +


0 2
0 2

0 2
0 2
2
1
1 1 1
2
1 2
2 2 2
2
3 2 1
1 1 1
2
2 1
N N N N N
N N N N N N
z , y , x f h y y
z , y , x f h y y y
z , y , x f h y y y
z , y , x f h y y

Sistema no lineal
Lo resolvemos por Newton
Jacobiano
) z , y , x ( f h a a
i i i y i , i i
2
2+ = =
) z , y , x ( f ) h ( a b
i i i z i , i i
2 1
1
+ = =
+
) z , y , x ( f ) h ( a c
i i i z i , i i 1 1 1 1
2 1
+ + + +
= =
Diagonal: para i = 1, 2, ..., n

Superdiagonal: para i = 1, 2, ..., n1

Superdiagonal: para i = 1, 2, ..., n1
( )
( )
( )
|
|
|
|
|
|
|
.
|

\
|
+ | +
+ +
+ + o
=
N N N N N
z , y , x f h y y
z , y , x f h y y y
z , y , x f h y y
d
2
1
2 2 2
2
3 2 1
1 1 1
2
2 1
2
2
2

Trmino independiente
diff(y,2)
function [f,fy,fz] = fun(x,y,z)
% y" = (32 + 2x^3 -yy')/8
% Valor de y"
f = (32 + 2*x.^3 -y.*z)/8;
% Parcial respecto a y
fy = -z/8;
% Parcial respecto a y'
fz = -y/8;
( ) | | 3 1 2 32
8
1
3
, x ' yy x ' ' y e + =
Ejemplo
MtodosVariacionales:
Rayleigh-Ritz
TEOREMA: Bajo ciertas condiciones para las
funciones p(x), q(x) y f(x), y(x) es la solucin
del problema de frontera

si y slo si y(x) es la nica funcin que
minimiza la integral
0 ) 1 ( ) 0 (
(1) 1 0 ) ( ) ( ) (
= =
s s = +
|
.
|

\
|

y y
x x f y x q
dx
dy
x p
dx
d
| | | | { }
}
+ =
1
0
2 2
(2) ) ( ) ( 2 ) ( ) ( ) ( ' ) ( ) ( dx x u x f x u x q x u x p u I
{ }
n
| | | ,..., ,
2 1
n i
i i
,..., 2 , 1 0 ) 1 ( ) 0 ( = = =| |
Funciones base
La integral I se minimiza en el subespacio
generado por las funciones base


Las funciones base
son linealmente independientes
verifican las condiciones de contorno

=
=
n
i
i i
x c x
1
) ( ) ( | |
{ }
dx x x f b
dx x x x q x x x p a
j j
j i j i ij
) ( ) (
) ( ) ( ) ( ) ( ) ( ) (
1
0
1
0
' '
|
| | | |
}
}
=
+ =
Solucin aproximada
Hallaremos una aproximacin a la solucin
y(x) de (1),


eligiendo los coeficientes para que
minimicen la integral I(f).
Se obtiene el sistema lineal A c = b donde
Funciones base: polinomios
lineales a trozos
Dada una particin de [0,1]
donde
1 ... 0
1 2 1 0
= < < < < < =
+ n n
x x x x x
n i x x h
i i i
,..., 1 , 0
1
= =
+
n i
x x
x x x
h
x x
x x x
h
x x
x x
x
i
i i
i
i
i i
i
i
i
i
,..., 2 , 1
1 0


0 0
) (
1
1
1
1
1
1
1
=

s <
s <

s <

s s
=
+
+
+

|
Coeficientes del sistema
{ }
{} {}
}
}
} }
}
+

)
`


+
+
)
`


+ =
= + =
| | + | | =
+

1
1
1
1
2
2
1
2
2
1
2
1
2
1
1
0
1
1
i
i
i
i
i
i
i
i
x
x
i
i
i
x
x
i
i
i
x
x
x
x
ii
j i
'
j
'
i ij
dx ) x ( q
h
) x x (
) x ( p
h
dx ) x ( q
h
) x x (
) x ( p
h
dx dx a
dx ) x ( ) x ( ) x ( q ) x ( ) x ( ) x ( p a
Coeficientes del sistema
} }
}
+

=
)
`


+ =

+
+
1
1
1
1
1
2
1
2
1
1
i
i
i
i
i
i
x
x
i
i
x
x
i
i
i
x
x
i
i i
i
i , i
dx ) x ( f
h
) x x (
dx ) x ( f
h
) x x (
b
dx ) x ( q
h
) x x )( x x (
) x ( p
h
a
Trminos independientes
Algoritmo de elementos finitos
lineales
Entrada: problema, particin del intervalo
Proceso:
En cada subintervalo [x
i
, x
i+1
] hallar las integrales
que aparecen el las frmulas de los coeficientes
del sistema.
Combinar adecuadamente las integrales
calculadas para obtener los coeficientes.
Resolver el sistema lineal.
Salida: aproximacin lineal a trozos de la solucin.

Integrales a evaluar: i = 0, ..., n
} }
}
} }
}
+ +
+
+ +
+

=

=

=
=
+
+
+
1 1
1
1 1
1
1
2
1
2
2
1
2
2
2
1
i
i
i
i
i
i
i
i
i
i
i
i
x
x
i
i
i
x
x
i
i
i
x
x
i
i i
i
x
x
i
i
i
x
x
i
i
i
x
x
i
i
dx ) x ( f
h
) x x (
rr dx ) x ( f
h
) x x (
rl
dx ) x ( q
h
) x x )( x x (
qh
dx ) x ( q
h
) x x (
qr dx ) x ( q
h
) x x (
ql
dx ) x ( p
h
ph
Coeficientes del sistema
Matriz del sistema
Diagonal: para i = 1, 2, ..., n
a
i
= ph
i1
+ ph
i
+ ql
i1
+ qr
i

Sub y superdiagonal: para i = 1, 2, ..., n1
b
i
= c
i
= qh
i
ph
i

Trminos independientes: para i = 1, 2, ..., n
d
i
= rl
i1
+ rr
i
Ejemplo
Solucin exacta: y(x)=sen (tx)
Tomamos h=0.1, x
i
= 0.1 i i=0,1,,9,10
| | 0 ) 1 ( ) 0 ( , 1 , 0
) sen( 2 ' '
2 2
= = e
= +
y y x
x y y t t t
00410877 . 1
95496419 . 0
81234106 . 0
59020033 . 0
31028667 . 0
5
6
7
8
9
=
=
=
=
=
c
c
c
c
c
31028667 . 0
59020033 . 0
81234106 . 0
95496419 . 0
1
2
3
4
=
=
=
=
c
c
c
c
F I N

También podría gustarte