I want to use the Bessel function in C++. Since this one is not implemented there for complex arguments, I am looking for a way to express the bessel function(first and second kind) as:
$$J_n(x+iy)=f(x,y)+ig(x,y)$$
So I am looking for a way, to use further functions to express the bessel function for complex arguments only by using functions that take real arguments.
Has anybody an idea?
We have $$J_n(z) \equiv J_n(x+iy)=\Re J_n(x+iy)+i \Im J_n(x+iy)\\ = \frac{J_n(x+iy)+J_n(x-iy)}{2}+i \frac{J_n(x+iy)-J_n(x-iy)}{2} $$
From the power series definition, $$J_n(z)=\sum_{m=0}^\infty \frac{(-1)^m}{m!(m+n)!} \left( \frac{z}{2} \right)^{2m+n} $$ we get
$$\Re J_n(x+iy)= \sum_{m=0}^\infty \frac{(-1)^m}{m!(m+n)!} \frac{ \left( \frac{z}{2} \right)^{2m+n}+ \left(\frac{\bar{z}}{2} \right)^{2m+n}}{2}=\sum_{m=0}^\infty \frac{(-1)^m}{m!(m+n)!} \Re \left[ \left( \frac{z}{2} \right)^{2m+n} \right] $$
If we use the polar representation, where $z=r e^{i \theta}$ we find that the real part is: $$\Re J_n=\sum_{m=0}^\infty \frac{(-1)^m}{m!(m+n)!} \left( \frac{r}{2} \right)^{2m+n} \cos (2m+n) \theta$$ Similarly, one can see that the imaginary part is $$\Im J_n=\sum_{m=0}^\infty \frac{(-1)^m}{m!(m+n)!} \left( \frac{r}{2} \right)^{2m+n} \sin (2m+n) \theta$$
Since you are trying to implement this on C++ you could try taking $$f(x,y)=\sum_{m=0}^N \frac{(-1)^m}{m!(m+n)!} \left( \frac{r}{2} \right)^{2m+n} \cos (2m+n) \theta $$ and $$g(x,y)=\sum_{m=0}^N \frac{(-1)^m}{m!(m+n)!} \left( \frac{r}{2} \right)^{2m+n} \cos (2m+n) \theta$$ both with sufficiently large $N$.