# What would the right approach to perform a 2D discrete convolution for this problem ?

**URL:** <https://community.wolfram.com/t/what-would-the-right-approach-to-perform-a-2d-discrete-convolution-for-this-problem/23999>\
**Category:** Questions\
**Tags:** physics\
**Created:** [May 15, 2024, 4:14pm UTC](https://community.wolfram.com/t/what-would-the-right-approach-to-perform-a-2d-discrete-convolution-for-this-problem/23999 "2024-05-15T16:14:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian9](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@ian9](https://community.wolfram.com/u/ian9)\
**Post date:** [May 15, 2024, 4:14pm UTC](https://community.wolfram.com/t/what-would-the-right-approach-to-perform-a-2d-discrete-convolution-for-this-problem/23999/1 "2024-05-15T16:14:57Z")

</div>

I am trying to perform a 2D discrete convolution of two terms; one a Gaussian and a differentiated Green’s function containing Hankel function of first kind and zero order. The convolution is defined as p(x,y,t) = f(x,y) \* \frac{d}{dt} G(x,y,t) where,

- f(x,y) = \epsilon e^{ -\alpha (x^2 + y^2) }
- \frac{d}{dt}G(x,y,t) = \frac{\omega}{4} \frac{1}{c\_0^2 } H\_0^{(1)}\left [k\sqrt{x^2+y^2} \right] e^{-i \omega t}

The common parameters in these terms are

- \epsilon=0.5,
- \alpha = \frac{log(2)}{2}
- \omega = \frac{2\pi}{30}
- c = 340.2626486
- k = \omega/c
- t = 90

These terms are from a paper in acoustics. I have tried to perform a discrete convolution but it fails to produced any output except the warning `TerminatedEvaluation["RecursionLimit"]`. I have attached the workbook which contains the usage of the command`DiscreteConvolve` and the convolving variables I have used are \xi and \eta.

What would be right way to perform a convolution for these terms? Are there any gotchas which I need to be aware of ?

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/46255f17-ad81-4f02-b458-88fda7e1c79a)

---

<div class="post-metadata">

**Author:** ![robertnowak](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/robertnowak/32/35992_2.png) [@robertnowak](https://community.wolfram.com/u/robertnowak)\
**Post date:** [May 16, 2024, 11:46am UTC](https://community.wolfram.com/t/what-would-the-right-approach-to-perform-a-2d-discrete-convolution-for-this-problem/23999/2 "2024-05-16T11:46:13Z")

</div>

You are not talking about the discrete convolution.  
In Mathematica the discrete convolution is performed by ListConvolve.

You might try to tabulate your functions over some discrete x / y region an then in deed perform a discrete convolution via ListConvolve.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [May 16, 2024, 12:00pm UTC](https://community.wolfram.com/t/what-would-the-right-approach-to-perform-a-2d-discrete-convolution-for-this-problem/23999/3 "2024-05-16T12:00:08Z")

</div>

It seems that you are attempting a continuous convolution, not a discrete one. For lack of an `NConvolve`, you may try something like this:

```
cnvlv[x_?NumericQ, y_?NumericQ] :=
  NIntegrate[f[\[Xi], \[Eta]] DiffG[x - \[Xi], y - \[Eta]],
   {\[Xi], -Infinity, Infinity},
   {\[Eta], -Infinity, Infinity}];
cnvlv[5, 1]

```
