Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differentiating a product with an unknown function - sympy

I tried various searches but couldn't find a good google string to bring up the right results.

I have a product of the form

y = x*f(x)

where f is a function of x which is not known. I want sympy to differentiate y with respect to x. Does anyone know how I can do this?

like image 694
user1654183 Avatar asked Aug 31 '13 23:08

user1654183


1 Answers

How about:

>>> x = sympy.Symbol("x")
>>> f = sympy.Function("f")
>>> y = x * f(x)
>>> y
x*f(x)
>>> y.diff(x)
x*Derivative(f(x), x) + f(x)
like image 67
DSM Avatar answered Sep 21 '22 10:09

DSM