There's a simple answer to this and a fairly complicated one. I'll hint you the hard one in a short manner and give you the easy one. If you wanna understand the hard one answer to this post. It's quite tricky if you wanna do it by hand every time (involves writing the two points where the secant intersects with your function as (x/f(x)) and ((x+h)/f(x)) (h simply stands for a value that makes sure x and x+h are not the same). But there's an easier way. Unluckily this involves you believing me that what i tell you is true and kinda ruins the whole point of mathematics but whatever here it goes: There's a way of deriving a formula for any function so that what you get is actually the gradient in any point you choose on the original function. You do this by taking your function and lowering the exponent of every term in that function by '1' and putting the number it was in front of the term as a factor to the term. Maybe not the easiest thing to put in words so here's an example:

Modifying x^2 with this method you get 2*x^1 = 2x

3x^4 + x^2 + 7 becomes 4*3x^3 + 2*x (the 7 dissapears since it had exponent '1' and you're lowering that to '0')

The functions you get out of this are the gradients for the secants approaching lenght 0 you talked about in any point 'x' chosen by you.

Example: f(x) = x^2 , f'(x)=2*x

So the function x^2 has the gradient 2*x in point 'x' of the function x^2. This means that if you want to know the gradient in the point, say 4, you have to put '4' in the f'(x) function which is 2*4 = 8.

Hope i could help

Greetings

MayD