On 2/2/09, Barton Willis <willisb at unk.edu> wrote:
> In part, I was looking at all this because I was thinking about
> substitutions into Maxima conditionals:
>
> (%i6) '(if x < 1 then 5 else 1/x)$
> (%i7) subst(x=0,%); Division by 0
>
> In the new to_poly_solver (CVS only), there is a simplifying
> conditional %if. I started thinking about squeezing some code into
> sublis to make sublis work for conditionals, but the source for sublis is
> recondite. Of course, it's tempting to take the easy path: ditch the
> complexity (and the oddball option variable sublis_apply_lambda) and
> start from scratch and use the CL function sublis. Already, subst and
> sublis have too many differences...
Barton, although it is tempting to just punt to SUBLIS, I think
the differences between subst and sublis are confusing, and just
calling SUBLIS wouldn't change that.
I think the only useful difference between subst and sublis is that
subst substitutes iteratively while sublis substitutes in parallel.
The name sublis doesn't suggest that, I think subst_parallel is better.
I'll suggest at this point to rename sublis to subst_parallel and aside
from parallel substitution to make it work like subst as much as possible.
About substitution into conditional expressions, I don't recommend
modifiying subst or sublis to handle them. A new function specifically
to substitute into such expressions would be OK I guess. But maybe
evaluating the expression with the variables of interest bound to
specific values would have the desired effect (because the code
for evaluating conditionals already ignores branches not taken).
e.g. foo : if x > 0 then 1/x else foo0; ev(foo, x = 0);
or: ev(foo, x = 1);
There may be some opposition to using ev in this way, but I don't
see how to get the desired effect with subst or sublis.
best
Robert Dodier