Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting TraditionalForm to put in a multiplication sign.

101 views
Skip to first unread message

Frank K

unread,
Aug 7, 2011, 6:16:48 AM8/7/11
to
For purposes of exporting Mathematica expressions to other software,
it would be useful to have a multiplication sign (*) in
TraditionalForm instead of a space. For example, x * y * (w + z)
instead of x y (w + z). Anybody know how to do this?

Murray Eisenberg

unread,
Aug 8, 2011, 4:24:51 AM8/8/11
to
But * is not the traditional multiplication sign! It's computer geekese
for multiplication.

The traditional (explicit) multiplication sign is either a center dot or
else a small x-shaped cross.

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

DrMajorBob

unread,
Aug 9, 2011, 7:21:13 AM8/9/11
to
I've seen all three multiplication signs for at least 40 years (center dot
rarely). Maybe your traditions are simply older than mine.

What's really NOT very useful, in my opinion, is no sign at all.

Bobby

On Mon, 08 Aug 2011 03:20:47 -0500, Murray Eisenberg
<mur...@math.umass.edu> wrote:

> But * is not the traditional multiplication sign! It's computer geekese
> for multiplication.
>
> The traditional (explicit) multiplication sign is either a center dot or
> else a small x-shaped cross.
>
> On 8/7/11 6:15 AM, Frank K wrote:
>> For purposes of exporting Mathematica expressions to other software,
>> it would be useful to have a multiplication sign (*) in
>> TraditionalForm instead of a space. For example, x * y * (w + z)
>> instead of x y (w + z). Anybody know how to do this?
>>
>


--
DrMaj...@yahoo.com

Peter Pein

unread,
Aug 9, 2011, 7:23:48 AM8/9/11
to

Hi,

will the following do what you want?

Unprotect[Times];
Format[HoldPattern[Times[x_, y__]]] := x \[CenterDot] y;
Protect[Times];
a x^2 + b x + c // TraditionalForm

Murray Eisenberg

unread,
Aug 10, 2011, 6:47:49 AM8/10/11
to
Center dot is not at all uncommon in strictly mathematical context, and
for any kind of multiplication-like operation.

I've been doing math for far longer than 40 years, and I never
encountered the * for multiplication of ordinary numbers before I first
began programming with FORTRAN (my first computer language after
assembly) in 1959.

The * is, however, and long has been, used in mathematical discourse to
denote an arbitrary operation in a group or monoid or whatever --
precisely because it's NOT the usual multiplication sign for numbers.

On 8/9/11 7:18 AM, DrMajorBob wrote:
> I've seen all three multiplication signs for at least 40 years (center dot
> rarely). Maybe your traditions are simply older than mine.
>
> What's really NOT very useful, in my opinion, is no sign at all.
>
> Bobby
>
> On Mon, 08 Aug 2011 03:20:47 -0500, Murray Eisenberg
> <mur...@math.umass.edu> wrote:
>
>> But * is not the traditional multiplication sign! It's computer geekese
>> for multiplication.
>>
>> The traditional (explicit) multiplication sign is either a center dot or
>> else a small x-shaped cross.
>>
>> On 8/7/11 6:15 AM, Frank K wrote:

>>> For purposes of exporting Mathematica expressions to other software,
>>> it would be useful to have a multiplication sign (*) in
>>> TraditionalForm instead of a space. For example, x * y * (w + z)
>>> instead of x y (w + z). Anybody know how to do this?
>>>
>>
>
>

--

Simon

unread,
Aug 10, 2011, 6:58:12 AM8/10/11
to
I thought there must be an option for this... but couldn't find it.
(AutoMultiplicationSymbol seems to only be for numbers...)
Instead, here's a quick hack that relies on the fact that in the box form of expressions, a single space is almost always used to denote multiplication.

ClearAll[TradFormX]
SetAttributes[TradFormX, HoldFirst]
TradFormX[expr_, cellStyle_String:"Output", outForm_: TraditionalForm] :=
CellPrint[Cell[ToBoxes[HoldForm[expr], outForm] /. " " -> "*", cellStyle]]

