MathGroup Archive 1997

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

Search the Archive

Re: Q: About constants inside Distribute

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9237] Re: [mg9187] Q: About constants inside Distribute
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Fri, 24 Oct 1997 01:00:51 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

sergio at scisun.sci.ccny.cuny.edu (Sergio Rojas) [mg9187] Q: About
constants inside Distribute

asks why we get

rule = Dot[s___,(k:(a[i_]))m___, r___]:> k Dot[s,m,r]

        f = O1*a[1] + O2*a[2]
        g = P1*a[3]*a[1]
        h = O2*a[3]

Distribute[f.g.h]//.rule

    2
a[1]  a[3] O1 . P1 . a[3] . O2 + a[1] a[2] a[3] O2 . P1 . a[3]. O2


with the a[3] not stripped out by the rule.

The problem is seems to lie in

MatchQ[a , a m___]
	False
	
When we would expect matches like
	a ~ a 1 ~ a Times[] ~ a Times[___].

I'm not clear about what is happening here but a work-around is use  
default values

MatchQ[a,a m_.]	(*   note the dot m_.  *)
	
	True
	
and modify the rule to

rule2 = Dot[s___,(k:a[i_])m_., r___]:> k Dot[s,m,r]

Check:

Distribute[f.g.h]//.rule2

	a[1]^2*a[3]^2*O1 . P1 . O2 + a[1]*a[2]*a[3]^2*O2 . P1 . O2

Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK



  • Prev by Date: Re: Colored ListDensityPlot
  • Next by Date: Re: Re: Problems with Limit, Log, E
  • Previous by thread: Re: Q: About constants inside Distribute
  • Next by thread: Re: Q: About constants inside Distribute