I am trying to type (and evaluate) expressions of the following form:

$$ G^{a,b} $$

into a mathematica. I've tried the obvious

G^(a, b)



But both of these give the same error

Syntax::tsntxi: "a,b" is incomplete; more input is needed.

I know one solution is to use Symbolize from the Notation package

<< Notation`
Symbolize[ParsedBoxWrapper[SuperscriptBox["G", RowBox[{"_", ",", "_"}]]]]

however this solution will not suffice as I want to perform operations such as the following:

In[3]:= Sum[G^(a, b), {a, 1, 2}, {b, 1, 2}]
Out[3]= 4 G^(a, b)

Is there any sensible way to get around this? Why is Superscript so much more picky than Subscript? Thanks in advance.

  • 1
    $\begingroup$ Superscript[G, {a, b}] would be the right way to go I assume. $\endgroup$ – Öskå Aug 31 '14 at 23:23
  • $\begingroup$ Shouldn't the sum return G^(1,1) + G^(1,2) + G^(2,1) + G^(2,2) instead of 4 G^(a,b)? $\endgroup$ – Teake Nutma Sep 1 '14 at 8:51

Perhaps this will work for you:

MakeBoxes[Superscript[b_, x_, y__], form_] ^:=
  ToBoxes[Superscript[b, Row[{x, y}]], form]


Sum[Superscript[G, a, b], {a, 1, 2}, {b, 1, 2}]


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.