Differentiation in Python

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Mar 28 13:35:11 CET 2013


On Thu, 28 Mar 2013 05:17:36 -0700, zingbagbamark wrote:

> How do I differentiate(first order and 2nd order) the following
> equations in python. I want to differentiate C wrt Q.
> 
> C = (Q**3)-15*(Q**2)+ 93*Q + 100


For such a simple case, you don't do it with Python, you do it with 
maths, and get an exact result.

dC/dQ = 3*Q**2 - 30*Q + 93


d²C/dQ² = 6*Q - 30


The rule for differentiating polynomials of the form

y = k*x**n

is:

dy/dx = (k*n)*x**(n-1)

Consult a good calculus text book or on-line site for further details.


-- 
Steven



More information about the Python-list mailing list