Karl
Karl

Reputation: 69

How can I calculate the analytical derivative of a function?

How can I analytically differentiate in Python?

E.g:

d/dx (x^3 * L * lambda /(pi*d))

Additional: Screenshot of an attempt to install sympy

Upvotes: 0

Views: 1645

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 117876

You can use sympy to differentiate a function symbolically

>>> from sympy import *
>>> x, L, lamb, d = symbols('x L lamb d')
>>> f = x**3 * L * lamb / (pi * d)
>>> f
L*lamb*x**3/(pi*d)
>>> diff(f, x)
3*L*lamb*x**2/(pi*d)

Upvotes: 1

Related Questions