Re: Matrix Multiplication (with a twist)

• To: mathgroup at smc.vnet.net
• Subject: [mg69013] Re: Matrix Multiplication (with a twist)
• From: "sashap" <pavlyk at gmail.com>
• Date: Sat, 26 Aug 2006 04:40:03 -0400 (EDT)
• References: <ecmhcp\$9kl\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Bruce Colletti wrote:
> For matrix A = {{e,f},{g,h}} and B = {{a,b},{c,d}}, Mathematica returns their product
>
> A.B = {{ae+cf,be+df},{ag+ch,bg+dh}}
>
> However, I want to treat multiplication of numeric variables as noncommutative in order to instead obtain the result
>
> {{ea+fc, eb+fd},{ga+hc,gb+hd}}
>
> How would this be done in v5.2?  Thanks.
>
> Bruce

Hi Bruce,

try Inner:

In[1]:=
mA = {{e, f}, {g, h}};
mB = {{a, b}, {c, d}};

In[3]:=
Inner[NonCommutativeMultiply, mA, mB]

Out[3]=
{{e**a + f**c, e**b + f**d}, {g**a + h**c,
g**b + h**d}}

Oleksandr Pavlyk
Wolfram Research

```

• Prev by Date: Re: Erf[InverseErf] -- making a function and its inverse cancel
• Next by Date: Re: General--IF condition in Plot3D
• Previous by thread: Re: Matrix Multiplication (with a twist)
• Next by thread: Symmetric polynomials