Taylor Series

Taylor Series

A Taylor Series is an expansion of a function into an infinite sum of terms, like these ones:
Taylor Series expansionAs Sigma Notation
(There are many more)

Approximations

You can use the first few terms of a Taylor Series to get an approximate value for a function.
Here we show better and better approximations for cos(x). The red line is cos(x), the blue is the approximation (try plotting it yourself) :
1 − x2/2!
1 − x2/2! + x4/4!
1 − x2/2! + x4/4! − x6/6!
1 − x2/2! + x4/4! − x6/6! + x8/8!
(You can also see the Taylor Series in action at Euler's Formula for Complex Numbers.)

What is this Magic?

How can you turn a function into a series of power terms like this?
Well, it isn't really magic. First you say you want to have this:
f(x) = c0 + c1(x-a) + c2(x-a)2 + c3(x-a)3 + ...
Then choose a value "a", and work out the values c0 , c1 , c2 , ... etc
It is done using derivatives ...

Quick review: a derivative gives you the slope of a function at any point.

You must know the derivatives of your function f(x) and these basic derivative rules :
  • The derivative of a constant is 0
  • The derivative of x is 1
  • The derivative of xn is nxn-1 (Example: the derivative of x3 is 3x2)
We will use the little mark  to mean "derivative of".
OK, let's start:
To get c0, choose x=a so all the (x-a) terms become zero, leaving you with:
f(a) = c0
So c0 = f(a)
To get c1, take the derivative of f(x):
f(x) = c1 + 2c2(x-a) + 3c3(x-a)2 + ...
With x=a all the (x-a) terms become zero:
f(a) = c1
So c1 = f(a)
To get c2, do the derivative again:
f(x) = 2c2 + 3×2×c3(x-a) + ...
With x=a all the (x-a) terms become zero:
f(a) = 2c2
So c2 = f(a)/2
In fact, a pattern is emerging. Each term is
  • the next higher derivative ...
  • ... divided by all the exponents so far multiplied together (for which we can use factorial notation, for example 3! = 3×2×1)
And we get:
Now we have a way of finding our own Taylor Series: keep taking derivatives and divide by n! each time.

Example: Taylor Series for cos(x)

And all we need to know is:
  • The derivative of cos(x) is -sin(x)
  • The derivative of sin(x) is cos(x)
Choose a=0:
  • c0 = f(0) = cos(0) = 1
  • c1 = f'(0)/1! = -sin(0) = 0
  • c2 = f''(0)/2! = -cos(0)/2! = -1/2!
  • c3 = f'''(0)/3! = sin(0)/3! = 0
  • c4 = f''''(0)/4! = cos(0)/4! = 1/4!
  • etc...
The odd terms are all zero, so we get:
cos(x) = 1 − x2/2! + x4/4! − ...
Try that for sin(x) yourself, it will help you to learn.
Or try it on another function of your choosing. The key thing is that you be able to take derivatives of your function f(x).

Note: A Maclaurin Series is a Taylor Series where a=0, so all the examples we have been using so far can also be called Maclaurin Series.

Derivative Rules


The Derivative tells us the slope of a function at any point.
The derivatives of many functions are well known. Here are some useful rules to help you work out the derivatives of more complicated functions (with examples below). Note: the little mark means "Derivative of".
Common FunctionsFunctionDerivative
Constantc0
 x1
Squarex22x
Square Root√x(½)x
Exponentialexex
 axax(ln a)
Logarithmsln(x)1/x
 loga(x)1 / (x ln(a))
Trigonometry (x is in radians)sin(x)cos(x)
 cos(x)−sin(x)
 tan(x)sec2(x)
 sin-1(x)1/√(1−x2)
 cos-1(x)−1/√(1−x2)
 tan-1(x)1/(1+x2)
   
RulesFunctionDerivative
Multiplication by constantcfcf’
Power Rulexnnxn−1
Sum Rulef + gf’ + g’
Difference Rulef - gf’ − g’
Product Rulefgf g’ + f’ g
Quotient Rulef/g(f’ g − g’ f )/g2
Reciprocal Rule1/f−f’/f2
Chain Rule
(as "Composition of Functions")
f º g(f’ º g) × g’
Chain Rule (in a different form)f(g(x))f’(g(x))g’(x)
"The derivative of" is also written 

Examples

Example: what is the derivative of sin(x) ?

From the table above it is listed as being cos(x)
It can be written as:
sin(x) = cos(x)
Or:
sin(x)’ = cos(x)

Power Rule

Example: What is x3 ?

The question is asking "what is the derivative of x3?"
We can use the Power Rule, where n=3:
xn = nxn−1
x3 = 3x3−1 = 3x2

Example: What is (1/x) ?

1/x is also x-1
We can use the Power Rule, where n = −1:
xn = nxn−1
x−1 = −1x−1−1 = −x−2

Multiplication by constant

Example: What is 5x?

the derivative of cf = cf’
the derivative of 5f = 5f’
We know (from the Power Rule):
x3 = 3x3−1 = 3x2
So:
5x3 = 5x3 = 5 × 3x2 = 15x2

Sum Rule

Example: What is the derivative of x2+x?

The Sum Rule says:
the derivative of f + g = f’ + g’
So we can work out each derivative separately and then add them.
Using the Power Rule:
  • x2 = 2x
  • x3 = 3x2
And so:
the derivative of x2 + x3 = 2x + 3x2

Difference Rule

It doesn't have to be x, we can differentiate with respect to, for example, v:

Example: What is (v3−v4) ?

The Difference Rule says
the derivative of f − g = f’ − g’
So we can work out each derivative separately and then subtract them.
Using the Power Rule:
  • v3 = 3v2
  • v4 = 4v3
And so:
the derivative of v3 − v4 = 3v2 − 4v3

Sum, Difference, Constant Multiplication And Power Rules

Example: What is (5z2 + z3 − 7z4) ?

Using the Power Rule:
  • z2 = 2z
  • z3 = 3z2
  • z4 = 4z3
And so:
(5z2 + z3 − 7z4) = 5 × 2z + 3z2 − 7 × 4z3 = 10z + 3z2 − 28z3

Product Rule

Example: What is the derivative of cos(x)sin(x) ?

The Product Rule says:
the derivative of fg = f g’ + f’ g
In our case:
  • f = cos
  • g = sin
We know (from the table above):
  • cos(x) = −sin(x)
  • sin(x) = cos(x)
So:
the derivative of cos(x)sin(x) = cos(x)cos(x) − sin(x)sin(x)

cos2(x) − sin2(x)

 

Reciprocal Rule

Example: What is (1/x) ?

The Reciprocal Rule says:
the derivative of 1/f = −f’/f2
With f(x)= x, we know that f’(x) = 1
So:
the derivative of 1/x = −1/x2
Which is the same result we got above using the Power Rule.

Chain Rule

Example: What is sin(x2) ?

sin(x2) is made up of sin() and x2:
  • f(g) = sin(g)
  • g(x) = x2
The Chain Rule says:
the derivative of f(g(x)) = f'(g(x))g'(x)
The individual derivatives are:
  • f'(g) = cos(g)
  • g'(x) = 2x
So:
sin(x2) = cos(g(x)) × 2x
= 2x cos(x2)

Example: What is (1/sin(x)) ?

1/sin(x) is made up of 1/g and sin():
  • f(g) = 1/g
  • g(x) = sin(x)
The Chain Rule says:
the derivative of f(g(x)) = f’(g(x))g’(x)
The individual derivatives are:
  • f'(g) = −1/(g2)
  • g'(x) = cos(x)
So:
(1/sin(x))’ = −1/(g(x))2 × cos(x)
= −cos(x)/sin2(x)

Example: What is (5x−2)3 ?

The Chain Rule says:
the derivative of f(g(x)) = f’(g(x))g’(x)
(5x-2)3 is made up of g3 and 5x-2:
  • f(g) = g3
  • g(x) = 5x−2
The individual derivatives are:
  • f'(g) = 3g2 (by the Power Rule)
  • g'(x) = 5
So:
(5x−2)3 = 3g(x)2 × 5 = 15(5x−2)2

Functions

What is a Function?

A function relates an input to an output.
It is like a machine that has an input and an output.
And the output is related somehow to the input.

  f(x)  
"f(x) = ... " is the classic way of writing a function.
And there are other ways, as you will see!

Input, Relationship, Output

We will see many ways to think about functions, but there are always three main parts:
  • The input
  • The relationship
  • The output

Example: "Multiply by 2" is a very simple function.

Here are the three parts:
InputRelationshipOutput
0× 20
1× 22
7× 214
10× 220
.........
For an input of 50, what is the output?

Some Examples of Functions

  • x2 (squaring) is a function
  • x3+1 is also a function
  • Sine, Cosine and Tangent are functions used in trigonometry
  • and there are lots more!
But we are not going to look at specific functions ...
... instead we will look at the general idea of a function.

Names

First, it is useful to give a function a name.
The most common name is "f", but we can have other names like "g" ... or even "marmalade" if we want.
But let's use "f":
f(x)
We say "f of x equals x squared"
what goes into the function is put inside parentheses () after the name of the function:
So f(x) shows us the function is called "f", and "x" goes in
And we usually see what a function does with the input:
f(x) = x2 shows us that function "f" takes "x" and squares it.

Example: with f(x) = x2:
  • an input of 4
  • becomes an output of 16.
In fact we can write f(4) = 16.

The "x" is Just a Place-Holder!

Don't get too concerned about "x", it is just there to show us where the input goes and what happens to it.
It could be anything!
So this function:
f(x) = 1 - x + x2
Is the same function as:
  • f(q) = 1 - q + q2
  • h(A) = 1 - A + A2
  • w(θ) = 1 - θ + θ2
The variable (x, q, A, etc) is just there so we know where to put the values:
f(2) = 1 - 2 + 22 = 3

Sometimes There is No Function Name

Sometimes a function has no name, and we see something like:
y = x2
But there is still:
  • an input (x)
  • a relationship (squaring)
  • and an output (y)

Relating

At the top we said that a function was like a machine. But a function doesn't really have belts or cogs or any moving parts - and it doesn't actually destroy what we put into it!
A function relates an input to an output.
Saying "f(4) = 16" is like saying 4 is somehow related to 16. Or 4 → 16
Example: this tree grows 20 cm every year, so the height of the tree is related to its age using the function h:
h(age) = age × 20
So, if the age is 10 years, the height is:
h(10) = 10 × 20 = 200 cm
Here are some example values:
ageh(age) = age × 20
00
120
3.264
15300
......

What Types of Things Do Functions Process?

"Numbers" seems an obvious answer, but ...
... which numbers?
For example, the tree-height function h(age) = age×20 makes no sense for an age less than zero.
... it could also be letters ("A"→"B"), or ID codes ("A6309"→"Pass") or stranger things.
So we need something more powerful, and that is where sets come in:

A set is a collection of things.

Here are some examples:
Set of even numbers: {..., -4, -2, 0, 2, 4, ...}
Set of clothes: {"hat","shirt",...}
Set of prime numbers: {2, 3, 5, 7, 11, 13, 17, ...}
Positive multiples of 3 that are less than 10: {3, 6, 9}
Each individual thing in the set (such as "4" or "hat") is called a member, or element.
So, a function takes elements of a set, and gives back elements of a set.

A Function is Special

But a function has special rules:
  • It must work for every possible input value
  • And it has only one relationship for each input value
This can be said in one definition:

Formal Definition of a Function

A function relates each element of a set
with exactly one element of another set
(possibly the same set).

The Two Important Things!

1.
"...each element..." means that every element in X is related to some element in Y.
We say that the function covers X (relates every element of it).
(But some elements of Y might not be related to at all, which is fine.)
2.
"...exactly one..." means that a function is single valued. It will not give back 2 or more results for the same input.
So "f(2) = 7 or 9" is not right!
Note: "One-to-many" is not allowed, but "many-to-one" is allowed:
function function
(one-to-many) (many-to-one)
This is NOT OK in a function But this is OK in a function
When a relationship does not follow those two rules then it is not a function ... it is still arelationship, just not a function.

Example: The relationship x → x2

function
Could also be written as a table:
X: xY: x2
39
11
00
416
-416
......

It is a function, because:
  • Every element in X is related to Y
  • No element in X has two or more relationships
So it follows the rules.
(Notice how both 4 and -4 relate to 16, which is allowed.)

Example: This relationship is not a function:

function
It is a relationship, but it is not a function, for these reasons:
  • Value "3" in X has no relation in Y
  • Value "4" in X has no relation in Y
  • Value "5" is related to more than one value in Y
(But the fact that "6" in Y has no relationship does not matter)

not single valued

Vertical Line Test

On a graph, the idea of single valued means that no vertical line ever crosses more than one value.
If it crosses more than once it is still a valid curve, but isnot a function.

Some types of functions have stricter rules, to find out more you can read Injective, Surjective and Bijective

Infinitely Many

My examples have just a few values, but functions usually work on sets with infinitely many elements.

Example: y = x3

  • The input set "X" is all Real Numbers
  • The output set "Y" is also all the Real Numbers
We can't show ALL the values, so here are just a few examples:
X: xY: x3
-2-8
-0.1-0.001
00
1.11.331
327
and so on...and so on...

Domain, Codomain and Range

In our examples above
  • the set "X" is called the Domain,
  • the set "Y" is called the Codomain, and
  • the set of elements that get pointed to in Y (the actual values produced by the function) is called the Range.
We have a special page on Domain, Range and Codomain if you want to know more.

So Many Names!

Functions have been used in mathematics for a very long time, and lots of different names and ways of writing functions have come about.
Here are some common terms you should get familiar with:
Function Parts
Example: with z = 2u3:
  • "u" could be called the "independent variable"
  • "z" could be called the "dependent variable" (it depends on the value of u)
Example: with f(4) = 16:
  • "4" could be called the "argument"
  • "16" could be called the "value of the function"

Ordered Pairs

And here is another way to think about functions:
Write the input and output of a function as an "ordered pair", such as (4,16).
They are called ordered pairs because the input always comes first, and the output second:
(input, output)
So it looks like this:
xf(x) )
Example:
(4,16) means that the function takes in "4" and gives out "16"

