0% found this document useful (0 votes)
35 views19 pages

Assignment 1 Marc Cent Elles

Uploaded by

ermi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views19 pages

Assignment 1 Marc Cent Elles

Uploaded by

ermi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Mathematical Methods]

Assignment 1

Authors:

Marc Centelles Molina

Submission Date:

Tuesday, December 3, 2024


1. Wilson-Cowan: A Model of Activity of Neural Pop-
ulations
We consider the average activity of a large neural population consisting of two types, i.e.,
excitatory (E) and inhibitory (I) cells. For the state space, we consider the unit square
0 ≤ E, I ≤ 1. The model is given by:

E ′ = −E + (1 − E)Se (c1 E − c2 I + P ),
(1)
I ′ = −I + (1 − I)Si (c3 E − c4 I + Q),
where the function Sx (u) with x = E, I is defined by:
1 1
Sx (u) = − .
1 + exp(−bx (u − θx )) 1 + exp(bx θx )
Reading this function definition carefully, we see that u = c1 E − c2 I + P is the argument
of the function Se for E ′ , and not multiplication.
The parameters are given by:

θe = 4, be = 1.3, θi = 3.7, bi = 2, Q = 1, c1 = 20, c2 = 11.5, c3 = 15, c4 = 1, P = 2.

The excitatory population becomes active due to input P and excites both itself through
recurrent connections and the inhibitory population by projecting synapses.

2. Exercises (6 points)
The first two items are meant to structure your code and are necessary to solve later
parts.

1. Write a MATLAB function WC.m so that the call f=WC(t,X) is the evaluation of (1),
and f = (E’, I’) is a column vector. (0 points)

2. Write a MATLAB function JACWC.m so that the call A=JACWC(t,X) returns the
Jacobian matrix fX . We expect you to use the result from Tutorial 1. (0 points)

3. The equations dE
dt
= 0 and dIdt
= 0 define the nullclines. On the nullclines, solution
curves turn direction, i.e., up/right ↔ down/left. Since E ′ = 0 involves only one
term with I, we can write I as a function of E. Plot the resulting curves. (1.5
points)
Alternative to finding an analytical expression for the nullclines, you may consider
a root-finding method. In this case, for every fixed value of E, find I such that
E ′ = 0, and do this for a suitable range of values for E.

4. Find all equilibria of the Wilson-Cowan model for these parameter values numeri-
cally. (1 point)

5. Determine the linearization for each fixed point. Classify the fixed points based on
the eigenvalues. Make local phase portraits of the linearization x′ = Df (E0 , I0 )x in
separate figures. (1.5 points)

1
6. Make a global phase portrait for a relevant part of the unit square 0 ≤ E, I ≤ 1.
Your figure should contain the nullclines, the equilibria, and a few solutions (orbits).
Create these solutions by simulating the model with the Euler-Forward method and
use at most 10 initial conditions. For the equilibria with real eigenvalues, also plot
the lines given by X(s) = x0 +sv with v an eigenvector. Provide a short description
of this figure and comment on the attractors, i.e., where do the orbits go to? (2
points)

2
Exercise 1: Writing the WC.m Function
The objective of this exercise is to write a MATLAB function, WC.m, that evaluates the
Wilson-Cowan model equations. The function has to calculate the derivatives E ′ and I ′
of the excitatory and inhibitory populations, using the model parameters and equations
that were given in the proposed problem.
The function is defined such that the call f = WC(t, X) returns a column vector f =
(E’, I’) based on the equations:

E ′ = −E + (1 − E)Se (c1 E − c2 I + P ),
I ′ = −I + (1 − I)Si (c3 E − c4 I + Q),
where Sx (u) for x = E, I is given by:
1 1
Sx (u) = − .
1 + exp(−bx (u − δx )) 1 + exp(bx δx )

MATLAB Implementation
Below is the MATLAB code for the function WC.m:
1 % % Exercise 1
2
3 % We define all of the parameters
4 delta_e = 4;
5 b_e = 1.3;
6 delta_i = 3.7;
7 b_i = 2;
8 Q = 1;
9 c_1 = 20;
10 c_2 = 11.5;
11 c_3 = 15;
12 c_4 = 1;
13 P = 2;
14
15 function f = WC (t , X )
16 % Extract the variables from X
17 E = X (1) ;
18 I = X (2) ;
19
20 % Compute the arguments for S_e and S_i
21 u_e = c_1 * E - c_2 * I + P ;
22 u_i = c_3 * E - c_4 * I + Q ;
23

