# Continuous Fourier Transform: fourier ifourier addtable

### 5.26.2 Continuous Fourier Transform: fourier ifourier addtable

The Fourier transform of a function f is defined by

F(s)=

∫

+∞
−∞

e−i s x f(x) dx, s∈ℝ. (5)

The fourier command computes the Fourier transform.

- fourier takes one mandatory argument and two optional arguments:
  - expr, an expression which defines a function f(x)=expr.
  - Optionally, x, the variable for f (by default x).
  - Optionally, s, the variable for the Fourier transform (by default x).
- fourier(expr ⟨ ,x,s⟩) returns the Fourier transform F(s). If s is not given, then x will be used.

The inverse Fourier transform, as its name implies, takes a Fourier transform F(x) and returns the original function f(x). It is given by:

f(x)=

1
2 π

∫

+∞
−∞

ei s x F(s) ds. (6)

The ifourier command computes the inverse Fourier transform.

- ifourier takes one mandatory argument and two optional arguments:
  - expr, an expression which defines a function F(x)=expr.
  - Optionally, x, the variable for F (by default x).
  - Optionally, X, the variable for the original function f (by default x).
- ifourier(expr ⟨ ,x,X⟩) returns the inverse Fourier transform f(X). If X is not given, then x will be used.

Note the similarity between the definitions of the Fourier transform (equation (5)) and its inverse (equation (6)). To compute the inverse transformation of F(s), it is enough to compute the Fourier transform with function F(s)/2π and using the variables s and x instead of x and s, and replacing x with −x in the result.

#### Examples.

- Arbitrary rational functions can be transformed. For example, we find the Fourier transform of f(x)=x/x3−19 x+30.
  Input:
  F:=fourier(x/(x^3-19x+30),x,s)
  Output:

  1
  56

  π sign

  ⎛
  ⎝

  s

  ⎞
  ⎠

  ⎛
  ⎝

  16 i e−2 i s −21 i e−3 i s +5 i e5 i s

  ⎞
  ⎠

  Input:
  ifourier(F,s,x)
  Output:

  x
  x3−19 x+30

- Find the transform of f(x)=x2+1/x2−1:
  Input:
  F:=fourier((x^2+1)/(x^2-1),x,s)
  Output:

  2 π | ⎛ ⎝ | δ | ⎛ ⎝ | s | ⎞ ⎠ | −sign | ⎛ ⎝ | s | ⎞ ⎠ | sins | ⎞ ⎠

  Input:
  ifourier(F,s,x)
  Output:

  x2+1
  x2−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, it returns the unevaluated integral (5). In these cases you may try to evaluate the result using eval.

#### Examples.

- Input:
  fourier(3x^2+2x+1,x,s)
  Output:

  2 π | ⎛ ⎝ | δ | ⎛ ⎝ | s | ⎞ ⎠ | +2 i δ | ⎛ ⎝ | s,1 | ⎞ ⎠ | −3 δ | ⎛ ⎝ | s,2 | ⎞ ⎠ | ⎞ ⎠

- Input:
  fourier(Dirac(x-1)+Dirac(x+1),x,s)
  Output:

  2 coss

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

  4 e−i s
  s2+4

- Input:
  fourier(atan(1/(2x^2)),x,s)
  Output:

  2 π e

  −

  ⎪ ⎪ | s | ⎪ ⎪

  2

  sin

  ⎛
  ⎜
  ⎜
  ⎝

  s
  2

  ⎞
  ⎟
  ⎟
  ⎠

  s

  2*pi*sin(s/2)*exp(-abs(s)/2)/s
- Input:
  fourier(BesselJ(3,x),x,s)
  Output:

  −

  s | ⎛ ⎝ | 4 s2−3 | ⎞ ⎠ | ⎛ ⎝ | −i sign | ⎛ ⎝ | s+1 | ⎞ ⎠ | +i sign | ⎛ ⎝ | s−1 | ⎞ ⎠ | ⎞ ⎠

  √

  −s2+1

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

  −

  2
  s2−1

  Input:
  ifourier(F,s,x)
  Output:

  sign | ⎛ ⎝ | x | ⎞ ⎠ | sinx

- Input:
  fourier(log(abs(x)),x,s)
  Output:

  −

  π | ⎛ ⎝ | 2 γ δ | ⎛ ⎝ | s | ⎞ ⎠ | ⎪ ⎪ | s | ⎪ ⎪ | +1 | ⎞ ⎠

  ⎪ ⎪ | s | ⎪ ⎪

- Input:
  fourier(rect(x),x,s)
  Output:

  2 sin

  ⎛
  ⎜
  ⎜
  ⎝

  s
  2

  ⎞
  ⎟
  ⎟
  ⎠

  s

- Input:
  fourier(exp(-abs(x))*sinc(x),x,s)
  Output:

  arctan | ⎛ ⎝ | s+1 | ⎞ ⎠ | −arctan | ⎛ ⎝ | s−1 | ⎞ ⎠

