Re: Q: About constants inside Distribute

• To: mathgroup at smc.vnet.net
• Subject: [mg9230] Re: [mg9187] Q: About constants inside Distribute
• From: "C. Woll" <carlw at u.washington.edu>
• Date: Fri, 24 Oct 1997 01:00:45 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Sergio,

I don't understand why you are using triple blanks instead of single
blanks. Here's how I would implement a solution for your problem using
rules:

rule = {(k_a m_) . s_ :> k m . s, m_ . (k_a s_) :> k m . s}

You could also write definitions for a or Dot, so that a[i_] extraction
and distribution were automatic. For example,

Unprotect[Dot];
Clear[Dot];

(a[i_]^n_. c_) . d_ := a[i]^n (c . d) c_ . (a[i_]^n_. d_) := a[i]^n (c .
d)

b_Plus . c_ := Distribute[Unevaluated[b . c]] b_ . c_Plus :=
Distribute[Unevaluated[b . c]]

Protect[Dot]

With the above f . g . h would automatically be put in the form you
want.

Good luck

Carl Woll
Dept of Physics
U of Washington

On Tue, 21 Oct 1997, Sergio Rojas wrote:

>
> Hi guys,
>
>   	The rule:
>
>         	rule = Dot[s___,(k:(a[i_]))m___, r___]:> k Dot[s,m,r]
>
>        works fine separating constants (a[i_]) in the distribution of
>        a Dot product:
>
>         	f = O1*a[1] + O2*a[2]
>         	g = P1*a[3]
>         	h = O2*a[3]
>
> In[44]:= Distribute[f.g.h]//.rule
>
>                   2                         2 Out[44]= a[1] a[3]  O1 .
> P1 . O2 + a[2] a[3]  O2 . P1 . O2
>
>        However, the rule does not work if product of constants (
> a[i_]*a[j_] )
>        are included. For example, taking:
>
>         	g = P1*a[3]*a[1]
>
> In[45]:=  g = P1*a[3]*a[1]
>
> Out[45]= P1 a[1] a[3]
>
> In[46]:= Distribute[f.g.h]//.rule
>
>              2
> Out[46]= a[1]  a[3] O1 . P1 . a[3] . O2 + a[1] a[2] a[3] O2 . P1 . a[3]
> . O2
>
>
>   After playing with this for a while ( a big one ), I was unable to
> figure out what is going on and how to fix it. Could anybody point out
> some suggestions?
>
> Salut,
>
> Rojas
> E-mail: sergio at scisun.sci.ccny.cuny.edu
>
>
>

```

• Prev by Date: Re: Re: Help with findroot
• Next by Date: RE: Q: residual standard deviation
• Previous by thread: Q: About constants inside Distribute
• Next by thread: Re: Q: About constants inside Distribute