how to substitute known values



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
>>
>
>