MathGroup Archive 2000

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

Search the Archive

Re: define a new object or use the existing?

  • To: mathgroup at
  • Subject: [mg24377] Re: define a new object or use the existing?
  • From: zhl67 at
  • Date: Wed, 12 Jul 2000 23:13:17 -0400 (EDT)
  • References: <8k9irm$>
  • Sender: owner-wri-mathgroup at

In article <8k9irm$fqq at>,
  Maris =?iso-8859-1?Q?T=F5nso?= <maris at> wrote:
> Hi!
> I am trying to write a program which could handle noncommutative
> polynomials. A noncommutative polynomial has a form
> p(delta) = pn**delta^n + ... + p2**delta^2 + p1**delta + p0,
> where ** denotes noncommutative multiplication. I can not decide,
> is better way to represent an object pi**delta^i : to define
> rules for function NonCommutativeMulitply or to build a special new
> object on
> this purpose, for example  Twisted[pi,i].
> You will probably say that it depends on concrete circumstances or
> there is no difference in principle; but I still hope you can give
> comments
> on this problem.
> And the other problem: If I choose to build a new object when I would
> like object
> 	Twisted[p, n]
> in StandardForm to be printed as
> 	p delta^n.
> One way to get it is to use Format and Postfix:
> 	Format[Twisted[p_,n_]] := Postfix[{p}, delta^n ]
> But this solution does not satisfy me.
> I would like to know if there exists a elegant way to define the
> formatting for the object Twisted so that
> Twisted[p+q, n]  would printed as  (p+q) delta^n  (not p+q delta^n)
> Twisted[1, n]  would printed as  delta^n  (not 1 delta^n).
> Thanks for any advices.
> Maris Tonso
> Tallinn, Estonia

First Question: it DOES depends on how much you would your program to
do and which environment you would your program to work in. In fact I
would preferr to add new rules to the existing function
NonCommutativeMultiply if the program is assumed to be a general
purpose noncommutative polynomial program, and that it is not assumed
to work jointly with other existing programs of the same kind (e.g. the
NCAlgebra package from math source). However, if you wish your program
to work on top of NCAlgebra or any other packages which contains a lot
of additional rules for NonCommutativeMultiply, it is better to define
your new function!

Second Question: I would use MakeBoxes to do the job. Here is am
example (which I actually use for my noncommutative multiply function
which I named Diamond to take advantage of the built-in infix form

Diamond /: MakeBoxes[Diamond[x_, y___], TraditionalForm] :=
          If[Length[{y}] === 0, "",
             Seq["\[Diamond]",MakeBoxes[Diamond[y], TraditionalForm]]

Liu Zhao

Sent via
Before you buy.

  • Prev by Date: Re: Problem with antiderivtive of ArcSec
  • Next by Date: Q: print without linefeed
  • Previous by thread: Re: define a new object or use the existing?
  • Next by thread: Keeping Invisible Commas invisible