Ask Your Question

Revision history [back]

In Sage, what you want is called "holding" the operation.

Find more about it by searching the word "hold" on this page:

For example, compare the abs operation, without holding or with holding:

sage: SR(-5).abs()
sage: SR(-5).abs(hold=True)

However, the hold context is not implemented for all operations.

In your case, I would use the string representation for f(x) and replace x by 2:

sage: f(x) = x^2
sage: print str(f(x)).replace('x', '2')