Przemek Klosowski <przemek.klosowski at nist.gov> writes:
> On 11/27/2012 08:59 AM, Hans W. Hofmann wrote:
>> why we do not get a handsome answer
Handsome, like beauty, is in the eye of the beholder.
>>
>>>> (%o2) %union([x = - 2], [x = 1])
>>
>> what should I do with %union()...? I want to handle the return as usual...
What is the definition of usual? Do you mean you want a list of
solutions, like with solve? Well, you have a list of solutions, it's just
a fancy list with some simplification properties that Barton outlined in
an earlier post.
>
> I think you are looking for individual solutions, which you can get via
> first(%o2) and then continue on by doing e.g. first(rest(%o2)). I
> actually don't know the details of %union implementation---those are the
> two things I just tried and they worked (after trying to index %o2, and
> trying things like car/cdr).
Almost everything in Maxima is a list. An easy way to create a list that
is not a []-delimited list is to make the list elements the arguments of
an undefined Maxima function. To convert the list to a []-delimited
list, use args:
(%i2) %solve(x^2=1,x);
(%o2) %union([x = - 1], [x = 1])
(%i3) args(%);
(%o3) [[x = - 1], [x = 1]]
One can define one's own handsome %solver by composing %solve and args.
>
> How would one go about finding out things like that systematically? i.e.
> where should one look for the explanation of a maxima construct one
> might see in someone else's code, such as %union()?
This is not a direct answer, but...
You can access the lisp reader via :lisp from the Maxima top-level. So,
you can see what the underlying lisp object is via
(%i4) :lisp $%o2
(($%UNION SIMP) ((MLIST SIMP) ((MEQUAL SIMP) $X -1))
((MLIST SIMP) ((MEQUAL SIMP) $X 1)))
(the Maxima symbol x is interned as $X in lisp)
--
Leo Butler <l_butler at users.sourceforge.net>
SDF Public Access UNIX System - http://sdf.lonestar.org