python - How to do function composition in Sympy? -


i want h = f(g(x)) , able differentiate h, h.diff(x). 1 function h = cos(x) in fact possible , documentation makes clear.

but function compositions not clear. if have done this, kindly show me example or link me relevant document.

(if sympy can't this, know of other packages this, if non-python)

thank you.

it seems function composition works expect in sympy:

import sympy h = sympy.cos('x') g = sympy.sin(h) g out[245]: sin(cos(x)) 

or if prefer

from sympy.abc import x,y g = sympy.sin('y') f = g.subs({'y':h}) 

then can call diff derivative.

g.diff() out[246]: -sin(x)*cos(cos(x)) 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -