I want to find the derivative of a function (x)(x - 1) using the definition of a derivative. I want my increments to be 1e-2
. So that it simulates the limit going to zero. I saw on Range for Floats that I could use user-defined functions to create range functions that take float variables.
def frange(x, y, jump):
while x < y:
yield x
x += jump
def drange(start, stop, step):
r = start
while r < stop:
yield r
r += step
i = frange(1e-14,1e-2,2)
for k in i:
set = []
x = 1
dvt = ((x + k ) * (x + k - 1) - x*(x - 1))/k
set.append(dvt)
print(set)
When I run the program I only get
[0.9992007221626509]
What is going on that I am not getting more than one derivative added to the list?