Hello,

I’m currently writing an algorithm to solve a specific kind of PDE, via Fourier Transform.

In the several examples that I saw, the general idea is to transform everything to the frequency domain using an `fft`

, do the computational stuff (Forward Euler, etc) and in the end transform it back to the natural domain using `ifft`

, thus obtaining the solution to our PDE.

My difficulties come when I, naively, apply the `fft`

and `ifft`

to my equation. For a toy example, where the analytical solution is known I get the following:

It seems to me that some kind of boundary conditions is being wrongly satisfied. The solution doesn’t have the domain periodicity (in this case [-10;10]).

However, if I replace `fft`

and `ifft`

by `fftshift(fft(ifftshift(U)))`

and `fftshift(ifft(ifftshift(U)))`

, respectively. I obtain the correct answer:

Well, this seems strange to me, because the `(i)fftshifts`

commands are only to shift the Fourier coefficients to their regular order when transforming to the frequency domain. But this is

reestablished when we perform the inverse transform:

```
using FFTW
julia> A=trunc.(Int64,rand(6)*10)
6-element Array{Int64,1}:
0
2
3
7
1
2
julia> â=fft(A) # F. coefs with shifted order
6-element Array{Complex{Float64},1}:
15.0 + 0.0im
-7.0 - 1.7320508075688772im
3.0 + 1.7320508075688772im
-7.0 + 0.0im
3.0 - 1.7320508075688772im
-7.0 + 1.7320508075688772im
julia> ifft(â) # equals to original vector A
6-element Array{Complex{Float64},1}:
0.0 + 0.0im
2.0 + 0.0im
3.0 + 0.0im
7.0 + 0.0im
1.0 + 0.0im
2.0 + 0.0im
```

Someone know why this behavior happens when solving PDE using the Fourier Transform?

I really need that my algorithm be fast as possible. For each time step computing 2 shifts for every time I compute an `fft`

it’s too much computations spent on this issue, I guess

It’s the first time that I’m using this method to solve PDEs, so I don’t know that much about signal processing and fourier transforms. Any help?

Best regards,

Tiago