24 % Compute S_e and S_i


25 S_e = 1/(1 + exp ( - b_e *( u_e - delta_e ) ) ) - 1/(1 + exp ( b_e * delta_e ) ) ;
26 S_i = 1/(1 + exp ( - b_i *( u_i - delta_i ) ) ) - 1/(1 + exp ( b_i * delta_i ) ) ;
27
28 % Compute the derivatives E ’ and I ’
29 E_prima = -E + (1 - E ) * S_e ;
30 I_prima = -I + (1 - I ) * S_i ;
31
32 % Return the derivatives as a column vector
33 f = [ E_prima ; I_prima ];
34 end

Listing 1: MATLAB Code for WC.m

3
Explanation of the Code
1. Parameter Definition: The parameters of the Wilson-Cowan model, like c1 , c2 , be ,
and δe , are computed at the beginning. These parameters change the state of the
excitatory and inhibitory populations.

2. Inputs and Output.

• The function WC has two inputs: t, the current time (which is actually not
being used in the overall definition because it only does the derivatives in one
a fixed time), and X, a vector containing the values of E and I at a given time,
the first on being E and the second one being I.
• The output f is a column vector that has the final derivatives E ′ and I ′ .

3. Intermediate Calculations that are done to extract the derivatives:

• The middle variables ue and ui that are used for the functions Se and Si are
computed using the equations in the stated before.
• The activation functions Se and Si are calculated based also on their respective
definitions.

4. Derivative Computation: Using the given equations, the derivatives E ′ and I ′ are
calculated.

5. Output: The derivatives are returned as a column vector.

Exercise 2: Writing the JACWC.m Function


The task is to write a MATLAB function, JACWC.m, that calculates the Jacobian matrix
of the Wilson-Cowan model equations using finite differences. Specifically, the function
calculates partial derivatives numerically based on the method described in Tutorial 1,
which uses small perturbations h in each variable to approximate the derivatives.

MATLAB Implementation
Below is the MATLAB code for JACWC.m:
1 % % Exercise 2
2 % I take the function from the Tutorial Exercises :
3 function A = JACWC (t , X , h )
4 n = length ( X ) ; % Dimension of the state vector
5 A = zeros (n , n ) ; % Initialize the Jacobian matrix
6
7 for i = 1: n
8 v = zeros (n , 1) ; % Perturbation vector
9 v ( i ) = 1; % Perturb one variable at a time
10
11 % Evaluate the perturbed values of the function
12 X_plus = WC (t , X + v * h ) ;
13 X_minus = WC (t , X - v * h ) ;
14

15 % Compute the numerical derivative ( finite differences )


16 A (: , i ) = ( X_plus - X_minus ) / (2 * h ) ;

4
17 end
18 end
19
20 % Example usage :
21 X = [ eq_points (1 , 1) , eq_points (1 , 2) ]; % Example equilibrium point
22 F = [ E_prima ( X (1) , X (2) ) ; I_prima ( X (1) , X (2) ) ]; % Evaluate derivatives
23 h = 1e -3; % Small perturbation
24 t = 0; % Current time
25
26 % Compute Jacobian using JACWC
27 A = JACWC (t , F , h ) ;
28 disp ( A )
29
30 % Analytical Jacobian ( for verification )
31 Jac = [ dEdE ( X (1) , X (2) ) , dEdI ( X (1) , X (2) ) ;
32 dIdE ( X (1) , X (2) ) , dIdI ( X (1) , X (2) ) ];
33 disp ( Jac )

Listing 2: MATLAB Code for JACWC.m

Explanation of the Code


1. Function Inputs and Outputs:

• Inputs:
– t: Time (it is actually not used in this function because it is done at a
given time).
– X: A vector containing the current values of E and I, it has the E at the
first spot of the vector and I at the second.
– h: A small perturbation value that should be in the order of 10( − 3) or
lower.
• Output:
– A: The Jacobian matrix, where each entry is a numerical derivative.

2. Finite Difference Approximation:

• The Jacobian matrix is has in its positions all of the possible partial derivatives.
∂f
For a function f , the derivative ∂x i
is approximated as:

∂f f (X + hv) − f (X − hv)
≈ ,
∂xi 2h
where v is a perturbation vector with a 1 in the i-th position and 0 elsewhere.

