Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12483

Superscript on plus expression

From "Dave Snead" <dsnead6@charter.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Superscript on plus expression
Date 2012-11-27 08:39 +0000
Message-ID <k91u8h$5l1$1@smc.vnet.net> (permalink)
References <20121117084935.868E56AF3@smc.vnet.net> <19898081.6403.1353229345311.JavaMail.root@m06> <000301cdc668$e3ec8740$abc595c0$@comcast.net>
Organization Time-Warner Telecom

Show all headers | View raw


Hi,

Mathematica fails to parenthesize the a+b in Superscript[Plus[a,b],k]
so the output looks identical to
Plus[a,Superscript[b,k]]

Previous suggestions that worked to fix a similar problem for the Subscript 
case, i.e.,

Format[Subscript[arg_Plus, k_]] :=
Subscript[
  "(" <> StringJoin @@ Riffle[ToString /@ (List @@ arg), " + "] <>
   ")", k]

and

MakeBoxes[Subscript[(head : (Plus | Times))[args__], k_],
  form : (StandardForm | TraditionalForm)] :=
InterpretationBox[#1, #2] & @@ {SubscriptBox[
    RowBox[{"(", ToBoxes[head[args], form], ")"}], ToBoxes[k, form]],
   Subscript[head[args], k]}

don't carry over analogously to the Superscript case!

Format[Superscript[arg_Plus, k_]] :=
Superscript[
  "(" <> StringJoin @@ Riffle[ToString /@ (List @@ arg), " + "] <>
   ")", k]

and

MakeBoxes[Superscript[(head : (Plus | Times))[args__], k_],
  form : (StandardForm | TraditionalForm)] :=
InterpretationBox[#1, #2] & @@ {SuperscriptBox[
    RowBox[{"(", ToBoxes[head[args], form], ")"}], ToBoxes[k, form]],
   Superscript[head[args], k]}

don't work!


How can I get Mathematica to parenthesize the sum in
Superscript[Plus[a,b],k] ?

Thanks in advance,
Dave Snead




Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Superscript on plus expression "Dave Snead" <dsnead6@charter.net> - 2012-11-27 08:39 +0000
  Re: Superscript on plus expression Roland Franzius <roland.franzius@uos.de> - 2012-11-28 08:15 +0000
  Re: Superscript on plus expression awnl <awnl@gmx-topmail.de> - 2012-12-03 08:18 +0000

csiph-web