- Input:
  fourier(1/sqrt(abs(x)),x,s)
  Output:

  √

  2

  √

  π

  √

  ⎪ ⎪ | s | ⎪ ⎪

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

  π

  e

  −

  1
  4

  π s

  +e

  1
  4

  π s

  Input:
  ifourier(F,s,x)
  Output:

  2
  e−2 x+e2 x

- Input:
  fourier(Airy_Ai(x/2),x,s)
  Output:

  2 e

  8
  3

  i s3

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

  6 π e

  − | ⎛ ⎝ | 3 s+e−3 s | ⎞ ⎠

  Input:
  ifourier(F,s,x)
  Output:

  Γ

  ⎛
  ⎜
  ⎜
  ⎝

  1
  3

  i x+1

  ⎞
  ⎟
  ⎟
  ⎠

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

  π ugamma | ⎛ ⎝ | 0,4 | ⎪ ⎪ | s | ⎪ ⎪ | ⎞ ⎠

  Input:
  ifourier(F,s,x)
  Output:

  arctan

  ⎛
  ⎜
  ⎜
  ⎝

  x
  4

  ⎞
  ⎟
  ⎟
  ⎠

  x

- Input:

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

  Output:

  √

  a

  √

  π

  e

  −

  s2
  4 a

  +b

  a

The Fourier transform behaves nicely when combined with convolutions. Recall the convolution (see Section 15.2.8) of two functions f and g is

(f∗ g)(x) =

∫

+∞
−∞

f(t) g(x−t) dt

If F(f) represents the Fourier transform of a function f, then the convolution theorem states

F(f∗ g) = F(f)·F(g).

#### Example.

In this example, the convolution theorem will be used to compute the convolution of f(x)=e−|x| with itself.
Input:

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

Output:

2
s2+1

Input:

ifourier(F^2,s,x)

Output:

−x θ

⎛
⎝

−x

⎞
⎠

ex+x θ

⎛
⎝

x

⎞
⎠

e−x+e

− | ⎪ ⎪ | 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)

for appropriate functions f0,…,fn and a1,a2,…,an are real numbers such that a1<a2<⋯<an . Inequalities may be strict or non-strict.

#### Example.

Input:

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

Output:

3 s coss−i s sins+4 sins

s | ⎛ ⎝ | s−2 i | ⎞ ⎠ | ⎛ ⎝ | s+i | ⎞ ⎠

You can obtain the original function f from the above result by applying ifourier.
Input:

ifourier(F,s,x)

Output:

θ | ⎛ ⎝ | −x−1 | ⎞ ⎠ | ex+1+θ | ⎛ ⎝ | x+1 | ⎞ ⎠ | +θ | ⎛ ⎝ | x−1 | ⎞ ⎠ | e−2 x+2−θ | ⎛ ⎝ | x−1 | ⎞ ⎠

You can verify that the above expression is equal to f(x) by plotting them.

Some algebraic transformations of a function behave predictably under the Fourier transform. For example, if g(x) = f(x−a), then F(g)(s) = e−2π i a sF(f)(s). The addtable command lets you assign a function name to the Fourier (or Laplace, see Section 5.57.2) transform of another function name, without specifying the either function. This allows you to alter the original function and see the effect on the Fourier (or Laplace) transform.

- addtable takes five arguments:
  - transform, which can be fourier or laplace and indicates the type of transform.
  - f(x), where f is a symbol representing an unspecified function of the variable x.
  - F(s), where F is a symbol representing the transform of f and s is the new variable.
  - x, the variable used by f.
  - s, the variable used by F.
- addtable(transform,f(x),F(s),x,s) returns 1 if F is assigned as the transform of f, and 0 otherwise. In the case that F is assigned as the transform of f, then the transform (fourier or laplace) of manipulations of f will be returned in terms of F and conversely.

#### Examples.

- Input:
  addtable(fourier,y(x),Y(s),x,s)
  Output:

  1

  Input:
  fourier(y(a*x+b),x,s)
  Output:

  e

  i b s
  a

  Y

  ⎛
  ⎜
  ⎜
  ⎝

  s
  a

  ⎞
  ⎟
  ⎟
  ⎠

  ⎪ ⎪ | a | ⎪ ⎪

  Input:
  fourier(Y(x),x,s)
  Output:

  2 π 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 transforms can be used for solving linear differential equations with constant coefficients. For example, to obtain a particular solution to the equation

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

where δ is the Dirac delta function, you can first 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:

4 s4 Y | ⎛ ⎝ | s | ⎞ ⎠ | +Y | ⎛ ⎝ | s | ⎞ ⎠ | ,1

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

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

Output:

1
4 s4+1

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

ifourier(sol,s,x)

Output:

1
4

e

−

⎪ ⎪ | x | ⎪ ⎪

2

⎛
⎜
⎜
⎝

cos

⎛
⎜
⎜
⎝

⎪ ⎪ | x | ⎪ ⎪

2

⎞
⎟
⎟
⎠

+sin

⎛
⎜
⎜
⎝

⎪ ⎪ | x | ⎪ ⎪

2

⎞
⎟
⎟
⎠

⎞
⎟
⎟
⎠

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