# Maclaurin series of the sine function

By Martin McBride, 2022-11-17
Tags: maclaurin series sine
Categories: maclaurin series

In this section we will use the Maclaurin series to find a polynomial approximation to the sine function, sin(x).

The general formula for the Maclaurin series for the function f(x) is:

Where:

• f(0) is the value of the function for x = 0.
• f'(0) is the value of the first derivative function for x = 0.
• f''(0) is the value of the second derivative function for x = 0.
• f'''(0) is the value of the third derivative function for x = 0.
• And so on.

To apply this to the sine function, we need to calculate those derivatives.

## Derivatives the sine function

In our case f(x) is the sine function:

The first derivative of the sine function is the cosine function:

We find the second derivative by differentiating again. If we differentiate the cosine function we get negative sine:

We find the third derivative by differentiating again. If we differentiate negative sine function we get negative cosine:

Finally, we find the fourth derivative by differentiating yet again. If we differentiate negative cosine function we get sine:

We are back to the sine function again. If we differentiate again, the pattern will repeat: s, c, -s, -c, s, c, -s, -s ...

## Values of the derivatives at x = 0

The sine of 0 is 0, and the cosine of 0 is 1. This allows us to calculate the following values for f(x) and its derivatives when x = 0: This means that:

• f(0) = 0
• f'(0) = 1
• f''(0) = 0
• f'''(0) = -1

Again, this patten repeats for higher order derivatives: 0, 1, 0, -1, 0, 1, 0, -1 ...

## Maclaurin series of sine function

Taking the general equation above:

We can replace f(0), f'(0), and all of the higher order derivatives with the values we found above:

This can be tidied up by removing the zero terms. We have also added some extra terms up to teh term in the 7th power of x:

Or using sigma notation (as described here):

## A graphical illustration of the Maclaurin expansion

Here is an animation that shows the first 4 non-zero terms of the expansion being added in one by one:

One way to gain an intuitive insight into how the Maclaurin expansion works is to look at graphs of the approximation as we add the terms one by one.

### Step 1

Taking just the first term of the expansion gives us:

This graph shows the expansion (in yellow) and the sine function (in black):

This approximation is not very good, it is just a diagonal straight line. It has the same value and slope at the sine function at 0, but it diverges away from that point.

### Step 2

Taking the first two terms of the expansion gives us:

Here is the graph:

This is a better approximation, and will continue to improve as we add more terms.

### Step 3

Taking the first three terms of the expansion gives us:

Here is the graph:

### Step 4

Taking the first four terms of the expansion gives us:

Here is the graph: