3
$\begingroup$

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)

or

Superscript[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.

$\endgroup$
  • 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
4
$\begingroup$

Perhaps this will work for you:

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

Example:

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

$G^{11}+G^{12}+G^{21}+G^{22}$

| improve this answer | |
$\endgroup$

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.