# Multivariate Fourier

## Recommended Posts

Would anyone please write for me the multivariate(two variables will do) Fourier series in trigonometric form?

##### Share on other sites
I'm pretty sure the following is correct... (All this is for an AABB in n dimensions):

For each wavevector 'w,' you have two basis functions,

x --> k cos(<w, x>)

and

x --> k sin(<w, x>)

where <.,.> denotes the Euclidean inner product in R^n and k is a constant chosen to make the functions' L2 norms be 1 (things are just nicer that way); I'll get to it later.

Assuming your domain is an AABB in n dimensions, with side lengths L_1,L_2,...,L_n, those wavevectors are any whose coefficients satisfy,

w_i = (2 pi j_i)/L_i

for some integers j_1,...,j_n >= 0.

Finally, the normalizing constant is,

k = [(1/2) L1 L2 ... Ln]^(-1/2)

for all basis functions except the one corresponding to the zero wavevector (for that one, get rid of the (1/2)).

The coefficients, then, are the L2 inner products of those basis functions with the function you want to approximate (i.e., the integral over the box of their product).

To summarize,

\begin{align*} f&:[0,L_1]\times\cdots\times[0,L_n] \to {\mathbb R} \\ f(x) &= a_0 + k \sum_{i_1,\cdots,i_n}\left[a_{i_1,\cdots,i_n} \cos\left( 2 \pi\left(\frac{i_1}{L_1} x_1 \cdots \frac{i_n}{L_n} x_n\right )\right )+ b_{i_1,\cdots,i_n}\sin\left( 2 \pi\left(\frac{i_1}{L_1} x_1 \cdots \frac{i_n}{L_n} x_n\right )\right ) \right ] \\ a_0 &= \frac{1}{V_1\cdots V_n} \int_0^{L_1}\cdots \int_0^{L_n} f(x) ~dx \\ a_{i_1,\cdots,i_n} &= k \int_0^{L_1} \cdots \int_0^{L_n} \cos\left( 2 \pi\left(\frac{i_1}{L_1} x_1 \cdots \frac{i_n}{L_n} x_n\right )\right ) f(x) ~dx \\ b_{i_1,\cdots,i_n} &= k \int_0^{L_1} \cdots \int_0^{L_n} \sin\left( 2 \pi\left(\frac{i_1}{L_1} x_1 \cdots \frac{i_n}{L_n} x_n\right )\right ) f(x) ~dx \\ k &= \frac{1}{\sqrt{\frac{1}{2}V_1 \cdots V_n}} \end{align*}

where "=" in each case is in the L2 sense. I.e., two functions are "equal" iff the integral of the square of their difference is zero.

Let me know if I've made a mistake somewhere.

...

Also...

1.) The square roots are nice theoretically because they give you an orthonormal basis instead of just an orthogonal one. But square roots aren't great computationally, so you can get rid of the 'k' in the second equation in my LaTeX box and remove the square root from the definition of 'k' on the 6th line, if you prefer.

2.) If you're just truncating the sum by using, say, all the wavevectors in a box around the origin, then this isn't an issue... but, in the infinite case, the order in which you iterate matters; you need to reach each bounded index in a finite number of iterations. A "Cantor diagonalization"-like order will do that. I.e., do all the wavevectors whose wavenumber vector has a 1-norm of 1, then all those whose 1-norm is 2, etc. You can do that like,
 // In this pseudocode, arrays are 1-basedfor s[n] = 0 to infinity{   for s[n-1] = 0 to s[n]   {      i[n] = s[n]-s[n-1];      for s[n-2] = 0 to s[n-1]      {         i[n-1] = s[n-1]-s[n-2];         //...         for s[1] = 0 to s[2]         {            i[2] = s[2] - s[1];            i[1] = s[1];            // Do something with index vector 'i.'         }      }   }}

or, for prettier code, with a nice iterator object...

...

Also, all this said, I should probably ask what you're doing; you might actually want the DFT, DCT, or even something else...

[Edited by - Emergent on November 15, 2010 10:52:54 PM]

##### Share on other sites
Hi Emergent,

Thank you very much. You described it very nicely, it is a great
help indeed.

I just want to fit my data using matlab surface fitting tool box.
So I need to use the multivariate Fourier series to see whether
I can represent my data using Fourier basis.

Thanks again.:)

##### Share on other sites
out of curiosity, is there any reason you don't simply use the fourier transform to do fit your data to the basis? It has built-in and well-tested fast 1-d,2-d and n-d implementations in matlab.

##### Share on other sites
I am using surface fitting tool(sftool) of matlab.
It does not have library model for Fourier.However
it has an option for custom model. So I need
the Fourier equation to make the custom model work
as Fourier for me.

##### Share on other sites
Right, I get that, but have you thought that maybe the surface fit tool doesn't include fourier basis functions because it is easier and more efficient to fit the surface using fft2?