6
$\begingroup$

This post is not about a specific Mathematica problem but about to develop the best way to enter mathematical equations with subscripts and superscripts. I have a model of a large number of equations in which variables have subscripts, superscripts, and an index to create a set of equations using Table.

I wonder if anybody can suggest me the best way to enter model equations such as those in dynamic stochastic equilibrium models. Equations have all kinds of subscripts and superscripts, and I like to know the best way of writing such equations in Mathematica.

EDIT 1 Here is an example of a model I aim to solve. Using the suggested subscript and superscript notation to write a Mathematica code will be very complicated and there must be another way to code this model because Mathematica is supposed to be powerful solve much more complicated and larger system of non-linear equations.

enter image description here enter image description here

As can be easily seen from this example model, I could log-linearize the model and redefine the variables and solve the system. My question is not about solving this model but entering the model equations in an efficient format using Mathematica. It is obvious to me that using long-subscript and superscripted variables is not the way forward. I am interested in a robust and stable coding of model of this kind.

I hope my question is clear.

Thanks.

$\endgroup$
  • 3
    $\begingroup$ There are some limitations that you can face when using sub/super-scripts mathematica.stackexchange.com/questions/1004/… $\endgroup$ – yarchik Jun 30 at 7:53
  • 3
    $\begingroup$ For instance, you cannot clear a value of such an object easily mathematica.stackexchange.com/questions/373/… $\endgroup$ – yarchik Jun 30 at 7:54
  • 12
    $\begingroup$ My recommendation is to avoid directly transcribing math into MA code. Try to adapt to MA programing paradigm. For instance the following object y[a,b][c,d][x] could denote a function with 2 sup and 2 superscripts and one variable. $\endgroup$ – yarchik Jun 30 at 7:58
  • 6
    $\begingroup$ ... and you can always use Format to define print forms, e.g. Format[y[a_, b_][c_, d_][z_]] := Subsuperscript[y, Row[{a, b}], Row[{c, d}]][z] $\endgroup$ – kglr Jun 30 at 9:05
  • 3
    $\begingroup$ I think it's better to show us the specific equation system you want to code. $\endgroup$ – xzczd Jun 30 at 14:43
1
$\begingroup$

I have found out an answer to my questions: 1) how to typeset mathematical equations in the text-book format, and 2) how to differentiate superscripts from power notation.

My answer to question (1) is taken from this forum. To write an equation with superscripts and power at the same time, run the following Code once in the beginning of your program:

AppendTo[
CurrentValue[$FrontEnd, "InputAliases"], 
"sps" -> TemplateBox[{"\[SelectionPlaceholder]", "\[Placeholder]"}, 
"Superscript"]
];

Then enter Esc sps Esc to write an equation with pure superscript notation, and then use Built-in MMA pallate for power notation Ctrl+^. This will create a math equation or notation with superscript combined with power notation.

To answer question (2), I give an example of creating a math notation with pure power. Just looking at the following example should be sufficient to see that in the first math notation, pure superscripts are combined with power 2, and in the second math notation using the MMA pallate Ctrl+^ is used to create pure power notation. Using these two different notations in typesetting math equations is so powerful and makes our life very easy.

Thank you all commenting on my question and especially the MMA links provided by some of the comments given.

enter image description here

$\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.