differentate derivative differentation

Solutions on MaxInterview for differentate derivative differentation by the best coders in the world

showing results for - "differentate derivative differentation"
Angelo
17 Jan 2017
1# function wrt to differentate
2def cu(x):
3    return x*x*x
4
5# differentation function
6# Slightly increase x and compute the result. 
7# Then compute the ratio of change in result with change in x
8def diff(fun, x):
9    delta = 0.000000001
10    y = fun(x)
11    x1 = x+delta
12    y1 = fun(x1)
13    return (y1-y) / (x1-x)
14
15# X^3 = 3X^2
16diff(cu,2)
17# >>12.0