Friday, February 21, 2020 | Toby Opferman


Toby Opferman


What is a dirivative?  It's the slope of the tangent line adjacent to the
function.  It's the change in x along the line.   It's the slope at any
point x on the graph of the function.

Well, that's all nice, but now let's show you how to do this shit and
in a little more detail what it means.

Let us demonstrate with a simple function.

f(x) = x + 4

The slope is 1 obviously from the equation y = mx + b

But, let us find the dirivative.

        f(x + h) - f(x)
limit  ---------------    =
 h->0        h

((x + h + 4) - (x + 4))/h =
(x + h + 4 - x - 4)/h =
h/h = 1

The dirivative is 1 as well.

Let me explain the top method now.

h = Delta X.  Delta means "Change"  So Delta X means "The Change in X"

We want to know the change in X as it moves along the graph to get the slope.

If you want to find the change between two points, you subtract them.

So, we take the function f(x), we add h to it f(x + h) and we then subtract
f(x) from it.  You could also take f(x) and subtract f(x - h) would
be the same thing.

We use the Limit of h->0 because we want the SMALLEST difference
in the change of x.

Here is a more complex function.

f(x) = x^2 + x - 4

        f(x + h) - f(x)
limit   ---------------  =
 h->0          h

(((x + h)^2 + (x + h) - 4) - (x^2 + x - 4))/h
((x^2 + 2xh + h^2 + x + h - 4) - x^2 - x + 4)/h
(2xh + h^2 + h)/h
2xh/h + h^2/h + h/h

2x + h + 1

Now, you substitue 0 for h since this is as h goes to 0.  BUT you do not 
substitute until the equation is simplied, and h cannot be in the 
denominator of course.

2x + 1 is the dirivative.

At Any point on the line, you can get the slope by putting in the number
for x.  The slope would be the slope of the adjacent tangent line.

Knowing this, you know that the slope of a horizontal line is 0.

Well, If you want to know where any high tops or valleys are, you
simply solve:

2x + 1 = 0

2x = -1
x = -1/2

When x = -1/2  that is going to be the bottom (or top) of the dip in the
parabola (x^2 functions you know are a parabola)

Plug that into the original equation:

f(-1/2) = 1/4 - 2/4 - 16/4 = (-17/4)

So, (-1/2, -17/4) is the center of the parabola.

The General equation of the dirivative is:

limit  f(x + h) - f(x)
 h->0  ---------------

Where h = Delta X

Now, there is a faster way to do dirivatives. Each diriviatve is seperated by
a + or a -.  Operands joined by a divide or a multiplication must be taken

For any constant a, it is now 0.

For any variable  ax^n is now anx^(n-1)


x^2 + x - 4

x^2 = 2x^(2-1) = 2x

x^1 = 1*x^0 = 1

4 = 0

2x + 1 + 0 = 2x + 1

Same thing we got in the above computation, but quicker.

This is for one variable only remeber.  And trignometric functions
have precise distint dirivatives.

Anoter Example:
3x^4 + 2x^2 - 1

4*3x^(4-1) + 2*2x^(2-1) - 0 = 12x^3 + 4x

The dirivative is:

12x^3 + 4x

Now, for the next examples, I will show you a few different dirivatives:

cos(x) = -sin(x)
sin(x) = cos(x)
lnx = 1/x

Now, for operands being multiplied, you want to follow this formula:


You take the dirivative of the first times the second.
Add the dirivative of the second times the first.

cos(x) - xsin(x)

(from now on we will use the syntanx (x)` to mean dirivative.)

(x)`*cos(x) - x*(cos(x))` = 1*cos(x) + x*(-sin(x)) = cos(x) - xsin(x)

That is the dirivative.

The dirivative of division is simmilar.

cos(x)     x(cos(x))` - cos(x)(x)`
------  =  ----------------------
  x                 x^2

           -xsin(x) - cos(x)

So, general forms are:

u*v = u`v + v`u

u/v =  (u`v - v`u)/v^2

One last thing to cover is the "chain rule"

cos(u) = -sin(u)*u`

So if you have

cos(2x) the dirivative is -sin(2x)*2


This applies to any function.

Here is the rules for logarithms.

ln(u) = u`/u
log_a(u) = u`/(lna*u)

log_e(2x) = 2/(lne*2x) = 2/2x = 1/x

This is because ln(2x) = ln(2) + ln(x) and ln(2) is a constant.

That is a basic overview of simple dirivatives.

About Toby Opferman

Professional software engineer with over 15 years...

Learn more »
Codeproject Articles

Programming related articles...

Articles »

Resume »

Email: codeproject(at)opferman(dot)com