Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to reorder terms in an expression to follow a specific order?

Suppose I have the following code:

ti = var('ti', latex_name = 't_i')
yi = var('yi', latex_name = 'y_i')
expr1 = yi -ti

expr1 will display as $$-{t_i} + {y_i}$$

Is there a way I can rewrite expr1 so that it will display as:

$$ {y_i} -{t_i}$$

?

I've tried using hold=True like so:

expr1 = yi.add(-ti, hold = True)

but that did not work.