Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Do I have to worry about "Left" division for matrices?

164 views
Skip to first unread message

Tyler

unread,
Dec 4, 2008, 7:17:21 AM12/4/08
to
Hello All:

I am currently in the process of rewriting some old code into
Mathematica. One of the things I've come across is the matrix
operation

A \ b

Which is defined as "left division." In other words (if I have this
right):

A \ b = inv(A)*b

and "right division" is

b / A = b*inv(A)

I guess my question is, does mathematica make the distinction between
left and right division, or is this more or less related to the
algorithm used by the solver (I am using numerical values by the way,
and not a symbolic solution)?

Cheers,

t.

Jens-Peer Kuska

unread,
Dec 5, 2008, 5:28:11 AM12/5/08
to
Hi,

if Mathematica would make a difference between row and column vectors
yes. Otherwise not.

AFAIK Mathematica implements none of the operators and it depend
on you to make the decision. Since b/A with a matrix would do a
component wise division and that is not what you want.

Regards
Jens

dh

unread,
Dec 5, 2008, 5:34:44 AM12/5/08
to

Hi,

The star operator "*" works element by elemet. The operator you want

is: Dot ".". It binds the leftmost index of the left operand and the

rightmost index of the right operand.

Therefore you would write:

Inverse[A].b for left division and

b.Inverse[A] for right division.

hope this helps, Daniel

Daniel Lichtblau

unread,
Dec 6, 2008, 6:13:12 AM12/6/08
to
Tyler wrote:
> Hello All:
>
> I am currently in the process of rewriting some old code into
> Mathematica. One of the things I've come across is the matrix
> operation
>
> A \ b
>
> Which is defined as "left division." In other words (if I have this
> right):
>
> A \ b = inv(A)*b
>
> and "right division" is
>
> b / A = b*inv(A)
>
> I guess my question is, does mathematica make the distinction between
> left and right division, or is this more or less related to the
> algorithm used by the solver (I am using numerical values by the way,
> and not a symbolic solution)?
>
> Cheers,
>
> t.

The (preferred) Mathematica equivalents would be LinearSolve[A,b] and
LinearSolve[Transpose[A],b] respectively.

Mathematica does not support an infix form of this sort of division, so
the immediate question is moot.

Daniel Lichtblau
Wolfram Research

hayes...@gmail.com

unread,
Dec 9, 2008, 6:57:19 AM12/9/08
to
Thanks for all of the help and clarification. I like Daniel's
solutionn best as it seems (to me at least) to be the most transparent
method. Nonetheless, I may do a quick Timing[] test on Inverse[A].b
versus LinearSolve[A,b] to see which performs best.

Cheers,

t.

jwme...@gmail.com

unread,
Dec 10, 2008, 4:46:28 AM12/10/08
to
On Dec 6, 6:13 am, Daniel Lichtblau <d...@wolfram.com> wrote:
>
> Mathematica does not support an infix form of this sort of division, so
> the immediate question is moot.

You can turn LinearSolve into an "infix division" using the infix
notation:

In[1]:= a ~LinearSolve~ b

Out[1]= LinearSolve[a, b]

Not suggesting that is a particularly practical thing to do, but
sometimes the infix notation is useful, for instance for ~Join~

Regards,

JM

dh

unread,
Dec 19, 2008, 7:23:34 AM12/19/08
to

Hi,

I just saw your reply. Please note that using Inverse[A] to solve

equations is numerically unstable. Use LinearSolve. Even "A\vec" in

your other language is only syntax. The real procedure does not directly

use the matrix inverse.

The simplest procedure to solve equations is Gauss Elimination.

hope this helps, Daniel

0 new messages