摘要:
8.4 import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt def system(z,t): x,y=z dxdt=-x3-y dydt=x-y3 return [dxdt,dyd 阅读全文
摘要:
7.3 import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicod 阅读全文
摘要:
6.1(1) import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() nodes = ['v1', 'v2', 'v3', 'v4', 'v5', 'v6'] G.add_nodes_from(nodes) edges 阅读全文
摘要:
2.1 import math import pylab as plt import numpy as np x = np.linspace(-10, 10, 100) y1 = np.cosh(x) y2 = np.sinh(x) y3 = math.e**x/2 plt.plot(x, y1, 阅读全文
摘要:
4.3 import matplotlib.pyplot as plt import numpy as np import cvxpy as cp x=cp.Variable(6,pos=True) obj=cp.Minimize(x[5]) a1=np.array([0.025, 0.015, 0 阅读全文
摘要:
3.2 import sympy as sp def solve_difference_equation(): n = sp.symbols('n', integer=True) x = sp.Function('x') eq = sp.Eq(x(n + 2) - x(n + 1) - 2 * x( 阅读全文
摘要:
习题5.4 import numpy as np from scipy.optimize import minimize def objective_function(x): return np.sum(np.sqrt(x)) def linear_constraint(x): weights = 阅读全文