psubst appears to be undocumented, so there is no specification of what it
*should* do. I'm just describing what it *does* do.
I can think of various possible specifications:
* Leave behavior unspecified in cases like this (implementation-defined)
* Bottom-up (smallest match wins)
* Top-down (biggest match wins)
* Left-to-right (first match wins)
* Throw an error if there is an ambiguity
SInce subst doesn't have wildcards and doesn't do anything clever about
associative and commutative operators, we at least don't need to worry about
overlapping cases like
psubst( [x*y=3,y*z=5,x*z=7], x*y*z ) NOT an issue...
-s
On Thu, Apr 7, 2011 at 12:36, Robert Dodier <robert.dodier at gmail.com> wrote:
> Can you explain the reasoning here?
> I don't understand why f and x are substituted separated rather
> than together, since f(x) is one of the left hand sides in the
> list of substitution equations.
>
> best
>
> Robert Dodier
>
> On 4/7/11, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> > Corrigendum: g(3) is in fact a parallel substitution, and is what psubst
> > currently returns in this case.
> >
> > On Wed, Apr 6, 2011 at 10:02, Stavros Macrakis <macrakis at alum.mit.edu
> >wrote:
> >
> >> What should psubst( [x=3,f(x)=5,f(3)=10, f=g], f(x) ) be? Should it be
> >> f(3) or 5 or g(x)? Should psubst try to find the maximal match? I
> don't
> >> think that's currently part of its specification.
> >>
> >> Presumably not 10 or g(3), which would require sequential (not parallel)
> >> substitutions.
> >>
> >> Both 'subst' and 'psubst' are very basic *syntactic* operations. It is
> >> correct (and useful) behavior that subst([y=x],'diff(y,t)) =>
> 'diff(x,t).
> >>
> >> 'at' is supposed to be the *semantic* substitution operation, but it can
> >> be
> >> very clumsy to use and it is not very powerful. In the present case,
> you
> >> might want to say something like
> >>
> >> at('diff(x,t),[x=3,'at('diff(x,t),x=3)=5])
> >>
> >> but that doesn't work.
> >>
> >> -s
> >>
> >> On Wed, Apr 6, 2011 at 09:14, Leo Butler <l.butler at ed.ac.uk> wrote:
> >>
> >>>
> >>>
> >>> On Wed, 6 Apr 2011, Barton Willis wrote:
> >>>
> >>> < -----Leo Butler <l.butler at ed.ac.uk> wrote: -----
> >>> <
> >>> < > I think the function you want is psubst.
> >>> < >
> >>> < > psubst([x=3, y=4, diff(x,t) = 5, diff(y,t)=7],
> >>> diff(sqrt(x^2+y^2),t));
> >>> < >
> >>> < > should do what you want.
> >>> <
> >>> < No, isn't the cure:
> >>> <
> >>> < (%i1) depends(x,t,y,t);
> >>> < (%o1) [x(t),y(t)]
> >>> <
> >>> < (%i2) psubst([x=3, y=4, diff(x,t) = 5, diff(y,t)=7],
> >>> diff(sqrt(x^2+y^2),t));
> >>> < (%o2) 0
> >>> <
> >>> < (%i3) psubst([diff(x,t) = 5, diff(y,t)=7,x=3, y=4],
> >>> diff(sqrt(x^2+y^2),t));
> >>> < (%o3) 43/5
> >>>
> >>> Well, I guess this is a bug, eh?
> >>>
> >>> Here is a slightly re-worked version of the example from the
> >>> documentation:
> >>>
> >>> (%i20) psubst ([a^2=b, b=a], sin(a^2) + cos(b));
> >>> (%o20) sin(b) + cos(a)
> >>> (%i21) psubst ([b=a, a^2=b], sin(a^2) + cos(b));
> >>> (%o21) sin(b) + cos(a)
> >>>
> >>>
> >>> Leo
> >>> --
> >>> The University of Edinburgh is a charitable body, registered in
> >>> Scotland, with registration number SC005336.
> >>>
> >>> _______________________________________________
> >>> Maxima mailing list
> >>> Maxima at math.utexas.edu
> >>> http://www.math.utexas.edu/mailman/listinfo/maxima
> >>>
> >>
> >>
> >
>