Codecademy Logo

Differential Calculus

Limits

Limits quantify what happens to the values of a function as we approach a given point. This can be defined notationally as:

limx6f(x)=L\lim_{x \rightarrow 6} f(x) = L

We can read this in simple terms as “the limit as x goes to 6 of f(x) approaches some value L”.

Limit evaluations for a function with a discontinuity at x=-4.

Limit Definition of the Derivative

The limit definition of the derivative proves how to measure the instantaneous rate of change of a function at a specific point by looking at an infinitesimally small range of x values.

instantaneous rate of change =limh0f(x+h)hinstantaneous\ rate\ of\ change\ = \lim_{h \rightarrow 0} \frac{f(x+h)}{h}

The animation provided shows that as we look at a smaller range of x values, we approach the instantaneous range of a point.

This gif shows the definition of a derivative through limits by approaching instantaneous rate of change at x=1 for a function.

Derivative Properties

The derivative is the slope of a tangent line at a specific point, and the derivative of a function f(x) is denoted as f’(x). We can use the derivative of a function to determine where the function is increasing, decreasing, at a minimum or maximum value, or at an inflection point.

If f’(x) = 0, then the function is not changing. This can mean one of a few things.

  • It may mean that the function has reached a local maximum (or minimum). A local maximum is a value of x where f’(x) changes from positive to negative and thus hits 0 along the way. In f(x), the local maximum is lower than all the points around it.
  • It may also mean that the function has reached what is called a local maximum. Our local maximum is higher than the points around it. When f’(x) goes from negative values to 0 to positive values, a local maximum forms.
  • It may be an inflection point. This is a point where a function has a change in the direction of curvature. For example, the curve of the function goes from “facing down” to “facing up.” Finding inflection points involves a second derivative test, which we will not get to in this lesson.

If f’(x) > 0, the function is increasing, and if f’(x) < 0, the function is decreasing.

This gif shows where a function is increasing, decreasing, or at an extrema.

Derivatives in Python

We can use the np.gradient() function from the NumPy library to calculate derivatives of functions represented by arrays. The code block shown shows how to calculate the derivative of the function f(x) = x3 + 2 using the gradient() function.

from math import pow # dx is the "step" between each x value dx = 0.05 def f(x): # to calculate the y values of the function return pow(x, 3) + 2 # x values f_array_x = [x for x in np.arange(0,4,dx)] # y values f_array_y = [f(x) for x in np.arange(0,4,dx)] # derivative calculation f_array_deriv = np.gradient(f_array_y, dx)

Calculating Derivatives

To take the derivative of polynomial functions, we use the power rule. This states the following:

ddxxn=nxn1\frac{d}{dx}x^{n} = nx^{n-1}

There are rules even beyond the power rule. Many common functions have defined derivatives. Here are some common ones:

ddxln(x)=1xddxex=exddxsin(x)=cos(x)ddxcos(x)=sin(x)\begin{aligned} \frac{d}{dx}ln(x) = \frac{1}{x} \\ \frac{d}{dx}e^x = e^x \\ \frac{d}{dx}sin(x) = cos(x) \\ \frac{d}{dx}cos(x) = -sin(x) \end{aligned}

Derivative Rules

There are general rules we can use to calculate derivatives.

The derivative of a constant is equal to zero:

ddxc=0\frac{d}{dx}c = 0

Derivatives are linear operators, meaning that we can pull constants out of derivative calculations:

ddxcf(x)=cf(x)\frac{d}{dx} c f(x) = c f'(x)

The derivative of a sum is the sum of the derivatives, meaning we can say the following:

ddx(f(x)+g(x))=ddxf(x)+ddxg(x)\frac{d}{dx}(f(x) + g(x)) = \frac{d}{dx}f(x) + \frac{d}{dx}g(x)

We define the derivative of two products as the following:

ddx(f(x)+g(x))=ddxf(x)+ddxg(x)f(x)=u(x)v(x)f(x)=u(x)v(x)+v(x)u(x)\begin{aligned} \frac{d}{dx}(f(x) + g(x)) = \frac{d}{dx}f(x) + \frac{d}{dx}g(x) \\ f(x) = u(x)v(x) \rightarrow f'(x) =u(x)v'(x) + v(x)u'(x) \end{aligned}

Related Courses

Course

Differential Calculus

Beginner friendly

1 Lesson
Path

Fundamental Math for Data Science

Beginner friendly

16 Lessons