Hi,(adsbygoogle = window.adsbygoogle || []).push({});

I wrote a piece of MATLAB code to compute a double integral of the form:

[tex]

\int_{a}^{b}\int_{c}^{d}f(x,y)dxdy

[/tex]

I went about it using the trapezium rule, so what I did was apply the rule to the [itex]x[/itex] variable first to obtain:

[tex]

\int_{a}^{b}\int_{c}^{d}f(x,y)dxdy\approx\frac{\delta x}{2}\int_{c}^{d}2\sum_{i=1}^{N}f(x_{i},y)-f(a,y)-f(b,y)dy

[/tex]

I then went on to apply the trapezium rule in the [itex]y[/itex] variable to obtain:

[tex]

\begin{array}{rcl}

\int_{a}^{b}\int_{c}^{d}f(x,y)dxdy & = & \left(\sum_{i=1}^{N}\sum_{j=1}^{M}f(x_{i},y_{j})-\frac{1}{2}\sum_{i=1}^{N}f(x_{i},c)-\frac{1}{2}\sum_{i=1}^{N}f(x_{i},d)\right)\delta x\delta y \\

& - & \frac{1}{2}\left(\sum_{j=1}^{M}f(a,y_{j})-\sum_{j=1}^{M}f(b,y_{j})\right)\delta x\delta y \\

& - & \frac{1}{2}(f(a,c)+f(b,c)+f(a,d)+f(b,d))\delta x\delta y

\end{array}

[/tex]

I tried using this to compute the inverse Fourier transform of the 2d Gaussian and I got some rather bad results.

I include the results. Not what I expected.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Numerical computation of double integral

**Physics Forums | Science Articles, Homework Help, Discussion**