Diferencia entre revisiones de «Reacciones con Autocatálisis (A5)»

De MateWiki
Saltar a: navegación, buscar
Línea 1: Línea 1:
 
{{ TrabajoED | Reacciones con Autocatálisis. Grupo 5A | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED14/15|Curso 2014-15]] |Javier Blanco Villarroel<br />Marta Cavero Guillén<br />Alba Bringas Gil<br />Irene Bendala Sugrañes<br />Paula Botella Andreu}}
 
{{ TrabajoED | Reacciones con Autocatálisis. Grupo 5A | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED14/15|Curso 2014-15]] |Javier Blanco Villarroel<br />Marta Cavero Guillén<br />Alba Bringas Gil<br />Irene Bendala Sugrañes<br />Paula Botella Andreu}}
 +
 +
{{matlab|codigo=
 +
%Ejercicio 2.2 Euler
 +
t0=0
 +
tn=10
 +
n=100
 +
h=(tn-t0)/n;
 +
t=t0:h:tn;
 +
 +
y0=1
 +
y=zeros(1,n+1);
 +
y(1)=y0;
 +
yy=y0;
 +
 +
k=1
 +
 +
x0=0.01
 +
x=zeros(1,n+1);
 +
x(1)=x0;
 +
xx=x0;
 +
 +
for i=1:n
 +
  yy=yy+h*(-k*xx.*yy);
 +
  xx=xx+h*k*(xx.*yy);
 +
  y(i+1)=yy;
 +
  x(i+1)=xx;
 +
  end
 +
 
 +
plot(t,x,'+')
 +
hold on
 +
plot(t,y,'g*')}}
 +
 +
{{matlab|codigo=
 +
%Ejercicio 2.3 trapecio
 +
t0=0
 +
tn=10
 +
n=100
 +
h=(tn-t0)/n;
 +
t=t0:h:tn;
 +
 +
y0=1
 +
y=zeros(1,n+1);
 +
y(1)=y0;
 +
yy=y0;
 +
 +
k=1
 +
 +
x0=0.01;
 +
x=zeros(1,n+1);
 +
x(1)=x0;
 +
xx=x0;
 +
 +
for i=1:n
 +
  yy=(((2*yy)/(-k*h))+xx.*yy)/((-2/(k*h))+(-k*xx));
 +
  xx=(((2*xx)/(k*h))+xx.*yy)/((2/(k*h))-(k*yy));
 +
  y(i+1)=yy;
 +
  x(i+1)=xx;
 +
  end
 +
 +
plot(t,y,'g')
 +
hold on 
 +
plot(t,x,'r')}}
 +
 +
{{matlab|codigo=
 +
%Ejercicio 2.3 Runge Kutta
 +
t0=0
 +
tn=10
 +
n=100
 +
h=(tn-t0)/n;
 +
t=t0:h:tn;
 +
 +
y0=1
 +
y=zeros(1,n+1);
 +
y(1)=y0;
 +
yy=y0;
 +
 +
k=1
 +
 +
x0=0.01
 +
x=zeros(1,n+1);
 +
x(1)=x0;
 +
xx=x0;
 +
 +
for i =1:n
 +
 +
k1A=(-k*xx.*yy);
 +
k1B=(k*xx.*yy);
 +
y1=yy+h*k1A/2;
 +
x1=xx+h*k1B/2
 +
 +
k2A=(-k*x1.*y1);
 +
k2B=(k*x1.*y1);
 +
y2=yy+h*k2A/2;
 +
x2=xx+h*k2B/2;
 +
 +
k3A=(-k*x2.*y2);
 +
k3B=(k*x2.*y2);
 +
y3=yy+h*k3A/2;
 +
x3=xx+h*k3B/2;
 +
 +
k4A=(-k*x3.*y3);
 +
k4B=(k*x3.*y3);
 +
 +
yy=yy+((h/6)*(k1A+2*k2A+2*k3A+k4A));
 +
xx=xx+((h/6)*(k1B+2*k2B+2*k3B+k4B));
 +
y(i+1)=yy;
 +
x(i+1)=xx;
 +
end
 +
 +
figure(1) 
 +
plot(t,y)
 +
 +
hold on
 +
plot(t,x,'g')}}

Revisión del 11:00 25 feb 2015

Trabajo realizado por estudiantes
Título Reacciones con Autocatálisis. Grupo 5A
Asignatura Ecuaciones Diferenciales
Curso Curso 2014-15
Autores Javier Blanco Villarroel
Marta Cavero Guillén
Alba Bringas Gil
Irene Bendala Sugrañes
Paula Botella Andreu
Este artículo ha sido escrito por estudiantes como parte de su evaluación en la asignatura


%Ejercicio 2.2 Euler
t0=0
tn=10
n=100
h=(tn-t0)/n;
t=t0:h:tn;

y0=1
y=zeros(1,n+1);
y(1)=y0;
yy=y0;

k=1

x0=0.01
x=zeros(1,n+1);
x(1)=x0;
xx=x0;

for i=1:n
   yy=yy+h*(-k*xx.*yy);
   xx=xx+h*k*(xx.*yy);
   y(i+1)=yy;
   x(i+1)=xx;
   end
   
plot(t,x,'+')
hold on
plot(t,y,'g*')


%Ejercicio 2.3 trapecio
t0=0
tn=10
n=100
h=(tn-t0)/n;
t=t0:h:tn;

y0=1
y=zeros(1,n+1);
y(1)=y0;
yy=y0;

k=1

x0=0.01;
x=zeros(1,n+1);
x(1)=x0;
xx=x0;

for i=1:n
   yy=(((2*yy)/(-k*h))+xx.*yy)/((-2/(k*h))+(-k*xx));
   xx=(((2*xx)/(k*h))+xx.*yy)/((2/(k*h))-(k*yy));
   y(i+1)=yy;
   x(i+1)=xx;
   end

plot(t,y,'g') 
hold on  
plot(t,x,'r')


%Ejercicio 2.3 Runge Kutta
t0=0
tn=10
n=100
h=(tn-t0)/n;
t=t0:h:tn;

y0=1
y=zeros(1,n+1);
y(1)=y0;
yy=y0;

k=1

x0=0.01
x=zeros(1,n+1);
x(1)=x0;
xx=x0;

for i =1:n

 k1A=(-k*xx.*yy);
 k1B=(k*xx.*yy);
 y1=yy+h*k1A/2;
 x1=xx+h*k1B/2
 
 k2A=(-k*x1.*y1);
 k2B=(k*x1.*y1);
 y2=yy+h*k2A/2;
 x2=xx+h*k2B/2;
 
 k3A=(-k*x2.*y2);
 k3B=(k*x2.*y2);
 y3=yy+h*k3A/2;
 x3=xx+h*k3B/2;
 
 k4A=(-k*x3.*y3);
 k4B=(k*x3.*y3);
 
 yy=yy+((h/6)*(k1A+2*k2A+2*k3A+k4A));
 xx=xx+((h/6)*(k1B+2*k2B+2*k3B+k4B));
 y(i+1)=yy;
 x(i+1)=xx;
 end

figure(1)   
plot(t,y)

hold on
plot(t,x,'g')