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 13:35:13 -0400
On Thu, Jun 12, 2008 at 12:53 PM, Richard Fateman
<fateman at cs.berkeley.edu> wrote:
> 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
Currently, rectform(expr) is precisely equal to
realpart(expr)+%i*imagpart(expr) and polarform(expr) should be (see
below) precisely equal to cabs(expr)*%e^(%i*carg(expr)). These seem
like reasonable definitions to me.
As it happens, there is a bug in cabs: cabs(exp(%i)) => sqrt(sin(1)^2+cos(1)^2)
This can be corrected by redefining $cabs:
(defun $cabs (xx) (cabs xx))
I do not know who introduced the current strange definition of $cabs;
I'm pretty sure it was not in the original.
-s