Set of Ordered Pairs

A function can then be defined as a set of ordered pairs:
Example: {(2,4), (3,5), (7,3)} is a function that says
"2 is related to 4", "3 is related to 5" and "7 is related 3".
Also, notice that:
  • the domain is {2,3,7} (the input values)
  • and the range is {4,5,3} (the output values)
But the function has to be single valued, so we also say
"if it contains (a, b) and (a, c), then b must equal c"
Which is just a way of saying that an input of "a" cannot produce two different results.
Example: {(2,4), (2,5), (7,3)} is not a function because {2,4} and {2,5} means that 2 could be related to 4 or 5.
In other words it is not a function because it is not single valued

 

interactive-cartesian-coordinates 

A Benefit of Ordered Pairs

We can graph them...
... because they are also coordinates!
So a set of coordinates is also a function (if they follow
the rules above, that is)

 

A Function Can be in Pieces

We can create functions that behave differently depending on the input value

Example: A function with two pieces:

  • when x is less than 0, it gives 5,
  • when x is 0 or more it gives x2
Piecewise FunctionHere are some example values:
xy
-35
-15
00
24
416
......
Read more at Piecewise Functions.

Explicit vs Implicit

One last topic: the terms "explicit" and "implicit".
"Explicit" is when the function shows us how to go directly from x to y, such as:
y = x3 - 3
When we know x, we can find y
That is the classic y = f(x) style.
"Implicit" is when it is not given directly such as:
x2 - 3xy + y= 0
When we know x, how do we find y?
It may be hard (or impossible!) to go directly from x to y.
"Implicit" comes from "implied", in other words shown indirectly.

Graphing

  • The Function Grapher can only handle explicit functions,
  • The Equation Grapher can handle both types (but takes a little longer, and sometimes gets it wrong).

Conclusion

  • a function relates inputs to outputs
  • a function takes elements from a set (the domain) and relates them to elements in a set (the codomain).
  • all the outputs (the actual values related to) are together called the range
  • a function is a special type of relation where:
    • every element in the domain is included, and
    • any input produces only one output (not this or that)
  • an input and its matching output are together called an ordered pair
  • so a function can also be seen as a set of ordered pairs