2
$\begingroup$

I have a very cumbersome expression, which I need to export to TeX form. The equations ends up to be extremely long, so I prefer that mathematica can display $\rm{Sin}[\alpha_1]$ as $s_{\alpha_1}$ , etc., and $\rm{Sin}[\alpha_1+\alpha_2]$ by $s_{\alpha_1+\alpha_2}$. Preferably, this notation will not prevent the expression from further trigonometric simplification.

I can't find a way after a lot of search. Could someone help?

Update

Thanks for the answers. They both work and have solved my problem, but I notice that they can no longer be further trigonometric simplified; for example,

 Simplify[
   Sin[Subscript[α, 1]]^2 /. Sin[x_] :> Subscript[s, x] + Cos[Subscript[α, 1]]^2]

does not simplify to 1. I wonder if there is anyway that avoid this problem? If this is possible, then the outputs within Mathematica itself can be more compact, and can be used for further manipulation, which is helpful.

$\endgroup$
3
  • $\begingroup$ Do you want to change the way it looks in TeXForm or in Mathematica, or both? $\endgroup$
    – Carl Woll
    Apr 21, 2017 at 22:22
  • $\begingroup$ MakeBoxes[Sin[x_], StandardForm] := MakeBoxes[Subscript["s",x], StandardForm] and something similar for Cos[x], although you might want to create a function to only produce the compact output when needed. $\endgroup$
    – Carl Woll
    Apr 21, 2017 at 23:35
  • $\begingroup$ @Carl Woll, this is exactly what I'm looking for, thanks a lot! $\endgroup$
    – larry
    Apr 21, 2017 at 23:47

3 Answers 3

2
$\begingroup$

Also:

ClearAll[toSubscript]
toSubscript = Block[{Sin = Subscript[s, #] &, Cos = Subscript[c, #] &}, # ] &;

toSubscript[{Cos[Subscript[α, 1]] + Sin[Subscript[α, 1] + Subscript[α, 2]], 
        Cos[Subscript[β, 1]] +  Cos[Subscript[β, 2] Subscript[β, 3]]}]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ Your solution (as well as Josh Bishop's) seems to prevent further trigonometric simplifications. $\endgroup$
    – Carl Woll
    Apr 21, 2017 at 23:08
  • $\begingroup$ @Carl, good point. I assumed the expression to be re-formatted was already Simplifyed, or, if not, it can be used as toSubscript[FullSimplify[expr]] $\endgroup$
    – kglr
    Apr 22, 2017 at 0:08
5
$\begingroup$

One easy way to accomplish this goal is to use a simple replacement rule.

{Sin[Subscript[α, 1]], Sin[Subscript[α, 1] + Subscript[α, 2]]} /. 
  Sin[x_] :> Subscript[s, x]
$\endgroup$
3
$\begingroup$

In these cases I like to use $Preprint:

$Preprint = # /. Sin[x_] -> Subscript[s, x] & 

This does not alter the internal representation of the expressions, just the way they are displayed.

$\endgroup$

Your Answer

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

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