# [Maxima] Bessel function with imaginary argument

Dieter Kaiser drdieterkaiser at web.de
Tue Jan 27 16:29:04 CST 2009

```Am Dienstag, den 27.01.2009, 22:41 +0100 schrieb Schirmacher, Rolf:
> Hello,
>
> I get the following strange result for bessel_j(1,z) with purely imaginary
> argument:
>
> First, try numerical evaluation:
>
> (%i127) bessel_j(1,1.0*%i);
> (%o127) 0.56515910399249*%i
> (%i128) realpart(bessel_j(1,1.0*%i));
> (%o128) 0
> (%i130) imagpart(bessel_j(1,1.0*%i));
> (%o130) 0.56515910399249
>
> This looks fine. Now, if I want to get the realpart / imagpart symbolically,
> it is wired:
>
> (%i131) realpart(bessel_j(1,1*%i));
> (%o131) bessel_j(1,%i)
> (%i132) imagpart(bessel_j(1,1*%i));
> (%o132) 0
>
> What am I doing wrong?

You are doing nothing wrong. At first Maxima does not evaluate the
expression bessel_j(1,%i) numerically.  Second, Maxima does not know
that bessel_j(n,z) is a complex valued function. Every unknown function
is assumed to be real valued. Therefore you get the "wrong" results for
the unsimplified noun form of the expression bessel_j(1,%i).

It is possible to declare the function to be complex. Then you get the
following:

(%i13) declare(bessel_j,complex);
(%o13) done
(%i14) realpart(bessel_j(1,%i));
(%o14) realpart(bessel_j(1, %i))
(%i15) imagpart(bessel_j(1,%i));
(%o15) imagpart(bessel_j(1, %i))

Maxima can not simplify realpart(bessel_j(1,%i)) to be zero. But the
results are not wrong.

If you introduce the number 1.0 Maxima does a numerical evaluation of
the expression. The result is a complex number which can be handled by
the Maxima functions realpart and imagpart:

(%i16) realpart(bessel_j(1,1.0*%i));
(%o16) 0
(%i17) imagpart(bessel_j(1,1.0*%i));
(%o17) 0.565159103992485

The numerical evaluation is done too when using the flag numer:

(%i18) realpart(bessel_j(1,%i)),numer;
(%o18) 0
(%i19) imagpart(bessel_j(1,%i)),numer;
(%o19) 0.565159103992485

It might be a good idea to give Maxima functions more known features
like 'complex. The results might be unsimplified, but more correct.

Dieter Kaiser

```