# Integrating interpolated function in polar coordinates

I have a set of data that I wish to express in polar coordinates.

The data represents the function $f(k_x,k_y)$ in the integral below
$\int_{-\infty}^{\infty} \int_{-\infty}^{\infty} dk_x dk_y f(k_x,k_y) = \int_0^{2\pi} d \theta \int_0^\infty dk \, n(k)$.

I am looking to find the corresponding function $n(k)$ in polar coordinates, where $k = \sqrt{k_x^2 + k_y^2}$ and it's possible to write $k_x = k \cos \theta$, $k_y = k \sin \theta$.

With a analytic function, mathematica can easily do this: if the function is f, then the following

Integrate[f[k Cos[\[Theta]], k Sin[\[Theta]]], {\[Theta], 0, 2 \[Pi]}]


easily gives me the right function. However, instead of an analytic function I tried to make a function by interpolating my dataset with

f=ListInterpolate[data]


Now, I can no longer integrate out the $\theta$ dependence. I have looked at directly transforming the data as a list, but could not find an appropriate transform. Is there a way to get the interpolated function to behave, or perhaps a much more obvious method of doing this that I'm missing?

(The data I am interpolating is of the form

{{ z@k_x1@k_y1, z@k_x2@k_y1 ...},{z@k_x1@k_y2,z@k_x2@k_y2 }...}

i.e no explicit $k_x$ and $k_y$ coordinates to work with.)

It is exactly the same way as in the case of the function given in the analytical form. This might be the end of my message, but I think, it may help to have a look at an example.

Since you did not give any data to play with, I will generate a simple example myself. Here is a list of an exponential:

lst1 = Table[Exp[-5 (x^2 + y^2)], {x, -1, 1, 0.1}, {y, -1, 1, 0.1}];


Here is the interpolation of this list:

f2 = ListInterpolation[lst1, {{-1, 1}, {-1, 1}}]


This is the check that we obtained something reasonable:

Plot3D[f2[x, y], {x, -1, 1}, {y, -1, 1}] Now let us integrate

NIntegrate[f[k*Cos[\[CurlyPhi]], k*Sin[\[CurlyPhi]]]*k, {k, 0,0.5},{\[CurlyPhi], 0, 2 \[Pi]}]

(*  0.0000147   *)


Have fun!

• Here, I am not wanting to integrate with respect to $k$ - the whole point of this exercise is to make a vector of the function $n(k)$. Using NIntegrate without integrating with respect to $k$ will of course return an error, as numerical will not be obtained. – ZufolgeWeierstrass Dec 19 '16 at 0:04
• I am not sure that I correctly understood your explanation. It seems that you do not want to integrate over k under the NIntegrate function, but leave k as a variable. If this is right, try this: g[k_] := NIntegrate[ f2[k*Cos[\[CurlyPhi]], k*Sin[\[CurlyPhi]]]*k, {\[CurlyPhi], 0, 2 \[Pi]}] . You can then, say, plot this function:  Plot[g[k], {k, 0, 1}] or do whatever you want with it. – Alexei Boulbitch Dec 19 '16 at 9:07
• Yes! This is exactly what I wanted. Thank you very much for your help! – ZufolgeWeierstrass Dec 20 '16 at 23:16