Continuous Fourier Transform : fourier, ifourier

### 5.25.2 Continuous Fourier Transform : fourier, ifourier

The command fourier takes one to three arguments: an expression f(x) and (optionally) identifiers x and s . It returns the Fourier transform F of f defined by

F(s)= | ∫ |
+∞
−∞
| e−i s x f(x) dx, s∈ℝ. (5)

If s is not given, F is returned as a function of x .

The command ifourier works the other way round: it takes arguments F(s) and (optionally) s and x , and returns the expression f(x) using the formula

f(x)= |
1
2 π
|  | ∫ |
+∞
−∞
| ei s x F(s) ds.

To compute the above integral, fourier is called with input parameters F(s)/2 π , s and x , replacing x with −x in the result.

Arbitrary rational functions can be transformed. For example, to find the Fourier transform of f(x)=x/x3−19 x+30 , input :

F:=fourier(x/(x^3-19x+30),x,s)

Output :

pi*(5*i*exp(5*i*s)+(-21*i)*exp((-3*i)*s)+16*i*exp((-2*i)*s))*sign(s)/56

Input :

ifourier(F,s,x)

Output :

x/(x^3-19*x+30)

Similarly, to find the transform of f(x)=x2+1/x2−1 , input :

F:=fourier((x^2+1)/(x^2-1),x,s)

Output :

2*pi*(Dirac(s)-sign(s)*sin(s))

Input :

ifourier(F,s,x)

Output :

(x^2+1)/(x^2-1)

A range of other (generalized) functions and distributions can be transformed, as demonstrated in the following examples. If fourier does not know how to transform a function, say f , it returns the unevaluated integral (5). In these cases one may try to evaluate the result using eval.
Input :

fourier(3x^2+2x+1,x,s)

Output :

2*pi*(Dirac(s)+2*i*Dirac(s,1)-3*Dirac(s,2))

Input :

fourier(Dirac(x-1)+Dirac(x+1),x,s)

Output :

2*cos(s)

Input :

fourier(exp(-2*abs(x-1)),x,s)

Output :

4*exp(-i*s)/(s^2+4)

Input :

fourier(atan(1/(2x^2)),x,s)

Output :

2*pi*sin(s/2)*exp(-abs(s)/2)/s

Input :

fourier(BesselJ(3,x),x,s)

Output :

-s*(4*s^2-3)*(-i*sign(s+1)+i*sign(s-1))/sqrt(-s^2+1)

Input :

F:=fourier(sin(x)*sign(x),x,s)

Output :

-2/(s^2-1)

Input :

ifourier(F,s,x)

Output :

sign(x)*sin(x)

Input :

fourier(log(abs(x)),x,s)

Output :

-pi*(2*euler_gamma*Dirac(s)*abs(s)+1)/abs(s)

Input :

fourier(rect(x),x,s)

Output :

2*sin(s/2)/s

Input :

fourier(exp(-abs(x))*sinc(x),x,s)

Output :

atan(s+1)-atan(s-1)

Input :

fourier(1/sqrt(abs(x)),x,s)

Output :

sqrt(2)*sqrt(pi)/sqrt(abs(s))

Input :

F:=fourier(1/cosh(2x),x,s)

Output :

pi/(exp(pi*s/4)+exp(-pi*s/4))

Input :

ifourier(F,s,x)

Output :

2/(exp(2*x)+exp(-2*x))

Input :

fourier(Airy_Ai(x/2),x,s)

Output :

2*exp(8*i*s^3/3)

Input :

F:=fourier(Gamma(1+i*x/3),x,s)

Output :

6*pi*exp(-exp(-3*s)-3*s)

Input :

ifourier(F,s,x)

Output :

Gamma(i*x/3+1)

Input :

F:=fourier(atan(x/4)/x,x,s)

Output :

pi*ugamma(0,4*abs(s))

Input :

ifourier(F,s,x)

Output :

atan(x/4)/x

Input :

assume(a>0):; fourier(exp(-a*x^2+b),x,s)

Output :

sqrt(a)*sqrt(pi)*exp(-s^2/(4*a)+b)/a

In the following example we compute the convolution of f(x)=e−|x| with itself using the convolution theorem. Input :

F:=fourier(exp(-abs(x)),x,s)

Output :

2/(s^2+1)

Input :

ifourier(F^2,s,x)

Output :

x*Heaviside(x)*exp(-x)-x*Heaviside(-x)*exp(x)+exp(-abs(x))

The above result is the desired convolution f∗ f(x)=∫−∞+∞f(t) f(x−t) dt .

Piecewise functions can be transformed if defined as

piecewise(x<a1,f1,x<a2,f2,...,x<an,fn,f0)

where a1,a2,…,an are real numbers such that a1<a2<⋯<an . Inequalities may be strict or non-strict.
Input :

f:=piecewise(x<=-1,exp(x+1),x<=1,1,exp(2-2x)):; F:=fourier(f,x,s)

Output :

(-i*s*sin(s)+3*s*cos(s)+4*sin(s))/(s*(s-2*i)*(s+i))

The original function f is obtained from the above result by applying ifourier. Input :

ifourier(F,s,x)

Output :

Heaviside(x+1)-Heaviside(x-1)+Heaviside(x-1)*exp(-2*x+2)+ Heaviside(-x-1)*exp(x+1)

One may verify that the above expression is equal to f(x) by plotting.

To transform unknown functions, one can use the command addtable which takes five arguments: fourier or laplace (to indicate the desired transform definition), f(x) , F(s) , x and s , where f , F , x and s are identifiers. If the first argument is fourier, this means that F{f(x)}(s)=F(s) i.e. that the command

fourier(f(x),x,s)

would return F(s). The return value of addtable is 1 on success and 0 on failure. The second and the third argument can also be expressions depending on several variables.
Input :

addtable(fourier,y(x),Y(s),x,s)

Output :

1

Input :

fourier(y(a*x+b),x,s)

Output :

Y(s/a)*exp(i*s*b/a)/abs(a)

Input :

fourier(Y(x),x,s)

Output :

2*pi*y(-s)

Input :

addtable(fourier,g(x,t),G(s,t),x,s)

Output :

1

Input :

fourier(g(x/2,3*t),x,s)

Output :

2*G(2*s,3*t)

Fourier transform can be used for solving linear differential equations with constant coefficients. For example, we obtain a particular solution to the equation

y(x)+4 y(4)(x)=δ(x),

where δ is the Dirac delta function. First we transform both sides of the above equation. Input :

L:=fourier(y(x)+4*diff(y(x),x,4),x,s); R:=fourier(Dirac(x),x,s)

Output :

Y(s)-4*s^4*Y(s), 1

Then we solve the equation L=R for Y(s) . Generally, one should apply csolve instead of solve. Input :

sol:=csolve(L=R,Y(s))[0]

Output :

1/(4*s^4+1)

Finally, we apply ifourier to obtain y(x) . Input :

ifourier(sol,s,x)

Output :

(sin(abs(x)/2)+cos(abs(x)/2))*exp(-abs(x)/2)/4

The above solution can be combined with solutions of the corresponding homogeneous equation to obtain the general solution.