我正在尝试使用SymPy来获取残留物,在这种情况下是余切函数.我有一个integrate()函数:
import sympy as sy
import numpy as np
def integrate(f, z, gamma, t, lower, upper, exact=True):
'''
Integrate f(z) along the contour gamma(t): [lower, upper] --> C
INPUTS:
f - A SymPy expression. Should represent a function from C to C.
z - A SymPy symbol. Should be the variable of f.
gamma - A SymPy expression. Should represent a function from [lower, upper] to C.
t - A SymPy symbol. Should be the variable of gamma.
lower - …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个简单的数值积分函数来说明蒙特卡罗积分在高维度中的好处.我想要这样的东西:
def quad_int(f, mins, maxs, numPoints=100):
'''
Use the naive (Riemann sum) method to numerically integrate f on a box
defined by the mins and maxs.
INPUTS:
f - A function handle. Should accept a 1-D NumPy array
as input.
mins - A 1-D NumPy array of the minimum bounds on integration.
maxs - A 1-D NumPy array of the maximum bounds on integration.
numPoints - An integer specifying the number of points to sample in
the Riemann-sum method. Defaults …Run Code Online (Sandbox Code Playgroud)