program to derivate code example
Example 1: program to derivate
def f(x): return x ** 2#For instance f(2) = 4
Example 2: program to derivate
def g(x): return sin(x) * cos(x) + exp(2*x) + 2*x**4 - 10
Example 3: program to derivate
def derive(function, value): h = 0.00000000001 top = function(value + h) - function(value) bottom = h slope = top / bottom # Returns the slope to the third decimal return float("%.3f" % slope)
Example 4: program to derivate
from math import *