3. Iterative Calculation:

• The for-loop iterates through each variable in X (that in our case are E and I),
computing the derivative with respect to that variable while having the others
constant.

4. Example Usage:

5
• The Jacobian is calculated at a sample equilibrium point, X = [eq points(1,1),
eq points(1,2)].
• Then, the Jacobian is compared to an analytical Jacobian matrix for verifica-
tion.

Exercise 3: Analytical and Numerical Computation of


Nullclines
The Wilson-Cowan model involves two related equations between them for excitatory (E)
and inhibitory (I) populations. The nullclines are defined as the lines where E ′ = 0 or
I ′ = 0, representing points where each population’s evolution remains constant.

Analytical Computation of Nullclines


To find the nullclines analytically, we imposed the conditions E ′ = 0 and I ′ = 0 and
solved for I and E, respectively:
 
1
ln E +exp(−b δ ) − 1 /be + c1 E + P − δe
1−E e e
IE (E) = ,
c2
 
1
− ln I +exp(−b δ ) − 1 /bi + c4 I − Q + δi
1−I i i
EI (I) = .
c3
E I
These equations have special restrictions. Specially, the terms 1−E and 1−I inside the
logarithms become problematic when E > 0.5 or I > 0.5, as they produce negative
numbers inside the logarithms, resulting in imaginary values. For this reason, we only
consider the interval 0 < E, I < 0.5.

Code for Analytical Nullclines: Below is the MATLAB code for plotting the null-
clines analytically:
1 E = 0.01:0.01:0.49;
2 I = 0.01:0.01:0.5;
3 exp_e = 1 / (1 + exp ( b_e * delta_e ) ) ;
4 exp_i = 1 / (1 + exp ( b_i * delta_i ) ) ;
5
6 I_E = @ ( E ) ( log (1 ./ ( E ./(1 - E ) + exp_e ) - 1) ./ b_e + c_1 * E + P - delta_e ) /
c_2 ;
7 E_I = @ ( I ) ( - log (1 ./ ( I ./(1 - I ) + exp_i ) - 1) ./ b_i + c_4 * I - Q + delta_i )
/ c_3 ;
8

9 I_e = I_E ( E ) ;
10 E_i = E_I ( I ) ;
11
12 figure (1) ;
13 plot (E , I_e , ’b - ’ , ’ LineWidth ’ , 2) ; % Excitatory Nullcline
14 hold on ;
15 plot ( E_i , I , ’r - - ’ , ’ LineWidth ’ , 2) ; % Inhibitory Nullcline
16
17 grid on ;

6
18 xlabel ( ’ Excitatory Activity ( E ) ’ , ’ FontSize ’ , 12) ;
19 ylabel ( ’ Inhibitory Activity ( I ) ’ , ’ FontSize ’ , 12) ;
20 title ( ’ Nullclines of the Wilson - Cowan Model ’ , ’ FontSize ’ , 14) ;
21 legend ( ’ Excitatory Nullcline ’ , ’ Inhibitory Nullcline ’ , ’ Location ’ , ’
southeast ’) ;
22 hold off ;

Listing 3: Analytical Nullclines

Numerical Computation of Nullclines


To solve the problems of the analytical method and calculate nullclines also in the range
of 0 < E, I < 0.5, we used the secant method for root finding. For each fixed value of E,
we searched the related I that satisfies E ′ = 0, and the other way around for I ′ .

Overall View:
1. The secant method detects roots by finding changes in the sign of E ′ or I ′ .

2. Equilibrium points are located where the excitatory and inhibitory nullclines inter-
sect.

How the Secant Method Works in the this case:


1. Start of the initial conditions:

• The arrays E array and I array are defined as discrete points inside the range
of E and I.
• The tolerance tol is set to have numerical precision.

2. Root Detection:

• For each fixed E = Earray (e), the function E prima(E, I) is evaluated over all
I values in I array.
• Changes in sign between one calculation and the net one of E prima are de-
tected using the condition:

yE(2:end) .* yE(1:end-1) < 0.

• Similarly, for each fixed E = Earray (e), changes in sign of I prima(E, I) are
detected.

3. Secant Model for E ′ :

• For each detected root in E ′ , the initial extremes (x1 and x2 ) are set based on
the indices of iE.
• The secant formula is applied repeatedly to approximate the root:
f (x2 ) · (x2 − x1 )
x 3 = x2 − ,
f (x2 ) − f (x1 )
where f (x) is E prima(E, I).

