sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
12.96k stars 4.43k forks source link

Issue #2803 still does not appear to result in a readable and reasonable solution #8559

Open Llewelyn62 opened 9 years ago

Llewelyn62 commented 9 years ago

As an example, the Fourier Transform of (e^-n*x , x=>0) is 1/sqrt(2*pi)*(1/(n-ik)). Using : fourier_transform(exp(x*-n),x,k, noconds=False) Got Result =0. This is incorrect, largely I think due to the interval -oo to oo. By hand, this discontinuous equation is calculated as two parts around 0. Also output had the warning: Expected a delimiter (at char 34), (line:1, col:35) FormatterWarning, Using the source code as below (which allows limits to be set), 1/sqrt(2*pi)*Integral(a*exp(-n*x)*exp(b*I*x*k), (x, 0, oo)).subs(a,1).subs(b,1).doit() the result is not an especially readable solution, but correct. Result: 1/(n(-ik/n + 1)), which of course is 1/(n-ik) simplified.

  1. It would be useful to be able to add limits of integration to account for discontinuous functions.
  2. It is easier to copy the LaTex code as an output (print(latex(Integral(etc))) into an editor and then read...would having the latex format AND the present output be useful?
  3. In the source code, I do not understand why the formula lacks the co-efficient 1/sqrt(2*pi). http://en.wikipedia.org/wiki/Fourier_transform#Other_conventions

Apologies if the suggestions are not appropriate -- am newish to Python.

oscarbenjamin commented 5 years ago

The first example doesn't evaluate now:

In [7]: fourier_transform(exp(-n*x),x,k, noconds=False)                                                                                        
Out[7]: 
                ⎛ -n⋅x      ⎞
FourierTransform⎝ℯ    , x, k⎠

The second example I guess is

In [18]: a, b = symbols('a b')                                                                                                                 

In [19]: k = Symbol('k', integer=True, positive=True)                                                                                          

In [20]: n = Symbol('n', integer=True, positive=True)                                                                                          

In [21]: 1/sqrt(2*pi)*Integral(a*exp(-n*x)*exp(b*I*x*k), (x, 0, oo)).subs(a,1).subs(b,1).doit()                                                
Out[21]: 
        √2        
──────────────────
       ⎛  ⅈ⋅k    ⎞
2⋅√π⋅n⋅⎜- ─── + 1⎟
       ⎝   n     ⎠

Note that this comes out with a complicated Piecewise expression if k, n are no declared positive.

Does that seem correct to you?