MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Replace expressions

  • To: mathgroup at
  • Subject: [mg7688] Re: Replace expressions
  • From: Stephen P Luttrell <luttrell at>
  • Date: Sun, 29 Jun 1997 22:17:23 -0400 (EDT)
  • Organization: Defence Research Agency
  • Sender: owner-wri-mathgroup at

Hans Steffani wrote:
> hans.steffani at (Hans Steffani) writes:
> >I want to replace all expressions
> >Dot[a, xx]
> >Dot[xx, a]
> >for certain as by
> >Times[a,xx].
> To say it in other words
> I have a list certainas, which contains a number of symbols.
> This symbols are scalars and therefore I am allowed to substitute
> Dot[a,b] by Times[a,b] if a or b is in the list certainas.
> How can this be done.

Here is an example of how to solve this problem:

(1) Define a pair of assignments for simplifying expressions
of the form Dot[a_,xx] and Dot[xx,a_], provided that a is a member
of the list certainas (^:= is used rather than := in order to
associate the assignment with xx rather than Dot; this is a
matter of taste):

Dot[a_,xx]^:=a xx/;MemberQ[certainas,a];
Dot[xx,a_]^:=a xx/;MemberQ[certainas,a];

(2) Define an example list to work with:


(3) See whether the substitutions are made correctly in some specific

The following input:





produces the following output:

a1 xx

a2 xx



which is what was expected, given the chosen elements of certainas.


Dr Stephen P Luttrell                  luttrell at
Adaptive Systems Theory                01684-894046 (phone)
Room EX21, Defence Research Agency     01684-894384 (fax)           
Malvern, Worcs, WR14 3PS, U.K.

  • Prev by Date: problem of notebook in 16bit X server
  • Next by Date: Re: How to close down the front end from a 3.0 notebook ?
  • Previous by thread: Re: Replace expressions
  • Next by thread: Seeking Mma docs for NeXT computers