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
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CANODV3%3DzF5hKDpTrLi0V-LO72AjQbDyUpMEUmy7v_E5GdprGew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.