Professional Documents
Culture Documents
1/34
2/34
ndice
Introduccin
Introduccin
3/34
En este tema analizamos los problemas que se pueden modelizar mediante una
ecuacin diferencial de segundo orden con condiciones en dos puntos dados,
extremos de un intervalo de estudio a; b.
y.a/ D ;
y.b/ D :
4/34
Shooting method
Con tal fin se genera una sucesin de problemas de valor inicial que converja al
dado.
Chemical
5/34
F .s/ D
6/34
< y D 4y
y.0/ D 1
: y.1/ D 3:
function z=F(s)
a=0; b=1; yb=3;
ydot = @(t,y) [y(2); 4*y(1)];
[t,y]= ode45(ydot,[a,b],[1,s]); % Solver de Matlab
z
= y(end,1)-yb
end
-1
0
0.1
0.2
0.3
0.4
0.5
Tiempo
0.6
0.7
0.8
0.9
7/34
Si y.t/ es una funcin con derivadas continuas al menos hasta cuarto orden,
sabemos que
0
y .t / D
y.t C h/
y.t
h/
2h
h2 000
y ./
6
y que
00
y .t / D
y.t C h/
2y.t/ C y.t
h2
h/
h2 000
C y ./:
12
8/34
for approximations wi to the correct values yi , as shown in Figure 7.6. The boundary
conditions are substituted in the system of equations where they are needed.
y
1
w1
w2
ya
y1
y2
wn1
wn
yn1
t0
t1
t 2 ...
yn
tn1 tn
yb
tn+1
Figure 7.6 The Finite Difference Method for BVPs. Approximations wi , i = 1, . . . , n for
the correct values yi at discrete points ti are calculated by solving a linear system of
equations.
objetivo
es reemplazar los y , y ; : : : ; y reales de la trayectoria por sus
El
1
2
n
aproximaciones
por diferencias
finitas,
wi . situations. If the original boundary value
After the substitutions,
there are
two possible
problem was linear, then the resulting system of equations is linear and can be solved by
Gaussian elimination or iterative methods. If the original problem was nonlinear, then
Si el
de contorno
original
es linealequations,
el problema
se convierte
entonces
theproblema
algebraic system
is a system
of nonlinear
requiring
more sophisticated
begin with
linear example.
en approaches.
resolver unWesistema
de aecuaciones
lineales; si no es lineal, en lo propio.
9/34
10/34
< y D 4y
y.0/ D 1
: y.1/ D 3:
1C
w1 C
w2 C
11/34
9
4
w3
ti
0;00
0;25
0;50
0;75
1;05
wi
1;0000
1;0249
1;3061
1;9138
3;0000
yi
1;0000
1;0181
1;2961
1;9049
3;0000
Las diferencias son O.10 2/. Para obtener ms precisin habra que aumentar n.
12/34
0
4h
wn
<y D y
y2
y.0/ D 1
: y.1/ D 4:
2wi C wi
h2
wi C wi2 D 0
o
wi
para 2 i n
2 C h2 wi C h2wi2 C wiC1 D 0;
1.
13/34
14/34
J .wk / 1f .wk /:
La funcin vectorial es
2
ya
6
6 w1
6
f .wk / D 6
6
4wn 2
wn 1
3
2 C h2 w1 C h2 w12 C w2
7
2 C h2 w2 C h2 w22 C w3 7
7
::
7;
:
7
2 C h2 wn 1 C h2 wn2 1 C wn 5
2 C h2 wn C h2 wn2 C yb
donde ya D 1 y yb D 4.
22h2w
2 C h2
6
La Jacobiana: 6
4
0
::
:
0
0
:
::
2h2 w1
2 C h2
::
:
1
::
::
:
: 2h2 w1
0
::
:
1
7
7:
5
0
2C
0
::
:
h2
1
2h2 wn
2 C h2
15/34
4.5
3.5
2.5
function a=jac(w,h,n)
1.5
a=zeros(n,n);
for i=1:n
a(i,i)=2*h^2*w(i)-2-h^2;
1
end
0
for i=1:n-1
a(i,i+1)=1;
a(i+1,i)=1;
end
end
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
16/34
17/34
18/34
Mtodo de colocacin
Resolvamos la ecuacin
8
00
< y D 4y
y.0/ D 1
: y.1/ D 3:
Pn
j D1 cj j .t /
Pn
j D1 cj t
j 1
n
X
cj j .0/ D y.0/ D 1
j D1
c1 C C cn D
n
X
cj j .1/ D y.1/ D 3:
j D1
En el ejemplo,
n h
X
j D1
j D1
1 j
j
2 ti
j 1
4ti
cj D 0;
j D1
i D 2; : : : ; n
1:
19/34
1 0 0 0
<
Aij D j 1 j 2 tij
:1 1 1 1
fila i D 1
3
j 1
filas i D 2; : : : ; n
4ti
fila i D n
y b D 1 0 0 0 3T .
i
n
1
.b
1
i
n
1 0
1 1
c1
c2
1
D 3 ;
1
:
1
20/34
Para n D 4 el sistema es
2
4
1
4
4
1
0
4 1=3 2
4 2=3 2
1
21/34
32 3
0
0
c1
2
4 .1=3/ 6 1=3 4 .1=3/3 5 4c2 5
c3
4 .2=3/2 6 2=3 4 .2=3/3
c4
1
1
23
D
1
405 ;
0
3
3
Exacta
y(t)=1+2t
2
y(t)=1-0.1886t+1.0273t +1.1613t
2.5
1.5
0.5
0.1
0.2
0.3
0.4
0.5
Tiempo
0.6
0.7
0.8
0.9
22/34
El ejemplo que hemos utilizado para introducir el mtodo era lineal, pues as lo
era la ecuacin diferencial. Si fuese no lineal, habra que utilizar el mtodo de
Newton-Raphson para resolver el sistema de ecuaciones no lineales que resultase.
Igual que hemos utilizado monomios como funciones base para aplicar el
mtodo, se puede recurrir a cualesquiera otras: polinomios de Chebyshev,
funciones trigonomtricas, etc.
23/34
24/34
8
00
0
< y D f .t; y; y /
y.a/ D y
: y.b/ D y ;
b
f sea
25/34
26/34
00
y .t/i .t/ dt D
forma dbil
para cada 0 i n C 1.
2- Utilizar integracin por partes para eliminar las segundas derivadas.
Teniendo en cuenta que
b
b
y .t/i .t/ dt D i .t/y 0 .t/a
00
D i .b/y 0 .b/
y 0 .t/i0 .t/ dt
Z b
a
i .a/y 0 .a/
y 0 .t/i0 .t/ dt:
a
i .a/y 0 .a/
27/34
nC1
X
ci i .t /:
i D0
Para ello, en los puntos t0 < t1 < < tn < tnC1 sobre el eje t, para
i D 1; : : : ; n, se define
i .t / D
8
t
< i
ti 1
ti 1
ti C1 t
tiC1 ti
:0
para ti
< t ti
28/34
Y, tambin,
0.t/ D
8
<
t1 t
ti t0
:0
para t0 t < t1
en otros casos7.3
y nC1.t / D
8
<
t tn
tnC1 tn
0 ElementenMethod
otros casos.
Collocation and the Finite
| 369
:
y
1
0 1 2
t0
t1
t2
n1 n n+1
t 3 ...
tn1 tn
tn+1
Figure 7.10 Piecewise-linear B-splines used as nite elements. Each i (t), for
1 i n, has support on the interval from ti1 to ti+1 .
1 si i D j
0 si i j:
for each i that can be solved for the ci in the functional form
y(t) =
n+1
ci i (t).
(7.23)
29/34
nC1
X
ci i .t /:
i D0
PnC1
iD0
ci i .tj / D cj .
S.t/ es una funcin lineal por tramos que interpola los puntos .ti ; ci /. Adems,
los ci son las soluciones en los puntos ti de la aproximacin de la ecuacin
diferencial.
30/34
nC1
X
ci i .a/ D c00.a/ D c0
i D0
y.b/ D
nC1
X
i D0
b
a
i0 .t /
cj j0 .t / dt D 0:
31/34
Z
i .t/i C1 .t/ dt D
D
b
t2
2h
Z b
t
t
t
1
dt D
h
h
h
a
3 h
t
3h2 D h6
h
t
h
2
b
0
.t/ dt
i0 .t/iC1
0 2
i .t/
a
dt
i .t/ dt D 2
Z
t2
h2
1
h
h
Z
D
dt D 2
0
2
1
h
1
h
2
2
dt D h
3
dt D
1
h
2
dt D :
h
32/34
8
00
< y D 4y
y.0/ D 1
: y.1/ D 3:
4i .t/
nC1
i
j D0
j D0
cj j .t/ C
j D0
Z
cj 4
Z
i .t/j .t/ dt C
:
33/34
2
1
h
c0 C
8
2
h
c1 C
2
1
h
c2 D 0
2
1
h
c1 C
8
2
h
c1 C
2
1
h
c1 D 0
h
3
h
3
hC
3
hC
3
h
3
h
3
::
: 0
1
h
2
h
3
cn
8
hC
3
2
h
cn C
2
h
3
1
h
cnC1 D 0:
6
60
6
6:
4 ::
0
donde
cn
2
2
8
y D h
D hC
3
h
3
yb
1
:
h
34/34
function c=Galerkin_ef_1(inter,bv,n)
% Elementos finitos de ejemplo clase
%
inter, intervalo de integracin; bv, valores de contorno;
%
n, nmero de pasos.
a=inter(1); b=inter(2); ya=bv(1); yb=bv(2);
h=(b-a)/(n+1);
alfa=(8/3)*h+2/h; beta=(2/3)*h-1/h;
e=ones(n,1);
M=spdiags([beta*e alfa*e beta*e],-1:1,n,n);
d=zeros(n,1); d(1)=-ya*beta; d(n)=-yb*beta;
c=M\d;
end
ti
0;00
0;25
0;50
0;75
1;05
ci
1;0000
1;0109
1;2855
1;8955
3;0000
yi
1;0000
1;0181
1;2961
1;9049
3;0000
Las diferencias son O.10 2/. Para obtener ms precisin habra que aumentar n.