# Logistic equation

Saltar a: navegación, buscar
Título Ecuación logística. Grupo 6B
Asignatura Ecuaciones Diferenciales
Curso Curso 2015-16
Autores Carlos Castro
Este artículo ha sido escrito por estudiantes como parte de su evaluación en la asignatura

This article shows how to solve the logistic equation using the Euler Method.

## 1 Logistic equation

Logistic equation is used to simulate a number of applications. It was first introduced by P.F. Verhulst to simulate population growth. It reads,

$y' = y\cdot (1-y), \quad t\in(t_0,\infty)$

$y(t_0) = y_0$

Here, t is the time, $y(t)$ represents the population size and $y_0$ the population size at initial time $t=t_0$.

## 2 Numerical scheme

We propose an Euler explicit method with time step h,

$y_0, \; t_0$

$y_{n+1} = y_{n} + h\cdot y_{n}\cdot(1 - y_{n})$

## 3 MATLAB code

 1 % Euler method to solve the logistic equation y'=y(1-y)
2 clear all;
3 t0=0; tN=4;           % initial and final time
4 f=@(t,y) y*(1-y);     % define function f(t,y)=y(1-y)
5 y0=1/10;              % value of y at time t=0
6 N=40;                 % Number of intervals
7 h=(tN-t0)/40;         % Time step h
8 yy=y0;                % yy -> variable with the solution at each time step
9 y(1)=yy;              % y -> vector where we store the solution
10 for n=1:N
11    yy=yy+h*f(t(n),y(n));  % numerical scheme
12    y(n+1)=yy;             % store the solution in the vector y
13 end
14 x=t0:h:tN;                % Draw the solution
15 plot(x,y,'x');


## 4 Results

Consider the particular case: $y_0=1/10, \; t_0=0, \; h=1/10$ The exact solution can be computed in this case: $y(t)=\frac{e^t}{9+e^t}$

 Numerical approximation of the solution Error = abs( exact solution - numerical approximation)

--Carlos Castro (discusión) 15:09 31 ene 2013 (CET)