7
• The new bounds are updated based on the sign of f (x3 ):
– If f (x1 ) · f (x3 ) < 0, the root is inside [x1 , x3 ], so x2 ← x3 .
– If not so, the root is in between [x3 , x2 ], so x1 ← x3 .
• Iteration continues until |f (x3 )| < tol.

4. Secant Iteration for I ′ :

• The process is repeated for I prima(E, I) with a fixed E, using the same
secant method.

5. Nullclines Storage (Lines 28–44):

• The calculated roots for E ′ and I ′ are saved in arrays E zero and I zero,
respectively.

6. Equilibrium Points (Lines 48–52):

• The arrays E zero and I zero are compared to find intersection points, that
are the actual equilibrium points.
• These are stored in the array possible eq points.

Code for Numerical Nullclines: Below is the MATLAB code used to calculate the
nullclines numerically and find the equilibrium points:
1 tol = 1e -10;
2 E_array = 0. 00 1: 0.0 01 :0 .9 99 ;
3 I_array = 0. 00 1: 0.0 01 :0 .9 99 ;
4 E_zero = [];
5 I_zero = [];
6 po ss ib le _e q_ po in ts = [];
7
8 for e = 1: length ( E_array )
9 yE = arrayfun ( @ ( I ) E_prima ( E_array ( e ) , I ) , I_array ) ;
10 iE = find ( yE (2: end ) .* yE (1: end -1) < 0) ;
11
12 yI = arrayfun ( @ ( I ) I_prima ( E_array ( e ) , I ) , I_array ) ;
13 iI = find ( yI (2: end ) .* yI (1: end -1) < 0) ;
14
15 if ~ isempty ( iE )
16 E = E_array ( e ) ;
17 x1 = I_array ( iE ) ;
18 x2 = I_array ( iE + 1) ;
19 x3 = x2 - E_prima (E , x2 ) * ( x2 - x1 ) /( E_prima (E , x2 ) - E_prima (E
, x1 ) ) ;
20 while abs ( E_prima (E , x3 ) ) >= tol
21 x3 = x2 - E_prima (E , x2 ) * ( x2 - x1 ) /( E_prima (E , x2 ) -
E_prima (E , x1 ) ) ;
22 if E_prima (E , x1 ) * E_prima (E , x3 ) < 0
23 x2 = x3 ;
24 else
25 x1 = x3 ;
26 end
27 end
28 E_zero = [ E_zero ; E_array ( e ) , x3 ];
29 end

8
30
31 if ~ isempty ( iI )
32 E = E_array ( e ) ;
33 x1 = I_array ( iI ) ;
34 x2 = I_array ( iI + 1) ;
35 x3 = x2 - I_prima (E , x2 ) * ( x2 - x1 ) /( I_prima (E , x2 ) - I_prima (E
, x1 ) ) ;
36 while abs ( I_prima (E , x3 ) ) >= tol
37 x3 = x2 - I_prima (E , x2 ) * ( x2 - x1 ) /( I_prima (E , x2 ) -
I_prima (E , x1 ) ) ;
38 if I_prima (E , x1 ) * I_prima (E , x3 ) < 0
39 x2 = x3 ;
40 else
41 x1 = x3 ;
42 end
43 end
44 I_zero = [ I_zero ; E_array ( e ) , x3 ];
45 end
46 end
47
48 for i = 2: length ( E_zero (: , 1) )
49 if ( E_zero (i , 2) - I_zero (i , 2) ) * ( E_zero (i -1 , 2) - I_zero (i -1 , 2) )
< 0
50 po ss ib le _e q_ po in ts = [ p oss ib le _e q_ po in ts ; E_zero (i , 1) E_zero (i ,
2) ];
51 end
52 end
53
54 figure (2) ;
55 plot ( E_zero (: , 1) , E_zero (: , 2) , ’b - ’ , ’ LineWidth ’ , 2 , ’ DisplayName ’ , ’
Excitatory Nullcline ’) ;
56 hold on ;
57 plot ( I_zero (: , 1) , I_zero (: , 2) , ’r - ’ , ’ LineWidth ’ , 2 , ’ DisplayName ’ , ’
Inhibitory Nullcline ’) ;
58 scatter ( po ss ib le_ eq _p oi nt s (: , 1) , po ss ib le _eq _p oi nt s (: , 2) , 50 , ’k ’ , ’
DisplayName ’ , ’ Equilibria ’) ;
59 xlabel ( ’ Excitatory Activity ( E ) ’ , ’ FontSize ’ , 12) ;
60 ylabel ( ’ Inhibitory Activity ( I ) ’ , ’ FontSize ’ , 12) ;
61 title ( ’ Numerical Solution of Wilson - Cowan Model Nullclines ’ , ’ FontSize ’ ,
14) ;
62 legend ( ’ show ’ , ’ Location ’ , ’ best ’) ;
63 grid on ;
64 hold off ;

