Come out. more than the value of the transform fourier sympy

Asked 1 years ago, Updated 1 years ago, 61 views


from sympy import fourier_transform, exp,symbols
from sympy.abc import x, k

a=fourier_transform(exp(-x**2), x, k)

s=symbols('s')
Ori=(s)*exp(-(x**2)/(s**2))

FT=fourier_transform(Ori,x,k)
a.subs({k:1}).evalf()
>>>9.16769605680502e-5
FT.subs({s:1,k:1}).evalf()
>>>FourierTransform(exp(-x**2), x, 1)

FT.subs({s:1,k:1}).The value of eval() is a.subs({k:1}).It should come out as a number like eval(), but it doesn't come out. What is wrong?

Ori is a function of x, and Ori is Fourier Transform for k, so it is not understandable that x is defined in Fourier Transform (exp(-x*2), x, 1).

sympy fourier_transform

2022-09-21 23:04

1 Answers

I already gave you an answer...I don't think I've read enough help.

FourierTransform (exp (-x*2), x, 1) itself is still before execution.

You can explicitly run doit to get a formula and evaluate it.

I wrote it in stages as much as possible, so I hope you can see and understand.

...
...
FT=fourier_transform(Ori,x,k)
print(a.subs({k:1}).evalf())

F = FT.subs({s:1,k:1}).evalf()
print(F)
F2 = F.doit()
print(F2)
V = F2.evalf()
print(V)

9.16769605680502e-5
FourierTransform(exp(-x**2), x, 1)
sqrt(pi)*exp(-pi**2)
9.16769605680502e-5


2022-09-21 23:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.