10 2024 档案

摘要:import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt a = pd.read_excel(r"ti6_7.xlsx") b = a.values s = list(b[ 阅读全文
posted @ 2024-10-27 14:28 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() G.add_nodes_from([1, 2, 3, 4, 5, 6]) edges = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 阅读全文
posted @ 2024-10-26 21:33 Tsuki* 阅读(9) 评论(0) 推荐(0) 编辑
摘要:import numpy as np distances = np.array([ [0, 2, 7, np.inf, np.inf, np.inf], [2, 0, 4, 6, 8, np.inf], [7, 4, 0, 1, 3, np.inf], [np.inf, 6, 1, 0, 1, 6] 阅读全文
posted @ 2024-10-26 20:49 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:initial_costs = [2.5, 2.6, 2.8, 3.1] salvage_values = [2.0, 1.6, 1.3, 1.1] maintenance_costs = [0.3, 0.8, 1.5, 2.0] dp = [[float('inf')] * 2 for _ in 阅读全文
posted @ 2024-10-22 17:29 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import heapq def prim(graph, start): num_nodes = len(graph) visited = [False] * num_nodes min_heap = [(0, start, -1)] mst_cost = 0 mst_edges = [] whil 阅读全文
posted @ 2024-10-22 16:58 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2024-10-22 16:31 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import numpy as np from scipy.sparse.linalg import eigs import pylab as plt w = np.array([[0, 1, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 0, 0], 阅读全文
posted @ 2024-10-22 16:20 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import sympy as sp def solve_difference_equation(): n = sp.symbols('n') x = sp.Function('x') eq = sp.Eq(x(n + 2) - x(n + 1) - 2 * x(n), 0) sol = sp.rs 阅读全文
posted @ 2024-10-22 16:13 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:from scipy.optimize import linprog c = [50, 0.2, 50, 0.2, 50, 0.2, 4, 4, 4] A = [ [1, 0, -1, 0, 0, 0, 0, 0, 0], [0, 1, 0, -1, 0, 0, 0, 0, 0], [0, 0, 1 阅读全文
posted @ 2024-10-21 22:04 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import numpy as np import cvxpy as cp n = 2 x = cp.Variable(n,integer = True) A1 = np.array([[0,5], [6,2], [1,1]]) b1 = np.array([15,24,5]) A2 = np.ar 阅读全文
posted @ 2024-10-21 21:51 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import numpy as np from scipy.optimize import least_squares def f(x): return (np.abs(x + 1) - np.abs(x - 1)) / 2 + np.sin(x) def g(x): return (np.abs( 阅读全文
posted @ 2024-10-21 21:16 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import numpy as np from scipy.optimize import fsolve def f(x): return (abs(x + 1) - abs(x - 1)) / 2 + np.sin(x) def g(x): return (abs(x + 3) - abs(x - 阅读全文
posted @ 2024-10-21 21:15 Tsuki* 阅读(2) 评论(0) 推荐(0) 编辑
摘要:import numpy as np matrix = np.array([[-1, 1, 0], [-4, 3, 0], [1, 0, 2]]) eigenvalues, eigenvectors = np.linalg.eig(matrix) print("特征值:", eigenvalues) 阅读全文
posted @ 2024-10-21 21:15 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:from sympy import symbols, pi, integrate, sqrt y = symbols('y') curve1 = y - sqrt(4*y - y2) curve2 = sqrt(4 - y) volume = pi * integrate((curve12 - cu 阅读全文
posted @ 2024-10-21 21:14 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import numpy as np A = np.zeros((1000, 1000)) np.fill_diagonal(A, 4) np.fill_diagonal(A[:, 1:], 1) np.fill_diagonal(A[1:, :], 1) b = np.arange(1, 1001 阅读全文
posted @ 2024-10-21 21:12 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:from sympy import symbols, Eq, solve x, y = symbols('x y') equations = (Eq(x**2 - y - x - 3, 0), Eq(x + 3*y - 2, 0)) symbolic_solution = solve(equatio 阅读全文
posted @ 2024-10-21 21:12 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import numpy as np A = np.array([[4, 2, -1], [3, -1, 2], [11, 3, 0]]) b = np.array([2, 10, 8]) x = np.linalg.lstsq(A, b) if np.linalg.matrix_rank(A) = 阅读全文
posted @ 2024-10-21 21:09 Tsuki* 阅读(2) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd import numpy as np x = np.arange(0, 101, 1) y = np.arange(0, 101, 1) z = np.random.randint(0, 1001, size=(101, 101)) df = pd.DataF 阅读全文
posted @ 2024-10-21 21:08 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import numpy as np import matplotlib.pyplot as plt a = 2 b = np.sqrt(10) c = np.sqrt(8) phi = np.arange(0, 2*np.pi+0.1, 0.1) theta = np.arange(-1, 1.1 阅读全文
posted @ 2024-10-21 21:07 Tsuki* 阅读(2) 评论(0) 推荐(0) 编辑
摘要:import numpy as np import matplotlib.pyplot as plt plt.rc('font', family='SimHei') plt.rc('axes', unicode_minus=False) k_values = [1, 2, 3, 4, 5, 6] x 阅读全文
posted @ 2024-10-21 21:04 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要:import numpy as np import matplotlib.pyplot as plt from scipy.integrate import quad def fun(t, x): return np.exp(-t) * (t ** (x - 1)) x = np.linspace( 阅读全文
posted @ 2024-10-21 21:02 Tsuki* 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import numpy as np import matplotlib.pyplot as plt k_values = [1, 2, 3, 4, 5, 6] x = np.linspace(-10, 10, 100) for k in k_values: y = k * x ** 2 + 2 * 阅读全文
posted @ 2024-10-21 20:59 Tsuki* 阅读(3) 评论(0) 推荐(0) 编辑
摘要: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, labe 阅读全文
posted @ 2024-10-21 20:57 Tsuki* 阅读(5) 评论(0) 推荐(0) 编辑
摘要:import numpy as np import math from scipy.optimize import minimize,Bounds def func(x): return sum(math.sqrt(x[i]) for i in range(100)) def con(x): ret 阅读全文
posted @ 2024-10-15 19:44 Tsuki* 阅读(2) 评论(0) 推荐(0) 编辑
摘要:import numpy as np from scipy.optimize import minimize def objective(x): return - (2 * x[0] + 3 * x[0]2 + 3 * x[1] + x[1]2 + x[2]) def con1(x): return 阅读全文
posted @ 2024-10-13 21:13 Tsuki* 阅读(5) 评论(0) 推荐(0) 编辑