|
[Date Index]
[Thread Index]
[Author Index]
Re: Preventing Times[x,x] from becoming Power[x,2]
- To: mathgroup at smc.vnet.net
- Subject: [mg53717] Re: Preventing Times[x,x] from becoming Power[x,2]
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Mon, 24 Jan 2005 03:37:54 -0500 (EST)
- Organization: The University of Western Australia
- References: <csqs3u$1te$1@smc.vnet.net> <csvi83$asl$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <csvi83$asl$1 at smc.vnet.net>,
David Bailey <dave at Remove_Thisdbailey.co.uk> 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
operator.
Cheers,
Paul
--
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 physics.uwa.edu.au
AUSTRALIA http://physics.uwa.edu.au/~paul
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]
|