# Variable order in output

I have two questions about editing my output in Mathematica.

I want the variables to be to the right of the fractions with the parameters.

### Update

e = a*Subscript[u, 1] + b*Subscript[u, 2] + c*Subscript[y, 1] + d*Subscript[y, 2];
Collect[
Solve[e == 0, Subscript[y, 1]],
{Subscript[y, 2], Subscript[u, 1], Subscript[u, 2]}]


What I want is

• Please do not post images of your work, especially when the images display at a size that make them difficult to read. Please post your actual Mathematica code in the form of text that can be copied and pasted into a Mathematica notebook. Without such, it will be difficult to reproduce your problem and to experiment with possible solutions. – m_goldberg Nov 23 '16 at 9:18
• here: e = -Subscript[T, samp] Subscript[u, km1] + [Tau] Subscript[y, k] - [Tau] Subscript[y, km1] + Subscript[T, samp] Subscript[y, km1]; Collect[Solve[e == 0, Subscript[y, k]], {Subscript[y, km1], Subscript[ u, km1]}] but difficult to read? – chrisdi91 Nov 23 '16 at 9:19
• Please do not post code in comments. Edit your question to show the code. Please use markdown and our editor to format the code readably. – m_goldberg Nov 23 '16 at 9:21
• Why is the reordering important to you? There is no way to reorder the output will preserve the ability use it for further computation. That is, reordering for display is possible, but reordering of the internal form is not. – m_goldberg Nov 23 '16 at 9:30
• @chrisdi91 copy and paste your code from your notebook!! – Mirko Aveta Nov 23 '16 at 9:34

First, as it is already commented by @ m_goldberg : "reordering for display is possible, but reordering of the internal form is not". This means that you can reorder the expression to have a comfortable look at it. But this reordered expression you will not be able to use in the following calculations. It is of coarse, if you intend to have such further calculations. But the good news is that there is a rather simple remedy to that.

Second, one should spend some efforts to reorder that. But finally it is possible and not that complex.

So let us start. Here are your expressions:

e = -Ts*u1 - t*yk - t*yk1 + Ts*yk1;
expr0 = Collect[Solve[e == 0, yk], {yk1, u1}][[1, 1]]

(*  yk -> -((Ts u1)/t) + ((-t + Ts) yk1)/t  *)


Let us look at its TreeForm:

TreeForm[expr0]


It is now easy to take the parts of the first term of the right-hand part of your result separately:

Evaluate[Take[expr[[2, 1]], {1, 3}]]
Evaluate[expr[[2, 1, 4]]]

(* -(Ts/t)

u1    *)


Evaluate is here very important, since later I will apply HoldForm to the results, and then without Evaluate it will not work.

Now the HoldFormfunction is needed to prevent the fusion of these two expressions. Let us construct the first term of the result:

expr2 = (Evaluate[expr0[[2, 2, 3]]] //HoldForm)*(Evaluate[Take[expr0[[2, 2]], {1, 2}]] // HoldForm)


The result is as follows:

Let us construct the second part in the same way:

expr2 = (Evaluate[expr0[[2, 2, 3]]] //
HoldForm)*(Evaluate[Take[expr0[[2, 2]], {1, 2}]] // HoldForm);


and combine them together:

    expr3 = expr1 + expr2;
expr4=yk -> expr3


with the effect:

This seems to be what you need. Let us now have a look at its structure:

expr3 // FullForm

We see lots of the HoldFormfunctions in it, so it will not work in further calculations. To remove it do the following:

expr4 // ReleaseHold

(* yk -> -((Ts u1)/t) + ((-t + Ts) yk1)/t *)


and we returned to the initial state, but you may calculate further.

Have fun!