Listing 4: Numerical Nullclines

Comparison of Analytical and Numerical Approaches


• Analytical Method: Gives explicit formulas but is restricted to 0 < E, I < 0.5
due to logarithmic limits.

• Numerical Method: Uses the secant method to find roots and works for the full
range 0 < E, I < 0.5.

• Equilibrium Points: Calculated numerically as the intersection of the nullclines,


defined in the change of sign of the substraction of functions.

9
Figures

Figure 1: Analytical Nullclines of the Wilson-Cowan Model.

Figure 2: Numerical Nullclines with Equilibrium Points.

10
Exercise 4: Equilibrium Points
The aim of this exercise is to numerically find the equilibrium points of the Wilson-Cowan
model for the values of the parameters provided. Equilibrium points happen when the
derivatives of the excitatory and inhibitory variables, E ′ (E, I) and I ′ (E, I), are both zero:

E ′ (E, I) = 0 and I ′ (E, I) = 0.

We use Newton’s method in two dimensions to find these points. The method iteratively
solves for roots of the vector function:
 ′ 
E (E, I)
F(E, I) = ′ ,
I (E, I)

by linearizing the system using the Jacobian matrix and solving for corrections.

Wilson-Cowan Model Functions


The Wilson-Cowan equations for E ′ (E, I) and I ′ (E, I) are defined as:

E ′ (E, I) = −E + (1 − E)Se (E, I),

I ′ (E, I) = −I + (1 − I)Si (E, I),


where the sigmoid functions Se (E, I) and Si (E, I) are:
1 1
Se (E, I) = − ,
1 + exp(−be (c1 E − c2 I + P − δe )) 1 + exp(be δe )
1 1
Si (E, I) = − .
1 + exp(−bi (c3 E − c4 I + Q − δi )) 1 + exp(bi δi )

Jacobian Matrix
The Jacobian matrix is defined as:
 ∂E ′ ∂E ′

J= ∂E ∂I .
∂I ′ ∂I ′
∂E ∂I

Each entry of the Jacobian matrix is computed using the derivatives of Se (E, I) and
Si (E, I).

∂E ′ ∂Se ∂E ′ ∂Se
= −1 − Se (E, I) + (1 − E) , = (1 − E) ,
∂E ∂E ∂I ∂I
∂I ′ ∂Si ∂I ′ ∂Si
= (1 − I) , = −1 − Si (E, I) + (1 − I) .
∂E ∂E ∂I ∂I
The derivatives of Se (E, I) and Si (E, I) are:

∂Se ∂Se
= be Se (E, I)(1 − Se (E, I))c1 , = −be Se (E, I)(1 − Se (E, I))c2 ,
∂E ∂I
∂Si ∂Si
= bi Si (E, I)(1 − Si (E, I))c3 , = −bi Si (E, I)(1 − Si (E, I))c4 .
∂E ∂I

