Hi everyone. Here are the help notes to clarify some points of lab-8.
#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.
Nprime(N) = 0.2 * N * (1 - N/200) * (N/100 - 1) #Let us see what diff function does: print(diff(Nprime))
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
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)
#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))
#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)
#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")
my_eqn(N) = 0.2 * N * (1 - N/200) * (N/100 - 1); eq_pts = [0, 100, 200] stability(my_eqn, eq_pts)