Arithmetic function library for python

I am looking for a library that will allow me to manipulate functions with standard operators (*, -, *, / etc.).

Suppose you have a function f(x) = x ** 2 and g(x) = x + 2 . I would like to write f * g and get a new functor that is essential x ** 2 * (x + 2) or f(g) and get (x + 2) ** 2 .

I know that this is not so difficult to implement, you just need to create the Functor class and overload it with __call__ , but I hope there is a third-party library for it.

I am not trying to use this for something heavy just for training. Thanks for the help.

+6
function python
source share
2 answers

Sympy should do what you want.

+5
source share

I do not quite understand what you need, but does the operator module (in the standard library) help in general? It defines functions for all standard arithmetic operators.

0
source share

All Articles