11
MATLAB Code
Below is the MATLAB code used to implement Newton’s method in two dimensions and
find the equilibrium points:
1 tol = 1e -6;
2
3 % Define the sigmoid functions
4 S_e = @ (E , I ) 1/(1+ exp ( - b_e *( c_1 * E - c_2 * I + P - delta_e ) ) ) - 1/(1+ exp (
b_e * delta_e ) ) ;
5 S_i = @ (E , I ) 1/(1+ exp ( - b_i *( c_3 * E - c_4 * I + Q - delta_i ) ) ) - 1/(1+ exp (
b_i * delta_i ) ) ;
6
7 % Define the derivatives
8 E_prima = @ (E , I ) -E + (1 - E ) * S_e (E , I ) ;
9 I_prima = @ (E , I ) -I + (1 - I ) * S_i (E , I ) ;
10
11 dSedE = @ (E , I) b_e * S_e (E , I) * (1 - S_e (E , I)) * c_1 ;
12 dSedI = @ (E , I) b_e * S_e (E , I) * (1 - S_e (E , I)) * - c_2 ;
13 dSidE = @ (E , I) b_i * S_i (E , I) * (1 - S_i (E , I)) * c_3 ;
14 dSidI = @ (E , I) b_i * S_i (E , I) * (1 - S_i (E , I)) * - c_4 ;
15
16 dEdE = @ (E , I) -1 - S_e (E , I ) + (1 - E ) * dSedE (E , I ) ;
17 dEdI = @ (E , I) (1 - E ) * dSedI (E , I ) ;
18 dIdE = @ (E , I) (1 - I ) * dSidE (E , I ) ;
19 dIdI = @ (E , I) ( -1 - S_i (E , I ) + (1 - I ) * dSidI (E , I ) ) ;
20

21 % Initialize equilibrium points


22 eq_points = [];
23
24 for i = 1: size ( po ss ib le _eq _p oi nt s )
25
26 X = po ss ib le _e q_ po in ts (i , :) ;
27 count = 0;
28
29 while true
30 % Compute function and Jacobian
31 F = [ E_prima ( X (1) , X (2) ) ; I_prima ( X (1) , X (2) ) ];
32 Jac = [ dEdE ( X (1) , X (2) ) , dEdI ( X (1) , X (2) ) ;
33 dIdE ( X (1) , X (2) ) , dIdI ( X (1) , X (2) ) ];
34
35 % Solve linear system for correction
36 h = - Jac \ F ;
37 X = X + h;
38
39 % Check convergence
40 if norm ( F ) < tol
41 is_new_point = true ;
42 if length ( eq_points ) > 0
43 for k = 1: size ( eq_points , 1)
44 if norm ([ X (1) X (2) ] - eq_points (k , :) ) < tol
45 is_new_point = false ;
46 break ;
47 end
48 end
49 end
50 if is_new_point
51 eq_points = [ eq_points ; [ X (1) X (2) ]];
52 end

12
53 break ;
54 end
55 if count > 15000
56 break ;
57 end
58 count = count + 1;
59 end
60 end
61
62 disp ( eq_points )

Listing 5: Finding Equilibrium Points

Results
The equilibrium points found are:
 
0.1541 0.1921
0.4727 0.4997 .
0.4346 0.4995

Conclusion
This implementation of Newton’s method calculates correctly the equilibrium points of the
Wilson-Cowan model. The nature of the mathematical computation of Newton’s method
allows to have rapid and accurate equilibrium points when initial guesses are close to the
actual equilibrium points.

Exercise 5: Linearization and Classification of Fixed


Points
In this exercise, we analyze the stability of the fixed points of the Wilson-Cowan model
with the linearization and analysis of the eigenvalues around each fixed point. The aim
is to calculate the Jacobian matrix at each fixed point and classify the fixed points based
on the eigenvalues of the Jacobian.

Linearization
The linearization of the system around a fixed point (E0 , I0 ) is given by:

x′ = J(E0 , I0 )x,
 
E
where x = and J(E0 , I0 ) is the Jacobian matrix evaluated at (E0 , I0 ). The entries of
I
the Jacobian matrix J(E, I) are:
 ∂E ′ ∂E ′ 
J(E, I) = ∂I∂E′ ∂I
∂I ′ .
∂E ∂I

These derivatives are derived as in Exercise 4 and implemented in the MATLAB code
below.

13
Eigenvalues and Classification
The stability and classification of a fixed point are determined by the eigenvalues λ1 and
λ2 of the Jacobian matrix. The classifications are as follows:
• Stable Node: Both eigenvalues are real and negative.

• Unstable Node: Both eigenvalues are real and positive.

• Saddle Point: Eigenvalues have opposite signs.

• Stable Spiral Focus: Eigenvalues are complex with negative real parts.

• Unstable Spiral Focus: Eigenvalues are complex with positive real parts.

• Center: Eigenvalues are purely imaginary.

