How to substitute a value into an expression without evaluation to convert it to LaTex?
How can I convert an expression to LaTex while substituting a variable value without evaluating the expression after substitution?
For example,
I have an expression 5*x*y.
The latex(5*x*y) is 5 \, x y as expected.
But now I want to substitute a constant instead of a variable.
For example 8 instead of x.
The LaTex representation (latex((5*x*y).subs(x=8)))
of which is would be 40 \, y, so the expression is automatically evaluated.
But I want to get something like 5 \\cdot 8 y instead.
Is that possible to do with SageMath?
I know something like that exists in SymPy. For example, take a look at the answer to:
It uses sympy.UnevaluatedExpr to wrap an expression to substitute the variable with.
Is there anything like that in SageMath?




Welcome to Ask Sage! Thank you for your question!