I wish to find an expression for $\operatorname{Im}\left(\operatorname{erf}\left(u+i\frac{p \pi}{u}\right)\right)$ that I can integrate over $u$ in some more complicated integral, with $p$ a positive integer and $u$ a non-negative real. The general expression $\operatorname{Im}(\operatorname{erf}(x+iy)) = \frac{\operatorname{erf}(x+iy) - \operatorname{erf}(x-iy)}{2i}$ is unfortunately not helpful for me. I know that such a reformulation is not generally possible, but I'm optimistic since the following equations simplify greatly in the case at hand.
It's easy to show that $$\operatorname{Im}\left(\operatorname{erf}\left(u+i\frac{p \pi}{u}\right)\right) = \frac {2} {\sqrt{\pi}}e^{-u^2} \int_0^\frac{p\pi}{u} e^{t^2} \cos(2ut) dt$$ Looking up the integral in tables always leads back to the original error function, so we use the series expansion of $e^x$: $$ \int_0^\frac{p\pi}{u} e^{t^2} \cos(2ut) dt = \sum_{n=0}^\infty\frac 1 {n!} \int_0^\frac{p\pi}{u} t^{2n} \cos(2ut) dt = \sum_{n=0}^\infty a_n$$ Though there is a general solution to the integral, we break it up to apply cancellations due to the parameters. This yields the recursive sequence: $$a_{n+1} = \frac 1 {2u^2} \left( \frac {\left(\frac{p\pi}u\right)^{2n+1}}{n!} - (2n+1)a_n\right), a_0=0$$ and its explicit form $$a_n = \frac {(-1)^a} {2 p\pi u} \frac{(2a)!}{2^{2a}a!} \sum_{k=0}^n (-1)^k \frac{(2p \pi)^{2k}}{(2k)!}k$$ which is interesting since $\sum_{k=0}^\infty (-1)^k \frac{(2p \pi)^{2k}}{(2k)!}k = -p\pi \sin(2p\pi)=0$. (That's how $\lim_\limits{n \to \infty}a_n=0$ despite the factor $\frac{(2a)!}{a!}$, though I couldn't prove that.) I have observed that $a_n > 0$ (again, couldn't prove it).
Unfortunately, neither of those forms allowed me to make progress regarding $\sum_{n=0}^\infty a_n$. I tried approaching the recursive form using the generating function $$ A(x)= \sum_{k=0}^\infty a_n x^{2k+1}$$ but $A(x)$ turned out to be (practically) my original error function. I also changed the order of summation in the explicit form, but to no avail.
Can someone suggest a different approach to $\sum_{n=0}^\infty a_n$? I have tried everything I could come up with, but it never produced something simpler than the above.
Apologies: this intended comment was too long to submit as such.
I'm not saying that what you wrote down for $\operatorname{Im}(\operatorname{erf}(x+iy)) = \frac{\operatorname{erf}(x+iy) - \operatorname{erf}(x-iy)}{2i}$ is incorrect, but it is not compatible with the published definition for complex error function that I am familiar with. I'm referring to paragraph 7.1.29 in Abramowitz and Stegun, Handbook of Mathematical Functions, Dover, 1965. This contains an infinite series. I have programmed this function and used it frequently. It's very complicated and lengthy and would take a very long time just to put it in MathJax format. I suggest that you get this reference. In addition, Table 7.9 has tabulations that you can compare results with.