MATLAB Code
The following MATLAB code computes the Jacobian matrix for each fixed point, calcu-
lates the eigenvalues, classifies the fixed point, and prints the results:
1 % % Exercise 5
2
3 eig_vals = [];
4 for i = 1: length ( eq_points )
5 % Extract fixed point coordinates
6 X = [ eq_points (i , 1) ; eq_points (i , 2) ];
7
8 % Compute Jacobian matrix
9 Jac = [ dEdE ( X (1) , X (2) ) , dEdI ( X (1) , X (2) ) ;
10 dIdE ( X (1) , X (2) ) , dIdI ( X (1) , X (2) ) ];
11 a = Jac (1 , 1) ;
12 b = Jac (1 , 2) ;
13 c = Jac (2 , 1) ;
14 d = Jac (2 , 2) ;
15

16 % Compute eigenvalues
17 eigenvalue_1 = (( a + d ) + sqrt (( a + d ) ^2 - 4*( a * d - b * c ) ) ) / 2;
18 eigenvalue_2 = (( a + d ) - sqrt (( a + d ) ^2 - 4*( a * d - b * c ) ) ) / 2;
19
20 eig_vals = [ eig_vals ; [ eigenvalue_1 , eigenvalue_2 ]];
21

22 % Classify fixed point


23 if imag ( eigenvalue_1 ) == 0 && imag ( eigenvalue_2 ) == 0
24 if real ( eigenvalue_1 ) < 0 && real ( eigenvalue_2 ) < 0
25 fprintf ( ’ The fixed point [% f , % f ] is a Stable Node .\ n ’ , X (1)
, X (2) )
26 elseif real ( eigenvalue_1 ) > 0 && real ( eigenvalue_2 ) > 0
27 fprintf ( ’ The fixed point [% f , % f ] is an Unstable Node .\ n ’ , X
(1) , X (2) )
28 else
29 fprintf ( ’ The fixed point [% f , % f ] is a Saddle Point .\ n ’ , X
(1) , X (2) )
30 end
31
32 elseif imag ( eigenvalue_1 ) ~= 0
33 if real ( eigenvalue_1 ) < 0 && real ( eigenvalue_2 ) < 0

14
34 fprintf ( ’ The fixed point [% f , % f ] is a Stable Spiral Focus .\
n ’ , X (1) , X (2) )
35 elseif real ( eigenvalue_1 ) > 0 && real ( eigenvalue_2 ) > 0
36 fprintf ( ’ The fixed point [% f , % f ] is an Unstable Spiral
Focus .\ n ’ , X (1) , X (2) )
37 else
38 fprintf ( ’ The fixed point [% f , % f ] is a Center .\ n ’ , X (1) , X
(2) )
39 end
40 end
41
42 end

Listing 6: Linearization and Classification of Fixed Points

Results and Classification


Using the eigenvalues computed for the equilibrium points from Exercise 4:
 
0.1541 0.1921
Equilibrium Points: 0.4727 0.4997 ,
0.4346 0.4995

the classifications of the fixed points are:

• Fixed Point [0.1541, 0.1921]: Unstable Spiral Focus.

• Fixed Point [0.4727, 0.4997]: Stable Node.

• Fixed Point [0.4346, 0.4995]: Saddle Point.

Conclusion
The linearization and eigenvalue analysis correctly classify the fixed points and give in-
formation about their dynamics. These classifications help to understand the stability
properties of the system near each fixed point.

Exercise 6: Global Phase Portrait


In this exercise, we are tasked with creating a global phase portrait for the Wilson-Cowan
model inside the unit square [0 ≤ E, I ≤ 1]. This includes plotting the nullclines, the
equilibria, and a few solutions (orbits) calculated by doing the evolutiom of the system over
time using the Euler-Forward method. Moreover, for the equilibria with real eigenvalues,
we will plot the lines given by:
X(s) = x0 + sv,
where v is an eigenvector associated with the fixed point x0 .

15
Simulating the Orbits
To simulate the orbits, we use the Euler-Forward method, a simple numerical technique
for solving ordinary differential equations. Given a differential equation of the form:
dx
= f (x),
dt
the Euler-Forward method updates the state of the system as:

xn+1 = xn + f (xn )∆t.

Here, ∆t is the time step. For this exercise, the time step is set to ∆t = 0.01 and the total
simulation time is tend = 10 units. The state variables E (excitatory) and I (inhibitory)
are updated at each step based on their corresponding derivatives E ′ and I ′ .

