2

How can I write this equation in a nice manner when posting on Mathematica.SE?

Cos[Subscript[\[Beta], 0][t]] Sin[Subscript[\[Alpha], 0][t]] ==
  Cos[Subscript[\[Beta], i][t]] Sin[Subscript[\[Alpha], i][t]]
10
  • 4
    If you can at all avoid it, don't use Subscripts in your calculation. Not only does it improve readability, it also protects you from sneaky unintended behavior. Commented Feb 23, 2016 at 19:18
  • 1
    You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful Commented Feb 23, 2016 at 19:21
  • @MichaelE2 {} button : sorry but I didn't see this button Commented Feb 23, 2016 at 19:50
  • No problem. But since you're asking about formatting anyway, I thought I share my boilerplate advice to help folks discover the tools for making nice-looking posts. Commented Feb 23, 2016 at 20:56
  • @MichaelE2 and so where is this button {} ? Commented Feb 23, 2016 at 20:58
  • Sorry, I thought you meant you didn't see it but now you do. If find it "above the edit window" as I said before. It's between the quote button and the image button. (By edit window, I mean the textbox for entering and editing the text of posts; I see it if I click on the "edit" button below your question.) Commented Feb 23, 2016 at 21:30
  • @MichaelE2 ok of course, I believed that you were speaking in Mathematica. But, even if I use {}, I need to suppress subscript and symbols. {} doesn't make the transformation for me Commented Feb 23, 2016 at 21:33
  • But it transformed the text in the question into properly formatted code, instead of being formatted as a quotation, which is how it was originally formatted. (It was a comment about formatting your question itself, not an answer to your question.) Commented Feb 23, 2016 at 21:35
  • 1
    You should avoid using Subscript while defining symbols (variables). Subscript[x, 1] is not a symbol, but a compound expression where Subscript is an operator without built-in meaning. You expect to do $x_1=2$ but you are actually doing Set[Subscript[x, 1], 2] which is to assign a Downvalue to the oprator Subscript and not an Ownvalue to an indexed x as you may intend. Read how to properly define indexed variables here Commented Feb 24, 2016 at 9:08
  • I am definitely in the minority on subscripts but I agree it is best to avoid when posting to Mathematica.SE -- unless the problem at hand specifically relates to subscripts. For subscript usage in general I recommend using the Notations package. Surprisingly, for what it is, Mathematica handling of subscripts has never come close to e.g. Mathcad or Maple, but the Notations package can get you a fair way as long as you stick within its limitations. Commented Apr 27, 2017 at 2:55

2 Answers 2

5

Try this:

expr = Cos[Subscript[\[Beta], 0][t]] Sin[Subscript[\[Alpha], 0][t]] ==
   Cos[Subscript[\[Beta], i][t]] Sin[Subscript[\[Alpha], i][t]]

Mathematica graphics

expr /. Subscript[a_, b_] -> a[b]

(* Out: Cos[\[Beta][0][t]] Sin[\[Alpha][0][t]] == Cos[\[Beta][i][t]] Sin[\[Alpha][i][t]]*)

You can then use http://steampiano.net/msc/ to get:

Cos[β[0][t]] Sin[α[0][t]] == Cos[β[i][t]] Sin[α[i][t]]
5
  • Nice, but there are always corner cases Subscript[b, Sequence @@ {a, u}] /. Subscript[a_, b_] -> a[b] Commented Feb 24, 2016 at 20:42
  • 3
    @Dr.belisarius Agreed, this is a partial solution at best. I honestly don't think the effort it would take to make this approach more general would be worthwhile. It's much easier to fix the problem at the root by avoiding subscripts altogether :-) Commented Feb 25, 2016 at 5:27
  • Absolutely, completely, unconditionally agree Commented Feb 25, 2016 at 5:29
  • @MarcoB And how can I do when I have several levels of subscripts ? I have tried this when I have expressions with 2 or 3 levels but it doesn't work : Map[ToString, q3Pattes /. Or[Subscript[a_, b_] -> a[b], Subscript[a_, b_, c_] -> a[b[c]]]] Do you have ideas why ? Commented Feb 27, 2016 at 21:32
  • Perhaps Subscript[a_, b_, c_] -> a[b, c]? There won't be any perfect solution; the unfortunate truth is that a lot of hand-conversion may be needed. Commented Feb 27, 2016 at 22:35
4

The short answer is that there is no easy way to do what you ask. The editor we use on Mathematica.SE website does not support entry and display of two-dimensional forms nor does it convert Mathematica's special character notation to Unicode.

Some amelioration is possible, depending on your intent for posting the code.

  • For special characters that have Unicode equivalents, install halirutan's plug-in into your web browser (see Additional useful buttons for our M.SE editor) and use the αβ button that it adds to our editor to make the conversion.

  • If the snippet you are pasting in represents Mathematica output, then you can insert a PNG image of the output into your post rather than pasting in text.

  • If the snippet you are pasting represents input to Mathematica, then you might post the expression both as text and as a PNG image of the input. Do not post a PNG image without a text version.

As others have already mentioned there are good, solid, technical reasons for avoiding the use of Subscript expressions in Input cells (cells that get evaluated). I, myself, never use them in Input cells. Pretty formatting does not compensate sufficiently for the problems Subscript expressions can cause in evaluations.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.