Multifold integration with Matlab

95 views Asked by At

This question may seem silly but I cannot find a way to solve it by myself. I need to do some multifold integrations (at least four fold) whose range is infinite with Matlab, and I did not found any suitable functions.

For example, how should I do the following integral:

Integrate[f(x,y,z,w),{x,-\infty,\infty},{y,-\infty,\infty},{z,-\infty,\infty},{w,-\infty,\infty}]

where the function f may be defined as

f=1/(x-y)*1/(z-w)exp(-0.25(x^2+y^2+z^2+w^2))

In Matlab, sometimes one needs to add a dot behind the arguments so the function can be executed, which I am very confused about.

I appreciate if anyone could help.

1

There are 1 answers

4
Luis Mendo On

I assume you mean symbolic integration. For that

  1. Define your symbolic variables.
  2. Define your function of those symbolic variables.
  3. Apply int repeatedly to integrate with respect to each variable. This assumes the function satisfies the hypotheses of Fubini's theorem (which it does for your example function).

So:

>> syms x y z w                           %// step 1
>> f = exp(-x^2-y^2-z^2-w^2)              %// step 2
f =
exp(- w^2 - x^2 - y^2 - z^2)
>> F = f
F =
exp(- w^2 - x^2 - y^2 - z^2)
>> F = int(F,x,-inf,inf)                  %// step 3: x
F =
pi^(1/2)*exp(-w^2)*exp(-y^2)*exp(-z^2)
>> F = int(F,y,-inf,inf)                  %// step 3: y
F =
pi*exp(- w^2 - z^2)
>> F = int(F,z,-inf,inf)                  %// step 3: z
F =
pi^(3/2)*exp(-w^2)
>> F = int(F,w,-inf,inf)                  %// step 3: w
F =
pi^2