Complex integral using matlab

MATLAB

Let $f(s)$ be a function. I would like to compute the following integral using Matlab

$$
I=\int_{c-i\infty}^{c+i\infty}f(s)s^{-s}ds.
$$

How can we use Matlab to evaluate this integral.
Is the following notation convenient :

syms s x
int(f,x,c-i\infty+c,c+i\infty) ?

Thanks

Best Answer

You aren't allowed to use $\infty$ (which is "inf" with Matlab) in such a case.

You have to replace it by a large enough number.

Here is the right way to do it, through an example (which is in fact classical)

clear all;close all;format long
a=rand;
f=@(z)(exp(z.^2));
I=integral(f,a-i*1000,a+i*1000)
J=i*sqrt(pi)
% theoretical result : I = J whatever the value of a
% practical result : I and J coincide up to the 15th decimal place !
Related Question