realpart strangeness, was: besselarray bug, was: Bessel plotting problem
Subject: realpart strangeness, was: besselarray bug, was: Bessel plotting problem
From: Stavros Macrakis
Date: Thu, 12 Jun 2008 12:24:13 -0400
On Thu, Jun 12, 2008 at 12:21 AM, Robert Dodier <robert.dodier at gmail.com>
wrote:
> The more serious is that realpart (and imagpart) assumes that any
> function it doesn;t recognize (which includes Bessel functions) is
> purely real. Yikes. Should return a noun expression in that case.
> This bug was reported before:
>
> http://sourceforge.net/tracker/index.php?func=detail&aid=1238141&group_id=4933&atid=104933
>
This is not a bug; realpart operates as designed. Whether the *design* is
good is another matter, and we may well want to revisit it.
Maxima in general assumes that all unknown quantities (functions and
variables) are real unless otherwise specified. Thus imagpart(x) => 0,
imagpart(f(x)) => 0, imagpart(f(%i)) => 0, etc. For *variables*, this has
proven to be a reasonable pragmatic decision, I think. This can be
overridden, variable-by-variable, using declare(var,complex). As it
happens, this also works for var as a function:
declare(ff,complex)$
imagpart(ff(x)) => 'imagpart(ff(x))
Unfortunately, this doesn't work for bessel_i -- *that* is a bug.
The assumption that all variables and functions are real could be changed in
various ways:
Maxima could assume that all variables and functions are complex unless
otherwise specified. This would, I suspect, be annoying in many cases, e.g.
imagpart(a+b*%i) => 'imagpart(a)+'realpart(b).
Maxima could assume that all variables are real, but unknown functions are
real for real arguments, which is of course untrue for many common built-in
functions like sqrt, asin, etc. -- so why should it be assumed for unknown
functions?: subst(asin,f,imagpart(f(x))) would not be the same as
asin(subst(asin,f,f(x))) and subst(%i,x,imagpart(f(x))) would not be equal
to imagpart(subst(%i,x,f(x))).
Probably the only consistent approach would be to assume that unknown
functions are always potentially complex, so rectform(f(x)) =>
'realpart(f(x)) + 'imagpart(f(x)). Is this going to make life easier or
harder for users? I don't know.
Discussion?
-s