A inconsistency with maplist (or with my understanding of maplist).
Subject: A inconsistency with maplist (or with my understanding of maplist).
From: Stavros Macrakis
Date: Fri, 12 Jul 2013 16:02:05 -0400
Your termsof function is just fine -- not sure why you're unhappy with it.
As for why the additive terms function isn't built-in, there are certainly
cases where it's useful to extract the additive terms of an expression, but
in general, it is useful to be able to extract the argument list of many
kinds of expression, including additions, multiplications, and arbitrary
function applications like f(a,b,c). args(...) and maplist(f,...) handle
the general case and can be used (as you did) to handle various special
cases.
For that matter, there are many different useful definitions of "additive
terms". For example, (x+1)*(y+1) can usefully be treated as having the
additive terms
(x+1)*(y+1) << just 1 additive term
(y+1)*x, y+1 << polynomial in x -- rat(...,y,x)
(x+1)*y, x+1 << polynomial in y -- rat(...,x,y)
x*y, x, y, 1 << fully expanded -- expand(...)
What exactly do you want to do with these additive terms?
-s
On Tue, Jul 9, 2013 at 6:28 AM, Mark Skilbeck <m at iammark.us> wrote:
> Hi, Jaime.
>
> Yeah, I gained a better understanding of how Maxima "sees" expressions
> after a discussion with a friend (it was taking some time for my email to
> get past the moderation queue), but I would've learned the same from you if
> I had been patient.
>
> Anyway, I came up with the following for getting a list of "terms" from an
> expression:
>
> termsof(exp):=if not atom(exp) and op(exp)="+" then args(exp) else [exp];
>
> I'm not convinced this is the best way to work with the terms of an
> expression (read: I think something like this ought to be native in Maxima,
> but what do I know?).
>
> Thanks for your reply,
> Mark.
>
>
> On 09/07/13 10:51, Jaime Villate wrote:
>
>> 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<http://maxima.sourceforge.net/docs/manual/en/maxima_37.html>
>>
>> Regards,
>> Jaime
>>
> ______________________________**_________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>
>