# [Maxima] Bessel function with imaginary argument

Schirmacher, Rolf Rolf.Schirmacher at MuellerBBM.de
Wed Jan 28 04:03:54 CST 2009

```Thanks for the fast and detailed reply.

> -----Original Message-----
> From: drdieterkaiser at web.de [mailto:drdieterkaiser at web.de]
> Sent: Tuesday, January 27, 2009 11:29 PM
> To: Schirmacher, Rolf
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] Bessel function with imaginary argument
>
>
> 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.
>

Somehow, I get different results. With a freshly started Maxima session, I
obtain

(%i1) facts(bessel_j);
(%o1) []
(%i2) realpart(bessel_j(1,%i));
(%o2) bessel_j(1,%i)
(%i3) imagpart(bessel_j(1,%i));
(%o3) 0
(%i4) declare(bessel_j,complex);
(%o4) done
(%i5) facts(bessel_j);
(%o5) [kind(bessel_j,complex)]
(%i6) realpart(bessel_j(1,%i));
(%o6) bessel_j(1,%i)
(%i7) imagpart(bessel_j(1,%i));
(%o7) 0

It does not depend on the previous usage of bessel_j:

(%i1) declare (bessel_j, complex);
(%o1) done
(%i2) facts(bessel_j);
(%o2) [kind(bessel_j,complex)]
(%i3) realpart(bessel_j(1,%i));
(%o3) bessel_j(1,%i)
(%i4) imagpart(bessel_j(1,%i));
(%o4) 0

Am I missing something?

> 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
>

Unfortunately, my "real" application is not as simple as the example above.
I am interested in the real / imaginary parts of some analytical expressions
including of course variables. Fortunately, there is some knowledge about
the domain of these variables. But for "mixed" expressions, the numerical
evaluation trick seems to be ineffective, it ends up with the symbolic
result:

(%i1) declare(x,real);
(%o1) done
(%i2) imagpart(bessel_j(1,%i*x));
(%o2) 0
(%i3) imagpart(bessel_j(1,%i*x)),numer;
(%o3) 0
(%i4) imagpart(bessel_j(1,%i)),numer;
(%o4) 0.56515910399249

For my actual problem, all I need (at the moment, at least) is bessel_j(0,z)
and bessel_j(1,z) for purely real and purely imaginary arguments z. Now,
according to A&S 9.1.10, the series for bessel_j(0,z) contains only even
powers of z, so it would be purely real for purely real or purely imaginary
arguments. The series for bessel_j(1,z) contains an additional factor z, so
it would be purely real for purely real z and purely imag for purely imag z.

How to tell Maxima?

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

I would highly appreciate this approach. I regard the risk of misleading
results for "naive" users to be very high - everything seems to work fine
but the results are wrong. Unsimplified results at least provide a clear
warning on the limited capabilities.
To add additional knowledge would be even more nice, but that is definitely
a second step.

Thanks

Rolf Schirmacher
```