Problemas de frontera para ecuaciones diferenciales Cálculo Numérico Práctica 3.

Post on 22-Jan-2016

227 views 0 download

Transcript of Problemas de frontera para ecuaciones diferenciales Cálculo Numérico Práctica 3.

Problemas de frontera para ecuaciones diferenciales

Cálculo Numérico

Práctica 3

Algoritmos de resolución Algoritmos auxiliares

• Problema de valor inicial

• Sistemas lineales tridiagonales

Métodos de disparo• Problema lineales y no lineales

Métodos de diferencias finitas• Problema lineales y no lineales

Métodos variacionales• Elementos lineales y cúbicos

Problema de valor inicial

siendo,

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)

% Ecuación 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

nn

nnn

d

d

d

d

d

x

x

x

x

x

ac

bac

bac

bac

ba

1

3

2

1

1

3

2

1

1

112

332

221

11

Algoritmo de Crout % Eliminación 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 % Sustitución 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 parámetros t = tk para que

)b(y )a(y

b,ax )'y,y,x(f''y

kt)a('y )a(y

b,ax )'y,y,x(f''y

)b(y)t,b(yklim k

Método de disparo no lineal

Disparo con la secante

tk: ángulo de tiro,

y'(a) = tk,

k=1,2,...

Iterar los tk según la fórmula

1kk

1kk

kk1k

tt

)t,b(y)t,b(y)t,b(y

tt

1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 612

13

14

15

16

17

18

19

20

21

k

y(b,tk)

Algoritmo de disparo secante

Entradas: f, a, b, , , tol, maxiter Proceso

• Estimar t0 y t1

• Disparar con y(a) = , y’(a) = t0 para hallar y(b,t0)

• Disparar con y(a) = , y’(a) = t1 para hallar y(b,t1)

• Mientras |y(b,tk) )| > tol y k < maxiterHallar tk+1 por la fórmula de la secanteDisparar con y’(a)=tk+1 para hallar y(b,tk+1)

Salida: y

Solución exacta:

Criterio de parada:

3

43)3(y 17)1(y

3,1x 'yyx2328

1''y 3

x

16x)x(y 2

5k 10

3

43)t,3(y

Ejemplo

1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 311

12

13

14

15

16

17

Diferencias finitas: caso no lineal Problema de contorno

Nodos de discretización

a = x0 < x1 < ... < xn < xn+1 = b

Aproximaciones en los nodos

)b(y,)a(y;b,ax),'y,y,x(f"y

211

11

22

h

yyy)x("y"y

h

yy)x('y'y)x(yy

iiiii

iiiiii

Discretización del problema no lineal

1

0

112

11

02

2

21

N

iiii

iii

y

y

h

yy,y,xf

h

yyy

N,....,,iPara

Derivadasegunda

Condiciones de contorno

Derivadaprimera zi

02

02

02

02

21

1112

12

2222

321

1112

21

NNNNN

NNNNNN

z,y,xfhyy

z,y,xfhyyy

z,y,xfhyyy

z,y,xfhyy

Sistema no lineal

Lo resolvemos por Newton

Jacobiano

)z,y,x(fhaa iiiyi,ii22

)z,y,x(f)h(ab iiizi,ii 211

)z,y,x(f)h(ac iiizi,ii 1111 21

Diagonal: para i = 1, 2, ..., n

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

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

NNNNN z,y,xfhyy

z,y,xfhyyy

z,y,xfhyy

d

21

2222

321

1112

21

2

2

2

Término 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;

31 2328

1 3 ,x'yyx''y Ejemplo

MétodosVariacionales:Rayleigh-Ritz TEOREMA: Bajo ciertas condiciones para las

funciones p(x), q(x) y f(x), y(x) es la solución del problema de frontera

si y sólo si y(x) es la única función que minimiza la integral

0)1()0(

(1) 10 )()()(

yy

xxfyxqdx

dyxp

dx

d

1

0

22 (2) )()(2)()()(')()( dxxuxfxuxqxuxpuI

n ,...,, 21

niii ,...,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

iii xcx

1

)()(

dxxxfb

dxxxxqxxxpa

jj

jijiij

)()(

)()()()()()(

1

0

1

0

''

Solución aproximada Hallaremos una aproximación a la solución

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 partición de [0,1]

donde

1...0 1210 nn xxxxx

nixxh iii ,...,1,0 1

ni

xx

xxxh

xx

xxxh

xx

xx

x

i

iii

i

iii

i

i

i ,...,2,1

1 0

0 0

)(

1

11

11

1

1

Coeficientes del sistema

1

1

1

1

2

21

2

21

21

21

1

0

1

1

i

i

i

i

i

i

i

i

x

xi

i

i

x

xi

i

i

x

x

x

xii

ji'j

'iij

dx)x(qh

)xx()x(p

h

dx)x(qh

)xx()x(p

h

dxdxa

dx)x()x()x(q)x()x()x(pa

Coeficientes del sistema

1

1

1

1

1

21

21

1

i

i

i

i

i

i

x

xi

ix

xi

ii

x

xi

ii

i

i,i

dx)x(fh

)xx(dx)x(f

h

)xx(b

dx)x(qh

)xx)(xx()x(p

ha

Términos independientes

Algoritmo de elementos finitos lineales Entrada: problema, partición del intervalo Proceso:

• En cada subintervalo [xi, xi+1] hallar las integrales que aparecen el las fórmulas de los coeficientes del sistema.

• Combinar adecuadamente las integrales calculadas para obtener los coeficientes.

• Resolver el sistema lineal. Salida: aproximación lineal a trozos de la solución.

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

11

1

11

1

1

21

2

21

2

2

2

1

i

i

i

i

i

i

i

i

i

i

i

i

x

xi

ii

x

xi

ii

x

xi

iii

x

xi

ii

x

xi

ii

x

xi

i

dx)x(fh

)xx(rrdx)x(f

h

)xx(rl

dx)x(qh

)xx)(xx(qh

dx)x(qh

)xx(qrdx)x(q

h

)xx(ql

dx)x(ph

ph

Coeficientes del sistema

Matriz del sistema

Diagonal: para i = 1, 2, ..., n

ai = phi1 + phi + qli1 + qri

Sub y superdiagonal: para i = 1, 2, ..., n1

bi = ci = qhi phi

Términos independientes: para i = 1, 2, ..., n

di = rli1 + rri

Ejemplo

Solución exacta: y(x)=sen (x) Tomamos h=0.1, xi = 0.1 i i=0,1,…,9,10

0)1()0( ,1,0

) sen(2'' 22

yyx

xyy

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