为什么 sympy 不简化导数的傅立叶变换?

Why doesn't sympy simplify the Fourier Transform of a derivative?

我们知道一个导数的傅里叶变换是

Fourier transform of a derivative

其中 k 是傅里叶变量。 Explanation here

我的问题是,为什么 sympy 不使用这些知识?例如:

from sympy import Function, symbols, fourier_transform, Derivative

f = Function('f')
x, k= symbols('x, k')

G = fourier_transform(Derivative(f(x), x, x) + f(x), x, k)
print(G)

这会打印

FourierTransform(f(x), x, k) + FourierTransform(Derivative(f(x), x, x), x, k)

但我希望它能打印(最多 2 pi i 的某些因数)

FourierTransform(f(x), x, k) + k**2 FourierTransform(f(x), x, k)

有没有办法告诉 sympy 无需进行此简化,因为我希望 f(x) -> 0 随着 x 趋于无穷大?

如果不是,最干净的替代方法是什么?

Sympy 不这样做的简单原因是 it's not implemented yet。作为目前的解决方法,您可以手动将导数的 FourierTransform 替换为乘法:

from sympy import Wild, FourierTransform, Derivative
a, b, c = symbols('a b c', cls=Wild)
G.replace(
    FourierTransform(Derivative(a, b, b), b, c),
    c**2 * FourierTransform(a, b, c)
)

据我所知,Sympy 不提供匹配任意数量参数的模式,因此您不能拥有匹配 Derivative(f(x), x)Derivative(f(x), x, x)Derivative(f(x), x, x, x),等等。你可以通过使用 replace() 的函数-函数形式来解决这个问题,但是如果你知道你正在处理的导数的顺序,那么明确地输入那么多 b 可能会更简单,正如我在示例中所做的那样。