unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Non-Commutative calculations in Calc, Revisited
@ 2005-10-04 21:23 Neon Absentius
  0 siblings, 0 replies; 11+ messages in thread
From: Neon Absentius @ 2005-10-04 21:23 UTC (permalink / raw)


When in non-commutative (aka `matrix') mode calc calculates 
(a b)^-1 to be a^-1 b^-1 instead of the correct b^-1 a^-1.

Actually there is a more general bug.  It calculates (a b)^n 
to be a^n b^n.  I think this rule should be removed when a and 
be don't commute.  Furthermore a special rule should be included 
that deals with the case n=-1. 

-- 
Everyone is so overwhelmed by the hospitality. And so many of the
people in the arena here, you know, were underprivileged anyway, so
this--this (she chuckles slightly) is working very well for them.
     -- Barbara Bush, about the refugees from New Orleans.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
       [not found] <mailman.9745.1128461080.20277.help-gnu-emacs@gnu.org>
@ 2005-10-06 13:16 ` Jay Belanger
  2005-10-06 13:42   ` David Kastrup
  0 siblings, 1 reply; 11+ messages in thread
From: Jay Belanger @ 2005-10-06 13:16 UTC (permalink / raw)
  Cc: belanger


Neon Absentius <absent@sdf.lonestar.org> writes:

> When in non-commutative (aka `matrix') mode calc calculates 
> (a b)^-1 to be a^-1 b^-1 instead of the correct b^-1 a^-1.
>
> Actually there is a more general bug.  It calculates (a b)^n 
> to be a^n b^n.  I think this rule should be removed when a and 
> be don't commute.  Furthermore a special rule should be included 
> that deals with the case n=-1. 

Yes; you're right.
Fixes should be commited to cvs tomorrow afternoon at the latest.

Thanks,
Jay

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
  2005-10-06 13:16 ` Non-Commutative calculations in Calc, Revisited Jay Belanger
@ 2005-10-06 13:42   ` David Kastrup
  2005-10-06 16:17     ` Jay Belanger
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: David Kastrup @ 2005-10-06 13:42 UTC (permalink / raw)


Jay Belanger <belanger@truman.edu> writes:

> Neon Absentius <absent@sdf.lonestar.org> writes:
>
>> When in non-commutative (aka `matrix') mode calc calculates 
>> (a b)^-1 to be a^-1 b^-1 instead of the correct b^-1 a^-1.

Uh, what's correct about b^-1 a^-1?

Set a=[1,1], b=[1;0], then (a b)^-1 = [1], and neither b^-1 nor a^-1
exist.

This only works with a and b being square matrices.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
  2005-10-06 13:42   ` David Kastrup
@ 2005-10-06 16:17     ` Jay Belanger
  2005-10-06 18:23       ` Neon Absentius
  2005-10-06 18:01     ` Neon Absentius
       [not found]     ` <mailman.10119.1128621714.20277.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 11+ messages in thread
From: Jay Belanger @ 2005-10-06 16:17 UTC (permalink / raw)
  Cc: belanger

David Kastrup <dak@gnu.org> writes:

> Jay Belanger <belanger@truman.edu> writes:
>
>> Neon Absentius <absent@sdf.lonestar.org> writes:
>>
>>> When in non-commutative (aka `matrix') mode calc calculates 
>>> (a b)^-1 to be a^-1 b^-1 instead of the correct b^-1 a^-1.
>
> Uh, what's correct about b^-1 a^-1?
>
> Set a=[1,1], b=[1;0], then (a b)^-1 = [1], and neither b^-1 nor a^-1
> exist.
>
> This only works with a and b being square matrices.

Oops; you're right.
Of course, the proper fix will no longer give the general
non-commutative operations that Neon wants to work with.  Perhaps a
square matrix option should be made to the Calc matrix modes.

Jay

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
  2005-10-06 13:42   ` David Kastrup
  2005-10-06 16:17     ` Jay Belanger
@ 2005-10-06 18:01     ` Neon Absentius
  2005-10-07  0:47       ` Neon Absentius
       [not found]       ` <mailman.10168.1128646105.20277.help-gnu-emacs@gnu.org>
       [not found]     ` <mailman.10119.1128621714.20277.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 11+ messages in thread
From: Neon Absentius @ 2005-10-06 18:01 UTC (permalink / raw)


On Thu, Oct 06, 2005 at 03:42:40PM +0200, David Kastrup wrote:
> Jay Belanger <belanger@truman.edu> writes:
> 
> > Neon Absentius <absent@sdf.lonestar.org> writes:
> >
> >> When in non-commutative (aka `matrix') mode calc calculates 
> >> (a b)^-1 to be a^-1 b^-1 instead of the correct b^-1 a^-1.
> 
> Uh, what's correct about b^-1 a^-1?
> 
> Set a=[1,1], b=[1;0], then (a b)^-1 = [1], and neither b^-1 nor a^-1
> exist.
> 
> This only works with a and b being square matrices.

Yes you are right.

However I am more interested in the case that there is a *globally*
defined associative multiplication and I am using the matrix mode as a
"poor man's no-commutative algebra mode".  In this context my remark 
makes sence.  I still believe that there is a need for such a mode,
perhaps a "sub-mode" of the matrix mode where one assumes that all
matrices are square.  I am not sure how hard this is to implement.
What do you think Jay?
 
-- 
Everyone is so overwhelmed by the hospitality. And so many of the
people in the arena here, you know, were underprivileged anyway, so
this--this (she chuckles slightly) is working very well for them.
     -- Barbara Bush, about the refugees from New Orleans.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
  2005-10-06 16:17     ` Jay Belanger
@ 2005-10-06 18:23       ` Neon Absentius
  0 siblings, 0 replies; 11+ messages in thread
From: Neon Absentius @ 2005-10-06 18:23 UTC (permalink / raw)


On Thu, Oct 06, 2005 at 11:17:09AM -0500, Jay Belanger wrote:

> Of course, the proper fix will no longer give the general
> non-commutative operations that Neon wants to work with.  Perhaps a
> square matrix option should be made to the Calc matrix modes.

Yes, I think that's a good idea.  I proposed something similar
in my responce to David.

-- 
Everyone is so overwhelmed by the hospitality. And so many of the
people in the arena here, you know, were underprivileged anyway, so
this--this (she chuckles slightly) is working very well for them.
     -- Barbara Bush, about the refugees from New Orleans.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
  2005-10-06 18:01     ` Neon Absentius
@ 2005-10-07  0:47       ` Neon Absentius
       [not found]       ` <mailman.10168.1128646105.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Neon Absentius @ 2005-10-07  0:47 UTC (permalink / raw)


On Thu, Oct 06, 2005 at 06:01:13PM +0000, Neon Absentius wrote:
> On Thu, Oct 06, 2005 at 03:42:40PM +0200, David Kastrup wrote:
> > Jay Belanger <belanger@truman.edu> writes:
> > 
> > > Neon Absentius <absent@sdf.lonestar.org> writes:
> > >
> > >> When in non-commutative (aka `matrix') mode calc calculates 
> > >> (a b)^-1 to be a^-1 b^-1 instead of the correct b^-1 a^-1.
> > 
> > Uh, what's correct about b^-1 a^-1?
> > 
> > Set a=[1,1], b=[1;0], then (a b)^-1 = [1], and neither b^-1 nor a^-1
> > exist.
> > 
> > This only works with a and b being square matrices.
> 
> Yes you are right.
> 

OTH, now that I thought litle bit about it, there is a way in which my statement 
makes sence even for non-square matrices.  Here is the general setting:

Let (C,*) be a set with a partially defined associative multiplication
(called composition) such that each element has a left and a right
identity element (such a structure is usually known as a "category").
The set of all matrices satisfy these conditions.  Assume that for two
composable elements a,b the composition a*b has an (bi-sided) inverse
(ab)^-1.  Then a has a *right* inverse a^-1 and b has a *left* inverse
b^-1 and the identity

  (ab)^-1 = b^-1a^-1

holds.

Proof:  Since ab(ab)^-1 = (ab)^-1 ab = 1 we can take a^-1 = b(ab)^-1 
        and b^-1 = (ab)^-1 a.  Then 
 	
	   b^-1 a^-1 = [(ab)^-1 a] [b (ab)^-1]
	             = (ab)^-1,  by associativity.

	It is also straightforward to check that all elements that I composed 
	are indeed composable. QED

I leave it as an exersise to find a^-1 and b^-1 for your example :)).

I am not sure it is a good idea to implement the rule in general
though.  In any case I do think that is a good idea to have a command
that assumes that all variables are square matrices or, in the
abstract language, that any two elements are composable.  Of course
being square matrices, the variables will have more properties, eg
determinats etc. That might also be useful in some cases.

--
 There is no national science just as there is no national
multiplication table; what is national is no longer science.
         -- Anton Checov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
       [not found]         ` <wi7jcqt9ep.fsf@dms.auburn.edu>
@ 2005-10-07  2:15           ` Neon Absentius
       [not found]           ` <mailman.10178.1128651397.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Neon Absentius @ 2005-10-07  2:15 UTC (permalink / raw)


On Thu, Oct 06, 2005 at 08:15:10PM -0500, Luc Teirlinck wrote:
>     In any case I do think that is a good idea to have a command
>     that assumes that all variables are square matrices or, in the
>     abstract language, that any two elements are composable.
> 
> As I already pointed out in my follow-up, does `Meta-N m v' not do that?
> (It assumes that all matrices are N by N square matrices.)
> I am not sure whether my follow-up actually got posted, which is why I
> am using email now.
> 

Yes indeed assuming that all matrices are square matrices *of a given
size* does solve the problem of "poor man's non-commutative mode".
And there we can safely use the rule about the inverse of a product.
Thanks for pointing this out and for taking the extra pain to email me
about it so that I can take the message for sure!

BTW my statement that you quoted as it stands it's not true: even if
we assume that all matrices are square still we cannot necessarily
compose them unless they have the same dimensions!

Still it might be usefull to have an assmption that all variables are
square matrices of *unspecified* dimension.

PS. I reply in the group/list since it is not sure whether your post
    will eventually show up.

> Sincerely,
> 
> Luc.

-- 
 There is no national science just as there is no national
multiplication table; what is national is no longer science.
         -- Anton Checov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
       [not found]     ` <mailman.10119.1128621714.20277.help-gnu-emacs@gnu.org>
@ 2005-10-07  3:59       ` Jay Belanger
  2005-10-07 21:31         ` Jay Belanger
  0 siblings, 1 reply; 11+ messages in thread
From: Jay Belanger @ 2005-10-07  3:59 UTC (permalink / raw)
  Cc: belanger


Neon Absentius <absent@sdf.lonestar.org> writes:
...
> However I am more interested in the case that there is a *globally*
> defined associative multiplication and I am using the matrix mode as a
> "poor man's no-commutative algebra mode".  In this context my remark 
> makes sence.  I still believe that there is a need for such a mode,
> perhaps a "sub-mode" of the matrix mode where one assumes that all
> matrices are square.  I am not sure how hard this is to implement.
> What do you think Jay?

It shouldn't be hard.

[from a different message]
> BTW my statement that you quoted as it stands it's not true: even if
> we assume that all matrices are square still we cannot necessarily
> compose them unless they have the same dimensions!

Right, but that's not a problem in Calc.  Similar to how you can't add
matrices A and B unless they're the same size, but in matrix mode the
user can still enter `a+b' and Calc treats it as if it makes sense;
it's implicitly assumed then that they're appropriate sizes.

> Still it might be usefull to have an assmption that all variables are
> square matrices of *unspecified* dimension.

Yes.

Jay

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
       [not found]           ` <mailman.10178.1128651397.20277.help-gnu-emacs@gnu.org>
@ 2005-10-07  7:26             ` David Kastrup
  0 siblings, 0 replies; 11+ messages in thread
From: David Kastrup @ 2005-10-07  7:26 UTC (permalink / raw)



Neon Absentius <absent@sdf.lonestar.org> writes:

> BTW my statement that you quoted as it stands it's not true: even if
> we assume that all matrices are square still we cannot necessarily
> compose them unless they have the same dimensions!

You can safely assume that except when the expression is invalid to
start with, in which case it does not really matter much what happens
to it.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Non-Commutative calculations in Calc, Revisited
  2005-10-07  3:59       ` Jay Belanger
@ 2005-10-07 21:31         ` Jay Belanger
  0 siblings, 0 replies; 11+ messages in thread
From: Jay Belanger @ 2005-10-07 21:31 UTC (permalink / raw)



Jay Belanger <belanger@truman.edu> writes:
...
>> Still it might be usefull to have an assmption that all variables are
>> square matrices of *unspecified* dimension.

Now (with the current CVS Emacs), (a*b)^n will not be rewritten as
a^n*b^n if a and b are matrices (such as in matrix mode), although
(a*b)^-1 will become b^-1*a^-1 if a and b are known to be square
matrices. 
Also, while calling matrix mode with `C-u N m v' will result in an NxN
matrix mode, calling it with `C-u m v' will result in a square matrix mode,
as suggested above.
The documentation has not been updated yet.
Also, I've noticed some previously existing problems which will be
fixed soon; such as if a variable is set to a matrix, Calc doesn't
recognize the variable itself as being a matrix while doing
calculations. 

Jay

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-10-07 21:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.9745.1128461080.20277.help-gnu-emacs@gnu.org>
2005-10-06 13:16 ` Non-Commutative calculations in Calc, Revisited Jay Belanger
2005-10-06 13:42   ` David Kastrup
2005-10-06 16:17     ` Jay Belanger
2005-10-06 18:23       ` Neon Absentius
2005-10-06 18:01     ` Neon Absentius
2005-10-07  0:47       ` Neon Absentius
     [not found]       ` <mailman.10168.1128646105.20277.help-gnu-emacs@gnu.org>
     [not found]         ` <wi7jcqt9ep.fsf@dms.auburn.edu>
2005-10-07  2:15           ` Neon Absentius
     [not found]           ` <mailman.10178.1128651397.20277.help-gnu-emacs@gnu.org>
2005-10-07  7:26             ` David Kastrup
     [not found]     ` <mailman.10119.1128621714.20277.help-gnu-emacs@gnu.org>
2005-10-07  3:59       ` Jay Belanger
2005-10-07 21:31         ` Jay Belanger
2005-10-04 21:23 Neon Absentius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).