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
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?
>>
>
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
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?
>>>
>>
>
>
--
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)
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.
Thanks.
Glenn
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.
It's important to remember that what you see on the screen is not
always what you get when you do Export.