I am trying to understand how Mathematica handles the Integral with complex limits.
NIntegrate[Exp[Sin[y]], {y, I, 2}] How does NIntegrate works for this limits?
You can use EvaluationMonitor to see what points were sampled:
{res,data}=Reap[NIntegrate[Exp[Sin[y]],{y,I,2},EvaluationMonitor:>Sow[y]]]; Here is a plot of the data showing that NIntegrate uses a straight line contour:
Graphics[{PointSize[Large],Red,Point@@ReIm@data},Axes->True,AxesLabel->{Re,Im}] Compare this to choosing a different contour:
{res,data}=Reap[NIntegrate[Exp[Sin[y]], {y, I, I+2, 2}, EvaluationMonitor:>Sow[y]]]; Graphics[{PointSize[Large],Red,Point@@ReIm@data},Axes->True,AxesLabel->{Re,Im}]
Iand ending in2. $\endgroup$