In[]:= (3 2 a + b) f[x + 2 y]//TradFormX
Out[]= (3*2*a + b)*f(x + 2*y)

Frank K

unread,
Aug 11, 2011, 5:15:41 AM8/11/11
to
On Aug 10, 6:47 am, Murray Eisenberg <mur...@math.umass.edu> wrote:
> Center dot is not at all uncommon in strictly mathematical context, and
> for any kind of multiplication-like operation.
>
> I've been doing math for far longer than 40 years, and I never
> encountered the * for multiplication of ordinary numbers before I first
> began programming with FORTRAN (my first computer language after
> assembly) in 1959.
>
> The * is, however, and long has been, used in mathematical discourse to
> denote an arbitrary operation in a group or monoid or whatever --
> precisely because it's NOT the usual multiplication sign for numbers.
>
> On 8/9/11 7:18 AM, DrMajorBob wrote:
>
>
>
>
>
>
>
>
>
> > I've seen all three multiplication signs for at least 40 years (center =

dot
> > rarely). Maybe your traditions are simply older than mine.
>
> > What's really NOT very useful, in my opinion, is no sign at all.
>
> > Bobby
>
> > On Mon, 08 Aug 2011 03:20:47 -0500, Murray Eisenberg
> > <mur...@math.umass.edu> wrote:
>
> >> But * is not the traditional multiplication sign! It's computer geekes=
e
> >> for multiplication.
>
> >> The traditional (explicit) multiplication sign is either a center dot =

or
> >> else a small x-shaped cross.
>
> >> On 8/7/11 6:15 AM, Frank K wrote:
> >>> For purposes of exporting Mathematica expressions to other software,
> >>> it would be useful to have a multiplication sign (*) in
> >>> TraditionalForm instead of a space. For example, x * y * (w + z)
> >>> instead of x y (w + z). Anybody know how to do this?
>
> --
> Murray Eisenberg mur...@math.umas=

s.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (=

W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305

I should have been more specific. I'm trying to convert Mathematica
expressions to AMPL code. AMPL uses * for multiplication.
ExportString[ expr, "Text"] works for polynomials but not for
functions.

Glenn Carlson

unread,
Aug 11, 2011, 5:16:12 AM8/11/11
to
I think this will be very useful to me.

Thanks.

Glenn

Simon

unread,
Aug 11, 2011, 5:21:17 AM8/11/11
to
Hi Peter,

Using Format is a good idea, but you probably want to combine it with Interpretation so that the output can be reused. In the following I've also restricted the Format to only work on TraditionalForm expressions, but that's not necessary:

In[1]:= Unprotect[Times];
Format[HoldPattern[Times[x_, y__]], TraditionalForm] :=
Interpretation[Row[{x, y}, "*"], Times[x, y]];
Protect[Times];

In[6]:= a f[x] + b g[x + y] + 2 c
% // TraditionalForm

Out[6]= 2 c + a f[x] + b g[x + y]

Out[7]//TraditionalForm= a*f(x)+b*g(x+y)+2*c

The problem with Format/Interpretation is that if you try to change an expression to TraditionalForm in place with Ctrl-Shift-T (or the appropriate context/normal menu option), you run into a recursion bug: http://stackoverflow.com/q/4112299/421225

To get around this, maybe it's best to use a manually constructed MakeBoxes rule. For example:

Unprotect[Times];
Times /: MakeBoxes[HoldPattern[Times[x_, y__]], TraditionalForm] :=
With[{row = ToBoxes[Row[{x, y}, "*"], TraditionalForm]},
InterpretationBox[row, x y]];
Protect[Times];

or

Unprotect[Times];
Times /: MakeBoxes[HoldPattern[Times[x_, y__]], form_] :=
With[{row = ToBoxes[Row[{x, y}, "*"], form]},
InterpretationBox[row, x y]];
Protect[Times];

if you want it applying to all formattings.

Frank K

unread,
Aug 13, 2011, 6:53:02 AM8/13/11
to

It's important to remember that what you see on the screen is not
always what you get when you do Export.

0 new messages