CoCalc Public FilesTA Sandbox / Ganesha_Sandbox / Classifying Equilibria_ HelpNotes.ipynbOpen with one click!
Author: Ganesha Durbha
Views : 110
Compute Environment: Ubuntu 20.04 (Default)

Hi everyone. Here are the help notes to clarify some points of lab-8.

In [ ]:
#FORGET ABOUT THE subs function. We will not be using it for this lab. #Instead, we shall find the expression for the derivative (using the diff function) #However, we shall store that expression as a mathematical function of some dummy variable, say P. Let's see.
In [1]:
Nprime(N) = 0.2 * N * (1 - N/200) * (N/100 - 1) #Let us see what diff function does: print(diff(Nprime))
N |--> -0.0000100000000000000*(N - 100)*(N - 200) - 0.0000100000000000000*(N - 100)*N - 0.0000100000000000000*(N - 200)*N

We see that the diff function simply differentiated Nprime and gave an expression. I now want to store this expression as a mathematical function of some dummy variable,P

In [3]:
derNprime(P) = diff(Nprime(P))#THE MOST IMPORTANT LINE. Converts the EXPRESSION FOR THE DERIVATIVE OF NPRIME INTO A MATHEMATICAL FUNCTION named derNprime. print(derNprime)
P |--> -0.0000100000000000000*(P - 100)*(P - 200) - 0.0000100000000000000*(P - 100)*P - 0.0000100000000000000*(P - 200)*P
In [4]:
#derNprime is the mathematical function that represents the derivative of Nprime. #Since derNprime is a mathematical function, I can compute it for a specific input simply by: print(derNprime(100))
0.100000000000000
In [5]:
#13. We can therefore do exercise 13 as: Nprime(N) = 0.2 * N * (1 - N/200) * (N/100 - 1) derNprime(P) = diff(Nprime(P)) print(derNprime)
P |--> -0.0000100000000000000*(P - 100)*(P - 200) - 0.0000100000000000000*(P - 100)*P - 0.0000100000000000000*(P - 200)*P
In [12]:
#16. def stability (chng_eqn, eql_list): derXprime(P) = diff(chng_eqn(P)) #Converts the derivative of chng_eqn into a mathematical function named derXprime. for eq in eql_list: val = derXprime(eq) if val < 0: print("STABLE") elif val > 0: print("UNSTABLE") else: print("TEST FAILS")
In [13]:
my_eqn(N) = 0.2 * N * (1 - N/200) * (N/100 - 1); eq_pts = [0, 100, 200] stability(my_eqn, eq_pts)
STABLE UNSTABLE STABLE
In [ ]: