上一页 1 2 3 4 5 6 7 8 ··· 11 下一页
摘要: from scipy.optimize import least_squares import numpy as np a=np.loadtxt('data2_47.txt') x0=a[0]; y0=a[1]; d=a[2] fx=lambda x: np.sqrt((x0-x[0])**2+(y 阅读全文
posted @ 2024-10-15 20:13 方~~ 阅读(10) 评论(0) 推荐(0)
摘要: from scipy.integrate import quad def fun42(x, a, b): return a*x**2+b*x I1 = quad(fun42, 0, 1, args=(2, 1)) I2 = quad(fun42, 0, 1, args=(2, 10)) print( 阅读全文
posted @ 2024-10-15 20:12 方~~ 阅读(9) 评论(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-15 20:08 方~~ 阅读(20) 评论(0) 推荐(0)
摘要: def X(n): # 差分方程的解 return 2 * (-1)**(n + 1) n_values = [0, 1, 2, 3, 4, 5] for n in n_values: print(f"X({n}) = {X(n)}") print("学号:3008") 结果如下 阅读全文
posted @ 2024-10-15 20:07 方~~ 阅读(22) 评论(0) 推荐(0)
摘要: 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) # 假设我们有一些初始猜测 阅读全文
posted @ 2024-10-15 20:03 方~~ 阅读(12) 评论(0) 推荐(0)
摘要: import numpy as np from scipy.linalg import eig # 定义矩阵 A = np.array([[-1, 1, 0], [-4, 3, 0], [1, 0, 2]]) # 计算特征值和特征向量 eigenvalues, eigenvectors = eig( 阅读全文
posted @ 2024-10-15 20:02 方~~ 阅读(13) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2024-10-15 20:01 方~~ 阅读(10) 评论(0) 推荐(0)
摘要: 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, 阅读全文
posted @ 2024-10-15 20:01 方~~ 阅读(7) 评论(0) 推荐(0)
摘要: 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.solv 阅读全文
posted @ 2024-10-15 20:00 方~~ 阅读(11) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2024-10-15 19:59 方~~ 阅读(10) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 ··· 11 下一页