摘要: 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 阅读全文
posted @ 2024-11-17 16:11 cjl110 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-11-16 22:36 cjl110 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-10-27 16:57 cjl110 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 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, 阅读全文
posted @ 2024-10-24 23:53 cjl110 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-10-22 16:57 cjl110 阅读(3) 评论(0) 推荐(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( 阅读全文
posted @ 2024-10-22 16:37 cjl110 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 习题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 = 阅读全文
posted @ 2024-10-14 21:50 cjl110 阅读(9) 评论(0) 推荐(0) 编辑