MathGroup Archive 2003

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

Search the Archive

Re: Design problem in 4.2?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38797] Re: Design problem in 4.2?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 13 Jan 2003 04:11:32 -0500 (EST)
  • References: <avrj5a$96i$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Ted,

The following works - extra brackets to make n and m name what we want.

MakeBoxes[(n : (_Integer | _Real))*(m : (_Integer | _Real))^pow_, form_] :=
  RowBox[{ToString[n], "*",
      SuperscriptBox[ToString[m], MakeBoxes[pow, form]]}]

Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565





"Ersek, Ted R" <ErsekTR at navair.navy.mil> wrote in message
news:avrj5a$96i$1 at smc.vnet.net...
> Earlier I showed Jonathan Mann how to have a muliplication sign used
> when the result of the following is displayed.
>
> > In[1]:=  40 (8)^t
> >
> > Out[1]  5 8^(1+t)
> >
> > --------------
> You might also want to ensure a multiplication sign is used in cases
> such as
> In[2]:=  40*8.2^t
> In[3]:=  40.5*8^t
> In[4]:=  40.5*8.2^t
> To do that use the following lines as desired.
> --------------
>
> MakeBoxes[n_Integer*m_Integer^pow_,form_]:=
>
RowBox[{ToString[n],"*",SuperscriptBox[ToString[m],MakeBoxes[pow,form]]}]
>
> MakeBoxes[n_Integer*m_Real^pow_,form_]:=
>
RowBox[{ToString[n],"*",SuperscriptBox[ToString[m],MakeBoxes[pow,form]]}]
>
> MakeBoxes[n_Real*m_Integer^pow_,form_]:=
>
RowBox[{ToString[n],"*",SuperscriptBox[ToString[m],MakeBoxes[pow,form]]}]
>
> MakeBoxes[n_Real*m_Real^pow_,form_]:=
>
RowBox[{ToString[n],"*",SuperscriptBox[ToString[m],MakeBoxes[pow,form]]}]
>
> ---------------------
>
> I thought instead of the four lines above I could only use the
> following:
>
> MakeBoxes[n:(_Integer|_Real)*m:(_Integer|_Real)^pow_,form_]:=
>
> RowBox[{ToString[n],"*",SuperscriptBox[ToString[m],MakeBoxes[pow,form]]}]
>
> but this doesn't work.  Can anyone explain why?
>
> > -------------
> > If you put code like this in your (init.m) file it will evaluate every
> > time Mathematica is launched.  On my computer the init.m file is located
> > at
>    C:\Program Files\Wolfram
> Research\Mathematica\4.1\Configuration\Kernel\init.m
>
>
> > Regards,
> >   Ted Ersek
> >
> > Download my collection of Mathematica tricks from:
> > http://www.verbeia.com/mathematica/tips/Tricks.html
> > and
> > http://www.verbeia.com/mathematica/tips/GraphicsTricks.html
> >
> >
>




  • Prev by Date: RE: Mathematica Programming Book Recomendation?
  • Next by Date: 4 Straight segments !!
  • Previous by thread: Re: Design problem in 4.2?
  • Next by thread: problems with N[]