realpart strangeness, was: besselarray bug, was: Bessel plotting problem
Subject: realpart strangeness, was: besselarray bug, was: Bessel plotting problem
From: Richard Fateman
Date: Thu, 12 Jun 2008 09:53:44 -0700
Seems to me that realpart should operate only on constants that look like
<realnumber> + <realnumber>*%i.
rectform is another functionality, trying to obtain <evaluable-to-a-real>
+<evaluable-to-a-real>*%i
coeff(expression,%i) will work for some things, but its semantics are not
the same as realpart.
my 2 cents.
RJF
_____
From: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu]
On Behalf Of Stavros Macrakis
Sent: Thursday, June 12, 2008 9:24 AM
To: Robert Dodier
Cc: Maxima List
Subject: Re: [Maxima] realpart strangeness, was: besselarray bug,was: Bessel
plotting problem
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
<http://sourceforge.net/tracker/index.php?func=detail&aid=1238141&group_id=4
933&atid=104933> &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