Initial Conditions
We use 10 different initial conditions for the simulation:
{(0.2, 0.2), (0.8, 0.2), (0.2, 0.8), (0.8, 0.8), (0.5, 0.5),
(0.1, 0.9), (0.9, 0.1), (0.4, 0.6), (0.6, 0.4), (0.5, 0.3),
Initial Conditions =
(0.3, 0.5), (0.2, 0.1), (0.1, 0.2), (0.9, 0.5), (0.5, 0.9),
(0.7, 0.8), (0.8, 0.7)}.

For each initial condition, we simulate the model for 1000 time steps (tsteps = 1000).

MATLAB Code
The following MATLAB code implements the Euler-Forward method, simulates the orbits
for the specified initial conditions, and plots the phase portrait.
1 % Parameters
2 dt = 0.01; % Time step for Euler - Forward method
3 t_end = 10; % Simulation duration
4 t_steps = t_end / dt ;
5
6 % Simulate Orbits
7 in it ia l_ co nd it io ns = [0.2 , 0.2; 0.8 , 0.2; 0.2 , 0.8; 0.8 , 0.8;
8 0.5 , 0.5; 0.1 , 0.9; 0.9 , 0.1; 0.4 , 0.6;
9 0.6 , 0.4; 0.5 , 0.3; 0.3 , 0.5; 0.2 , 0.1; 0.1 , 0.2;
0.9 0.5; 0.5 0.9; 0.7 0.8; 0.8 0.7];
10 orbits = cell ( size ( initial_conditions , 1) , 1) ;
11 for i = 1: size ( initial_conditions , 1)
12 E = zeros (1 , t_steps ) ;
13 I = zeros (1 , t_steps ) ;
14 E (1) = in it ia l_ co nd it io ns (i , 1) ;
15 I (1) = in it ia l_ co nd it io ns (i , 2) ;
16 for t = 1: t_steps -1
17 dE = E_prima ( E ( t ) , I ( t ) ) ;
18 dI = I_prima ( E ( t ) , I ( t ) ) ;
19 E ( t +1) = E ( t ) + dE * dt ;
20 I ( t +1) = I ( t ) + dI * dt ;
21 end
22 orbits { i } = [ E ; I ];

16
23 end
24
25 E = 0.01:0.01:0.49;
26 I = 0.01:0.01:0.5;
27 % Plotting
28 figure ;
29 hold on ;
30 plot ( E_zero (: , 1) , E_zero (: , 2) , ’ DisplayName ’ , ’ Excitatory Nullcline ’)
31 hold on
32 plot ( I_zero (: , 1) , I_zero (: , 2) , ’ DisplayName ’ , ’ Inhibitory Nullcline ’)
33 hold on
34

35 % Plot Equilibria
36 scatter ( eq_points (: ,1) , eq_points (: ,2) , 50 , ’k ’ , ’ DisplayName ’ , ’
Equilibria ’) ;
37
38 % Plot Eigenvector Lines
39 quiver ( E_grid , I_grid , E_prime , I_prime , DisplayName = ’ Derivatives Grid ’)
;
40
41 % Plot Orbits
42 for i = 1: length ( orbits )
43 orbit = orbits { i };
44 plot ( orbit (1 ,:) , orbit (2 ,:) , ’k ’ , ’ HandleVisibility ’ , ’ off ’) ;
45 end
46
47 % Final touches
48 xlabel ( ’E ’) ;
49 ylabel ( ’I ’) ;
50 xlim ([0 1]) ;
51 ylim ([0 1]) ;
52 title ( ’ Global Phase Portrait ’) ;
53 legend show ;
54 grid on ;

Listing 7: Global Phase Portrait

Description of the Figure


The output plot, named final plot.jpg, gives a global phase portrait for the Wilson-
Cowan model at the limits of 0 ≤ E, I ≤ 1. The following elements are displayed:

• Nullclines: The nullclines of the excitatory and inhibitory populations are plotted,
showing where the derivatives E ′ and I ′ are zero. The range of these curves are
in between 0 and 0.5 because it is only plotted the values where the result of the
nullcline is non-imaginary.

• Equilibria: The fixed points found in Exercise 4 are shown as black circles. These
points are the equilibrium points of the system.

• Eigenvector Lines: For fixed points with real eigenvalues, the lines representing
the eigenvectors are drawn. These lines show the directions of the local phase space
near each equilibrium.

17
• Orbits: The orbits are plotted for the various initial conditions shown before. These
trajectories represent the time evolution of the system starting from different initial
points.

Figure 3: Global Phase Portrait for the Wilson-Cowan Model

18

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy