Hi all,
I understand that the compose() function defined in
sympy.polys.polytools can be used as follows:
>>> from sympy import compose, Symbol
>>> x = Symbol('x')
>>> compose(x+1, x+1)
x + 2
Now, let's say I have a user defined function defined as follows:
from sympy import Function, Symbol, solve, compose, sin, cos
class fx(Function):
@classmethod
def eval(cls, x):
return x**2
def _eval_evalf(self, prec):
return self.eval()
I tried to use the compose() function as follows:
compose(fx(x), x+1) and I get the answer as follows, x**2 + 2*x + 1
which is correct.
Is this the best way to demonstrate function composition for user
defined functions?
Thanks,
Amit.
--
http://echorand.me