1 | initial version |
Thanks to kcrisman I figured the remaining bits out myself. Complete code as follows:
# [...]
print latex(sexp)
sexp2=simplify(sexp) # expand doesn't hurt it, so omit that
print latex(sexp2)
# observe they are different due to sexp2 being processed
# via Maxima, as explained by kcrisman
# maxima replaces a() by a new a() that doesn't have the
# print function:
print sexp2.operands()[0].operator().__class__ # maxima a()
print a.__class__ # the a() we have defined
# to coerce back, we need to replace the former by the latter:
print latex(sexp2.substitute_function(sexp2.operands()[0].operator(),a))
2 | No.2 Revision |
Thanks to kcrisman I figured the remaining bits out myself. Complete code as follows:
# [...]
print latex(sexp)
sexp2=simplify(sexp) # expand doesn't hurt it, so omit that
print latex(sexp2)
# observe they are different due to sexp2 being processed
# via Maxima, as explained by kcrisman
# maxima replaces a() by a new a() that doesn't have the
# print function:
print sexp2.operands()[0].operator().__class__ # maxima a()
print a.__class__ # the a() we have defined
# to coerce back, we need to replace the former by the latter:
print latex(sexp2.substitute_function(sexp2.operands()[0].operator(),a))
(And that does the intended.)