Форум сайта python.su
Суть следующей задачи заключается в построении графиков асимптотической и логистической функции.
Для асимптотической функции (функцию не смог подобрать, но хотелось бы привести примеры):
import numpy as np import matplotlib.pyplot as plt import mpl_toolkits.mplot3d.axes3d as p3 import matplotlib.animation as animation from scipy.integrate import odeint from scipy.optimize import curve_fit def show(fun, arg): print(type(fun), ':', fun) print('arg =',arg,'=> fun(arg) =', fun(arg)) def f() t = np.linspace( 0, 20, 50) # vector of time y0 = [100, 300] # start value w = odeint(f, y0, t) # solve eq. y1 = w[:,0] y2 = w[:,1] fig = plt.figure(facecolor='white') #plt.plot(t, y1, '-o', t, y2, '-o', linewidth=2) plt.plot(y1, y2, '-o', linewidth=2) plt.ylabel("z") plt.xlabel("t") plt.grid(True) plt.show() # display # T=2pi/sqrt(ab) U=b/gamma2 V=a/gamma1 # U= 1/T int (ot 0 do T) U(t)dt # V= 1/T int (ot 0 do T) V(t)dt # U0=199 V0=200 U=50/500 U_fig = range(50,500,25) V_fig = range(50,500,25) for u_t in U_fig: for v_t in V_fig: F=[u_t, v_t] #X = open('test.txt', 'r') b = np.array
import numpy as np import math import matplotlib.pyplot as plt import mpl_toolkits.mplot3d.axes3d as p3 import matplotlib.animation as animation from scipy.integrate import odeint def show(fun, arg): print(type(fun), ':', fun) print('arg =',arg,'=> fun(arg) =', fun(arg)) x = np.linspace(-5, 2, 100) def P(x,y): return 1/(1+math.pow(math.e, y)) t = np.linspace( 0, 20, 100) # vector of time x0 = [10, 300] # start value w = odeint(P, x0, t) # solve eq. x1 = w[:,0] x2 = w[:,1] fig = plt.figure(facecolor='white') #plt.plot(t, y1, '-o', t, y2, '-o', linewidth=2) plt.plot(x1, x2, '-o', linewidth=2) plt.ylabel("z") plt.xlabel("t") plt.grid(True) plt.show() # display # T=2pi/sqrt(ab) U=b/gamma2 V=a/gamma1 # U= 1/T int (ot 0 do T) U(t)dt # V= 1/T int (ot 0 do T) V(t)dt # U0=199 V0=200 U=50/500 U_fig = range(50,500,25) V_fig = range(50,500,25) for u_t in U_fig: for v_t in V_fig: F=[u_t, v_t]
Офлайн