Wildcards for subs()

Do Hoang Son dhson at thep.physik.uni-mainz.de
Wed May 23 12:48:35 CEST 2001


On Tue, 22 May 2001, Christian Bauer wrote:

> Hi!
> 
> It has been suggested to me that it would be a desirable feature for subs()
> to be able to specify wildcards for indices and function arguments so you
> could, for example

Yes, I think most of users who are familiar with Mathematica are willing
to have this feature.

Cheers,
Son

>  - in "sin(x-1)+sin(2*y)", substitute sin(?) by cos(?)/2 to get
>    "cos(x-1)/2+cos(2*y)/2"
>  - in "atan2(x+y,z^2)", substitute atan2(?1,?2) by ?2/?1 to get
>    "z^2/(x+y)"
>  - in "F.mu*g.nu.rho+F.nu*g.mu.rho", substitute F.? by a.?+b.? to get
>    "(a.mu+b.mu)*g.nu.rho+(a.nu+b.nu)*g.mu.rho"
> 
> This should be relatively easy to implement by extending indexed::subs() and
> function::subs() and adding a new "wildcard/wild" class that has an integer
> member to distinguish multiple wildcards. Function substitution would then
> go something like
> 
>   e.subs(atan2(wild(1), wild(2)) == wild(2)/wild(1));
> 
> and substitution of base expressions of indexed objects is similar:
> 
>   e.subs(indexed(wild(), mu) == indexed(wild(), mu)/2+indexed(A, mu));
> 
> Wildcards for indices are a little more involved because indices must be of
> class idx, so one would have to write
> 
>   e.subs(indexed(F, varidx(wild(), 4)) ==
>          indexed(a, varidx(wild(), 4)) + indexed(b, varidx(wild(), 4)));
> 
> which is a little clumsy but has the advantage of taking index dimensions
> and variance into account (this can also be a disadvantage because it could
> only substitute F~mu, not F.mu).
> 
> Any comments/suggestions?
> 
> Bye,
> Christian
> 
> -- 
>   / Coding on PowerPC and proud of it
> \/ http://www.uni-mainz.de/~bauec002/
> 




More information about the GiNaC-devel mailing list