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$
2
  • 1
    $\begingroup$ Superscript[G, {a, b}] would be the right way to go I assume. $\endgroup$
    – Öskå
    Commented Aug 31, 2014 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$ Commented Sep 1, 2014 at 8:51

1 Answer 1

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}$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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