Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Preventing Times[x,x] from becoming Power[x,2]

  • To: mathgroup at
  • Subject: [mg53717] Re: Preventing Times[x,x] from becoming Power[x,2]
  • From: Paul Abbott <paul at>
  • Date: Mon, 24 Jan 2005 03:37:54 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <csqs3u$1te$> <csvi83$asl$>
  • Sender: owner-wri-mathgroup at

In article <csvi83$asl$1 at>,
 David Bailey <dave at> wrote:

> Josef Karthauser wrote:
> > I was wondering whether anyone knows the answer to this one.
> > 
> > I've got a function, let's call it F[...]. If I enter F[s] F[s]
> > into mathematica it "simplifies" the resulting expression, making it
> > become Power[F[s],2].  Is there any way to prevent this automatic
> > simplification on F[] objects?
> > 
> > Joe
> Hi,
> The fact that you don't want that simplification to take place suggests 
> to me that you do not intend F[s]F[s] to mean ordinary multiplication. 
> In that case, it would be better to use one of the unassigned operators 
> (such as \[CircleTimes]) to represent 'not multiplication'. You 
> obviously will not get spurious simplifications, and you can define the 
> tru behaviour as you want.

Agreed. It is possible to have the implied multiplication interpreted as 
non-commutative multiplication. One way to do this is to use $Pre to 
replace Times by any operator that is not, by default, commutative. For 
example, here the CircleTimes operator is used.

 $Pre:= Function[x, ReleaseHold[Hold[x]/. Times -> CircleTimes], HoldAll]

Note that we have to hold the argument (Hold[x]) and that this pure 
function needs to be HoldAll so that its argument is not evaluated.

Next you need to add appropriate definitions to the (infix) CircleTimes 


Paul Abbott                                   Phone: +61 8 6488 2734
School of Physics, M013                         Fax: +61 8 6488 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at 

  • Prev by Date: Re: Numbers and their reversals
  • Next by Date: Re: compile / optimize
  • Previous by thread: Re: Preventing Times[x,x] from becoming Power[x,2]
  • Next by thread: Re: Preventing Times[x,x] from becoming Power[x,2]