MathGroup Archive 2012

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

Search the Archive

Re: Implicit Times

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128658] Re: Implicit Times
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Wed, 14 Nov 2012 01:30:06 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121109000050.A731368E1@smc.vnet.net> <20121110070632.836E26951@smc.vnet.net> <k7p3di$c9h$1@smc.vnet.net>

On 11/11/2012 20:56, Dave Snead wrote:
> Thanks, but the issue is not defining the operator.
> The issue is Mathematica's implicit assumption of a Times (*) when there's a
> space between variables.
> The NonCommutativeMultiply (**) already exists.
>
> So when I input
> x y//FullForm
> I want Mathematica to return
> NonCommutativeMultiply[x,y]
> instead of
> Times[x,y]
>
> Of course I want the explicit Times (*) to
> still work the same as before,
> x*y//FullForm
> yielding
> Times[x,y]
>
> --Dave Snead
>

I think you can probably get what you want, if you start with an 
expression in the form of a string:


In[4]:= str = " (b a) c*d"

Out[4]= " (b a) c*d"

In[8]:= str1 = StringReplace[str, "*" -> "\[SmallCircle]"]

Out[8]= " (b a) c\[SmallCircle]d"

In[12]:= expr =
  ToExpression[str1, StandardForm, Hold] /. Times -> CircleTimes /.
    SmallCircle -> Times // ReleaseHold

Out[12]= (b\[CircleTimes]a)\[CircleTimes](c d)

In[14]:= % // FullForm

CircleTimes[CircleTimes[b, a], Times[c, d]]

The above uses the standard Mathematica parser using a couple of tricks, 
but more generally, if you start with a string, you can parse it as you 
see fit with a little effort.

David Bailey
http://www.dbaileyconsultancy.co.uk



  • Prev by Date: System of second-order nonlinear ordinary differential equations
  • Next by Date: Re: Help with map /@
  • Previous by thread: Re: Implicit Times
  • Next by thread: Re: Implicit Times