摘要:
MAX_A = 15 MAX_B = 24 MAX_DEBUG = 5 products = [ {"name": "Ⅰ", "A_hours": 1, "B_hours": 6, "debug_hours": 1, "profit": 2}, # 假设产品Ⅰ至少使用1小时设备A {"name": 阅读全文
摘要:
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.055 阅读全文
摘要:
import numpy as np def f(x): return (abs(x + 1) - abs(x - 1)) / 2 + np.sin(x) def g(x): return (abs(x + 3) - abs(x - 3)) / 2 + np.cos(x) 假设我们有一些初始猜测值( 阅读全文
摘要:
import numpy as np from scipy.linalg import eig 定义矩阵 A = np.array([[-1, 1, 0], [-4, 3, 0], [1, 0, 2]]) 计算特征值和特征向量 eigenvalues, eigenvectors = eig(A) 打 阅读全文
摘要:
import numpy as np def f(x): return (abs(x + 1) - abs(x - 1)) / 2 + np.sin(x) def g(x): return (abs(x + 3) - abs(x - 3)) / 2 + np.cos(x) from scipy.op 阅读全文
摘要:
from scipy.integrate import quad import numpy as np 第一部分:抛物线旋转体(修正后) def V1_quad(y): return np.pi * (4*y - y**2) V1_corrected, _ = quad(V1_quad, 1, 3) 阅读全文
摘要:
import sympy as sp 定义变量 x, y = sp.symbols('x y') 定义方程组 equation1 = sp.Eq(x**2 - y - x, 3) equation2 = sp.Eq(x + 3*y, 2) 解方程组 solutions = sp.solve((equ 阅读全文
摘要:
import numpy as np 初始化系数矩阵A和常数项向量b n = 1000 A = np.zeros((n, n)) b = np.arange(1, n+1) 填充系数矩阵A for i in range(n): A[i, i] = 4 # 对角线元素为4 if i < n-1: A[ 阅读全文
摘要:
import numpy as np 定义系数矩阵A和常数项向量b A = np.array([[4, 2, -1], [3, -1, 2], [11, 3, 0]]) b = np.array([2, 10, 8]) 使用numpy的lstsq求解最小二乘解 x, residuals, rank, 阅读全文
摘要:
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D 模拟高程数据(假设数据已经过某种方式插值或生成) 这里我们创建一个简单的40x50网格,并填充随机高程值 x = np 阅读全文