Diferencia entre revisiones de «Logistic equation»
De MateWiki
| Línea 25: | Línea 25: | ||
<gallery> | <gallery> | ||
| − | Archivo:solucion.jpg|Aproximación numérica | + | Archivo:solucion.jpg|500px|Aproximación numérica |
| − | Archivo:error.jpg|Error entre la solución exacta y la aproximación numérica | + | Archivo:error.jpg|500px|Error entre la solución exacta y la aproximación numérica |
</gallery> | </gallery> | ||
Revisión del 13:03 31 ene 2013
Resolución de la Ecuación logística por el método de Euler
- Logistic equation:
[math]y0 = f (t,y) = y(1-y)[/math]
- y(t0) = y0:
- Numerical scheme
- y(0) = 1/10
- y(n+1) = y(n) + h y(n)(1 - y(n))
- MATLAB code
% Euler method to solve the logistic equation y'=y(1-y)
clear all;
t0=0; tN=4; % initial and final time
y0=1/10; % value of y at time t=0
N=40; % Number of intervals
h=(tN-t0)/40; % Time step h
yy=y0; % yy -> variable with the solution at each time step
y(1)=yy; % y -> vector where we store the solution
for n=1:N-1
yy=yy+h*yy*(1-yy); % numerical scheme
y(n+1)=yy; % store the solution
end
x=t0:h:tN; % Draw the solution
plot(x,y,'x');