9 votes

Approximate $h$ in $F(\theta)=\sin \theta \int_{-L}^{+L}h(z)e^{-ikz\cos \theta} \,dz$

This is a linear integral equation (because the right hand side is linear in $h$) and presumably the problem is ill-posed (for one, because of the multiplication by $\sin(\theta)$ but also because the ...
user avatar
  • 1,728
8 votes
Accepted

Numerically computing the advection equation

I see several issues: The DFT computed with fft puts the zero mode at the beginning of the array, and if you want to compute the derivative, it is necessary to ...
user avatar
  • 11.4k
7 votes

Fourier transform by FFT : by using cubic splines to interpolate between data points, do we change the frequency content of the Fourier transform?

The frequency content of the interpolated signal is significantly influenced by the interpolation basis. If you have a band-limited function that you have adequately sampled (i.e. satisfying Nyquist ...
user avatar
7 votes

Numpy FFT gives me a pulse shorter than it should be. Not sure what I am doing wrong

Running your code, it seems like your pulse looks kinda like this: (sorry for not adding units to the plots, I used the same as you, i.e. t is in fs and w in rad/fs) So, the FWHM is not correct (...
user avatar
6 votes
Accepted

Complete (an incomplete) explanation of the phenomenon of "aliasing", when using Fourier series to approximate functions?

This turned out much longer than I planned so I hope it is useful and can be a resource for others with the same questions. I believe you mean to ask primarily about the discrete Fourier transform (...
user avatar
6 votes
Accepted

How do I avoid divide-by-zero when solving the Poisson equation with Fourier transforms?

You are solving Poisson's equation: $$\nabla^2 \Phi = 4\pi G \rho.$$ Notice that if $\Phi$ is a solution, then so is $\Phi+C$ for any constant $C$. Furthermore, $C$ will have no effect on your ...
user avatar
6 votes

Fourier transform by FFT : by using cubic splines to interpolate between data points, do we change the frequency content of the Fourier transform?

The interpolation indeed affects the Fourier transform. @Steve already gives the correct answer in general, but I want to give you an example that helps the intuition more. Think for example that you ...
user avatar
6 votes
Accepted

Von Neumann stability analysis with a constant term

From your link, consider the definition of the round off error and the statement "Since the exact solution must satisfy the discretized equation exactly, the error must also satisfy the discretized ...
user avatar
  • 2,199
5 votes
Accepted

Does this Algorithm (probably Fourier like) Exist for 2D Shapes?

You can write a curve as a parametric equation ($x(t)$, $y(t)$) for a range say $0 < t < 1$. Then you can have a Fourier decomposition of both $x(t)$ and $y(t)$. A rectangle can be written as ...
user avatar
  • 166
5 votes
Accepted

Quick and simple discrete 2D Helmholtz-Hodge Decomposition using FFTs?

The easiest way to generate a divergence-free 2D function is to use a streamfunction, $\psi$. Where $$ u=\frac{\partial\psi}{\partial y}\quad \rm{and}\quad v=-\frac{\partial \psi}{\partial x}$$ Once ...
user avatar
  • 10.8k
5 votes
Accepted

MATLAB FFT Differentiation

1) You have misinterpreted the order the fft2 output elements are stored. This is a very common mistake, since it is very easy to get confused. Thankfully, there is an easy way to avoid such bugs. ...
user avatar
  • 220
5 votes
Accepted

Fourier characteristics of repeated numerical derivative

Regarding point 1: generally, applying a discretized derivative (stencil) twice is not equivalent to applying an equivalent (i.e. same number of points) stencil for the second derivative. Example in ...
user avatar
  • 211
5 votes

Rudin lecture -- if f(x) is not integrable on some interval, does it not have a Fourier Series expansion on that interval?

The point is to guarantee that the Fourier coefficients exist, not to make really fine distinctions about what might happen if the guarantee is violated. Furthermore, you would be hard pressed to find ...
user avatar
  • 11.4k
5 votes

Solving numerically the 1D Kuramoto-Sivashinsky Equation using spectral methods

Indeed the problem was that you were trying to calculate your nonlinear term incorrectly and you forgot that: $$\mathcal{F}[(f(x))^{2}] \neq (\mathcal{F}[f(x)])^{2}$$ I changed your code to this: <...
user avatar
5 votes

Why do problems arise in FFT for smaller value of df in Python?

The discrete Fourier transform for a signal of period $T$ with $N$ samples reads in its inverse or reconstruction form as $$ y(t)=\frac1{N}\sum_{k=-N/2}^{N/2}c_k e^{i2\pi k\frac{t}{T}} $$ with ...
user avatar
  • 3,651
4 votes

Generate high n quantum harmonic oscillator states numerically

I did some more investigating about the accuracy of the standard recurrence relation method vs. the newer Bunck algorithm. It seems that in fact the Bunck algorithm is generally more accurate for all $...
user avatar
  • 956
3 votes

Bounded Input Boundaed Output stability for heat equation. Proof or Counter example?

You immediately get $L^\infty$ stability by using the eigenfunction decomposition of the solution. The coefficient of each mode is strictly decreasing exponentially if you don't have a right hand side ...
user avatar
3 votes

Convolution of two real functions using discrete Fourier transform (FFT): zero-padding and normalization

You want to calculate $$c(t)=\int_{-6}^6dx f(x)g(t-x)$$. Your functions are not periodic, but you pad them with zeros so that assuming them to be repeated periodically does not mess up the calculation ...
user avatar
  • 131
3 votes

How do I take the FFT of unevenly spaced data?

Addition to the accepted answer. Here is a link to an open source implementation of Greengard's and Lee's method: https://finufft.readthedocs.io/en/latest/ It has wrappers to C, fortran, MATLAB, ...
user avatar
  • 119
3 votes
Accepted

What spline functions are used in Section 13.9 of "Numerical Recipes in C"?

When I change your code to this: ...
user avatar
  • 11.4k
3 votes

How to do Fast Fourier transform (FFT) for singular functions?

It's a question of function spaces. If your function is in $L^2$, then you know that you can approximate the function using a Fourier series because the Fourier basis (i.e., the sines and cosines) are ...
user avatar
3 votes
Accepted

3D Poisson equation, Fourier and Chebyshev

It is so trivial to pick a solution on a box domain for the Laplace equation. Just pick a function, say $\bar u(x,y,z)=x^2y^2\sin(z)$ (chosen in a way so that it isn't in your ansatz space), then ...
user avatar
3 votes

Obtain velocity from imposed energy spectrum using the inverse FFT

I recommend you first read answer here to find out why $\tilde{E}(\mathbf{k}) \neq \frac{1}{2} \tilde{\mathbf{u}}(\mathbf{k}) \cdot \tilde{\mathbf{u}}(\mathbf{k})$. In order to find velocity profile ...
user avatar
2 votes

Order of MATLAB FFT frequencies

Your question concerning wavenumber 'replacement' is rather tricky. In general, wavenumber modification of this sort is not intended to save flops, as some have suggested here, but instead designed to ...
user avatar
2 votes
Accepted

Zero-k mode in Pseudo-spectral solution of Stokes Flow

You are correct that the $k=0$ mode corresponds to the mean (volume averaged) velocity in the domain. Because the equations for Stokes flow are Galilean invariant they are undetermined up to a ...
user avatar
2 votes

How do I solve Laplace's equation in 2D using spectral methods?

So many options! This can be solved analytically using separation of variables. So that's good. Gives us something to check against, make sure that we are doing this right, and a good way of checking ...
user avatar
  • 211
2 votes

Enforcing non-negative constraint in fourier-spectral method

This is more of a comment, but I believe the more common name for this is "positive trigonometric polynomial", so this book might be helpful. One approach (http://www.mit.edu/~parrilo/cdc03_workshop/...
user avatar
  • 11.4k
2 votes
Accepted

How to calculate efficiently and accurately the Fourier transform of a radial function in Fortran

I have tried the following code in Julia for $f(r) = exp(-r)$ with 1D FFT, which seems to be working somehow. So, could you compare your code with it and see if there is some difference of ...
user avatar
  • 156

Only top scored, non community-wiki answers of a minimum length are eligible