A inconsistency with maplist (or with my understanding of maplist).
Subject: A inconsistency with maplist (or with my understanding of maplist).
From: Jaime Villate
Date: Tue, 09 Jul 2013 10:51:39 +0100
On 08-07-2013 15:17, Mark Skilbeck wrote:
> (%i188) maplist(identity, x/(x-2));
> (%o188) [x,x-2]
> (%i189) maplist(identity, x/(x-2)+1);
> (%o189) [x/(x-2),1]
>
> My initial belief was that maplist would map over the "terms" of the
> second input (the expression x/(x-2), etc.), although maybe my
> understand of what constitutes a "term" is wrong; however, the above
> doesn't play ball! I would've thought in the first example that I would
> receive [x/(x-2)].
>
> What am I missing?
Hi,
there is no inconsistency at all. In the first case, x/(x-2) is regarded
as a product between x and (x-2)^(-1); maplist will act on the two
elements x and (x-2)^(-1).
The second example, x/(x-2)+1, is regarded as a sum of the expression
x/(x-2) and the number 1. maplist acts on the two elements x/(x-2) and 1.
You can see how the expressions are stored internally in lisp using the
following syntax:
(%i1) :lisp #$x/(x-2)$;
((MTIMES SIMP) ((MEXPT SIMP) ((MPLUS SIMP) -2 $X) -1) $X)
(%i1) :lisp #$x/(x-2)+1$;
((MPLUS SIMP) 1 ((MTIMES SIMP) ((MEXPT SIMP) ((MPLUS SIMP) -2 $X) -1) $X))
See more details in section 37 of the manual:
http://maxima.sourceforge.net/docs/manual/en/maxima_37.html
Regards,
Jaime