Calculus

Calculus

The word Calculus comes from Latin meaning "small stone",
Because it is like understanding something by looking at small pieces.
Differential Calculus cuts something into small pieces to find how it changes. 
Integral Calculus joins (integrates) the small pieces together to find how much there is.

Introduction to Calculus

Calculus is all about changes.
Sam and Alex are travelling in the car ... but the speedometer is broken.
Alex:
"Hey Sam! How fast are we going now?"
Sam:
"Wait a minute ..."
"Well in the last minute we went 1.2 km, so we are going:"
1.2 km/minute x 60 minutes in an hour = 72 km/h
Alex:
"No, Sam! Not our average for the last minute, or even the last second, I want to know our speed RIGHT NOW."
Sam:
"OK, let us measure it up here ... at this road marker... NOW!"
"OK, we were AT the road marker for zero seconds, and the distance was ... zero meters!"
The speed is 0m / 0s = 0/0 = I Don't Know!
"I can't calculate it Sam! I need to know some distance over some time, and you are saying the time should be zero? Can't be done."

That is pretty amazing ... you'd think it is easy to work out the speed of a car at any point in time, but it isn't.
Even the speedometer of a car (when it works!) just shows us an average of how fast we were going for the last short amount of time.

How About Getting Real Close

But our story is not finished yet!
Sam and Alex get out of the car, because they have arrived on location. Sam is about to do a stunt:

Sam will do a jump off a 20 m building.

Alex, as photographer, asks:

"How fast will you be falling after 1 second?"

Sam uses this simplified formula to find the distance fallen:
d = 5t2
  • d = distance fallen, in meters
  • t = time from jump, in seconds
Example: at 1 second Sam has fallen
d = 5t2 = 5 × 12 = 5 m
But how fast is that? Speed is distance over time:
Speed =distance
time
So at 1 second:
Speed =5 m= 5 m/s
1 second
"BUT", says Alex, "again that is an average speed, since you started the jump, ... I want to know the speed at exactly 1 second, so I can set up the camera properly."

Well ... at exactly 1 second the speed is:
Speed =5 − 5 m=0 m= ????
1 − 1 s0 s
So again Sam has a problem.
Think about it ... how do we figure out a speed at an exact instant in time?
What is the distance? What is the time difference?
They are both zero, giving us nothing to calculate with!
But Sam has an idea ... invent a time so short it won't matter.
Sam won't even give it a value, and will just call it "Δt" (called "delta t").
So Sam works out the difference in distance between t and t+Δt
At 1 second Sam has fallen
d = 5t2 = 5 × (1)2 = 5 m

At (1+Δt) seconds Sam has fallen
d = 5t2 = 5 × (1+Δt)2 m

We can expand (1+Δt)2:
(1+Δt)2= (1+Δt)(1+Δt)
1 + 2Δt + (Δt)2

And we get:
d= 5 × (1+2Δt+(Δt)2) m
5 + 10Δt + 5(Δt)2 m


So between 1 second and (1+Δt) seconds the distance fallen is:
Change in d= (5 + 10Δt + 5(Δt)2) − 5 m
10Δt + 5(Δt)2 m

Now divide that distance by time to get the speed:
Speed10Δt +5(Δt)2 mΔt s
= 10 + 5Δt m/s

So the speed is 10 + 5Δt m/s, and Sam thinks about that Δt value ... he wants Δt to be so small it won't matter ... so he imagines it shrinking towards zero and he gets:
Speed = 10 m/s

Wow! Sam got an answer!

Sam: "I will be falling at exactly 10 m/s"
Alex: "I thought you said you couldn't calculate it?"
Sam: "That was before I used Calculus!"

Yes, indeed, that was Calculus.
The word Calculus comes from Latin meaning "small stone".
Because it is like understanding something by looking at small pieces.
Differential Calculus cuts something into small pieces to find how it changes. 
Integral Calculus joins (integrates) the small pieces together to find how much there is.
And Differential Calculus and Integral Calculus are like inverses of each other, just like multiplication and division are inverses.

Sam used Differential calculus to cut time and distance into such small pieces that a pure answer came out.

So ... was Sam's result just luck? Does it work for other things?
Let's try doing this for the function y = x3
This is going to be very similar to the previous example, but it will be just a slope on a graph, no one has to jump for this one!

Example: What is the slope of the function y = x3 at x=1 ?

At x = 1, y = 13 = 1
At x = (1+Δx), y = (1+Δx)3

We can expand (1+Δx)3 to 1 + 3Δx + 3(Δx)2 + (Δx)3, and we get:
y = 1 + 3Δx + 3(Δx)2 + (Δx)3

And the difference between the y values from x = 1 to x = 1+Δx is:
Change in y= 1 + 3Δx + 3(Δx)2 + (Δx)3 − 1
3Δx + 3(Δx)2 + (Δx)3

Now we can calculate slope:
Slope =3Δx + 3(Δx)2 + (Δx)3Δx
= 3 + 3Δx + (Δx)2

Once again, as Δx shrinks towards zero we are left with:
Slope = 3
And here we see the graph of y = x3

The slope is continually changing, but at the
point (1,1) we can draw a line tangent to the curve
and find the slope there really is 3.
(Count the squares if you want!)
Question for you: what is the slope at the point (2,8)?

Try It Yourself!

Go to the Slope of a Function page, put in the formula "x^3", then try to find the slope at the point (1,1).
Zoom in closer and closer and see what value the slope is heading towards.

Conclusion

Calculus is about changes.
Differential calculus cuts something into small pieces to find how it changes.
Integral calculus joins (integrates) the small pieces together to find how much there is.

Limits (An Introduction)

Approaching ...

Sometimes we can't work something out directly ... but we can see what it should be as we get closer and closer!

Example:

(x2 − 1)(x − 1)
Let's work it out for x=1:
(1− 1)(1 − 1) = (1 − 1)(1 − 1) = 00
Now 0/0 is a difficulty! We don't really know the value of 0/0 (it is "indeterminate"), so we need another way of answering this.
So instead of trying to work it out for x=1 let's try approaching it closer and closer:

Example Continued:

x(x2 − 1)(x − 1)
0.51.50000
0.91.90000
0.991.99000
0.9991.99900
0.99991.99990
0.999991.99999
......
Now we see that as x gets close to 1, then (x2−1)(x−1) gets close to 2
We are now faced with an interesting situation:
  • When x=1 we don't know the answer (it is indeterminate)
  • But we can see that it is going to be 2
We want to give the answer "2" but can't, so instead mathematicians say exactly what is going on by using the special word "limit"
The limit of (x2−1)(x−1) as x approaches 1 is 2
And it is written in symbols as:
So it is a special way of saying, "ignoring what happens when we get there, but as we get closer and closer the answer gets closer and closer to 2"
As a graph it looks like this:
So, in truth, we cannot say what the value at x=1 is.
But we can say that as we approach 1, the limit is 2.

Test Both Sides!

It is like running up a hill and then finding the pathis magically "not there"...
... but if we only check one side, who knows what happens?
So we need to test it from both directions to be sure where it "should be"!

Example Continued

So, let's try from the other side:
x(x2 − 1)(x − 1)
1.52.50000
1.12.10000
1.012.01000
1.0012.00100
1.00012.00010
1.000012.00001
......
Also heading for 2, so that's OK

When it is different from different sides

How about a function f(x) with a "break" in it like this:
The limit does not exist at "a"
We can't say what the value at "a" is, because there are two competing answers:
  • 3.8 from the left, and
  • 1.3 from the right
But we can use the special "−" or "+" signs (as shown) to define one sided limits:
  • the left-hand limit (−) is 3.8
  • the right-hand limit (+) is 1.3
And the ordinary limit "does not exist"

Are limits only for difficult functions?

Limits can be used even when we know the value when we get there! Nobody said they are only for difficult functions.

Example:

We know perfectly well that 10/2 = 5, but limits can still be used (if we want!)

Approaching Infinity

Infinity is a very special idea. We know we can't reach it, but we can still try to work out the value of functions that have infinity in them.

Let's start with an interesting example.

Question: What is the value of 1 ?

Answer: We don't know!

Why don't We know?

The simplest reason is that Infinity is not a number, it is an idea.
So 1 is a bit like saying 1beauty or 1tall.
Maybe we could say that 1= 0, ... but that is a problem too, because if we divide 1 into infinite pieces and they end up 0 each, what happened to the 1?
In fact 1 is known to be undefined.

But We Can Approach It!

So instead of trying to work it out for infinity (because we can't get a sensible answer), let's try larger and larger values of x:
x1x
11.00000
20.50000
40.25000
100.10000
1000.01000
1,0000.00100
10,0000.00010
Now we can see that as x gets larger, 1x tends towards 0
We are now faced with an interesting situation:
  • We can't say what happens when x gets to infinity
  • But we can see that 1x is going towards 0
We want to give the answer "0" but can't, so instead mathematicians say exactly what is going on by using the special word "limit"
The limit of 1x as x approaches Infinity is 0
And write it like this:
In other words:
As x approaches infinity, then 1x approaches 0

When you see "limit", think "approaching"

It is a mathematical way of saying "we are not talking about when x=, but we know as x gets bigger, the answer gets closer and closer to 0".

Solving!

We have been a little lazy so far, and just said that a limit equals some value because it looked like it was going to.

Continuous Functions

A function is continuous when its graph is a single unbroken curve ...
pencil... that you could draw without lifting your pen from the paper.
That is not a formal definition, but it helps you understand the idea.
Here is a continuous function:
x^4-2x^2+x

Examples

So what is not continuous (also called discontinuous) ?
Look out for holes, jumps or vertical asymptotes (where the function heads up/down towards infinity).
Not ContinuousNot ContinuousNot Continuous
(hole)(jump)(vertical asymptote)

Domain

A function has a Domain.
In its simplest form the domain is all the values that go into a function.
doman and range
A function might be continuous or not, depending on its Domain!

Example: 1/(x-1)

At x=1 we have:
1/(1-1) = 1/0 = undefined
So there is a "discontinuity" at x=1
f(x) = 1/(x-1)
over all Real Numbers
g(x) = 1/(x-1) for x>1
NOT continuousContinuous

g(x) does not include the value x=1, so it is continuous.
So when a function is continuous within its Domain, it is a continuous function.

More Formally !

We can define continuous using Limits (it helps to read that page first):
A function f is continuous when, for every value c in its Domain:
f(c) is defined, and:

"the limit of f(x) as x approaches c equals f(c)"
The limit says:
"as x gets closer and closer to c
then f(x) gets closer and closer to f(c)"
And we have to check from both directions:
as x approaches c (from left)
then f(x) approaches f(c)
AND
as x approaches c (from right)
then f(x) approaches f(c)
If we get different values from left and right (a "jump"), then the limit does not exist!

How to Use:

Make sure that, for all x values:
  • f(x) is defined
  • and the limit at x equals f(x)
Here are some examples:

Example: f(x) = (x2-1)/(x-1) for all Real Numbers

The function is undefined when x=1:
(x2-1)/(x-1) = (12-1)/(1-1) = 0/0
So it is not a continuous function
Let us change the domain:

Example: g(x) = (x2-1)/(x-1) over the interval x<1

Almost the same function, but now it is over an interval that does not include x=1.
So now it is a continuous function (does not include the "hole")

Example: How about this piecewise function:

which looks like:
It is defined at x=1, because h(1)=2 (no "hole")
But at x=1 you can't say what the limit is, because there are two competing answers:
  • "2" from the left, and
  • "1" from the right
so in fact the limit does not exist at x=1 (there is a "jump")
And so the function is not continuous.
But:

Example: How about the piecewise function absolute value:

Absolute Value functionwhich looks like:Absolute Value function
At x=0 it has a very pointy change!
But it is still defined at x=0, because f(0)=0 (so no "hole"),
And the limit as you approach x=0 (from either side) is also 0 (so no "jump"),
So it is in fact continuous.
(But it is not differentiable.)

Derivatives (Differential Calculus)

The Derivative is the "rate of change" or slope of a function.

Introduction to Derivatives

It is all about slope!
Slope  = 
Change in Y
Change in X
gradient

We can find an average slope between two points.

But how do we find the slope at a point?
There is nothing to measure!
But with derivatives we use a small difference ...
... then have it shrink towards zero.

Let us Find a Derivative!

We will use the slope formula:
Slope  = Change in Y  =  Δy
Change in XΔx
to find the derivative of a function y = f(x)
x changes from x to x+Δx
y changes from f(x) to f(x+Δx)
Follow these steps:
• Fill in this slope formula:
Δy = f(x+Δx) − f(x)
ΔxΔx
• Simplify it as best we can,
• Then make Δx shrink towards zero.
Here we go:

Example: the function f(x) = x2

We know f(x) = x2, and can calculate f(x+Δx:
Start with:f(x+Δx) = (x+Δx)2
Expand (x + Δx)2:f(x+Δx) = x2 + 2x Δx + (Δx)2

Start with the slope formula:
f(x+Δx) − f(x)
Δx
Put in f(x+Δx) and f(x):
x2 + 2x Δx + (Δx)2 − x2
Δx
Simplify (x2 and −x2 cancel):
 = 2x Δx + (Δx)2
Δx
Simplify more (divide through by Δx):  = 2x + Δx
And then as Δx heads towards 0 we get:= 2x

Result: the derivative of x2 is 2x

We write dx instead of "Δx heads towards 0", so "the derivative of" is commonly written 
x2 = 2x
"The derivative of x2 equals 2x"
or simply "d dx of x2 equals 2x"

What does x2 = 2x mean?

It means that, for the function x2, the slope or "rate of change" at any point is 2x.
So when x=2 the slope is 2x = 4, as shown here:
Or when x=5 the slope is 2x = 10, and so on.
Note: sometimes f’(x) is also used for "the derivative of":
f’(x) = 2x
"The derivative of f(x) equals 2x"

Let's try another example.

Example: What is x3 ?

We know f(x) = x3, and can calculate f(x+Δx:
Start with:f(x+Δx) = (x+Δx)3
Expand (x + Δx)3:f(x+Δx) = x3 + 3x2 Δx + 3x (Δx)2 + (Δx)3

The slope formula:
f(x+Δx) − f(x)
Δx
Put in f(x+Δx) and f(x):
x3 + 3x2 Δx + 3x (Δx)2 + (Δx)3 − x3
Δx
Simplify (x3 and −x3 cancel):
 = 3x2 Δx + 3x (Δx)2 + (Δx)3
Δx
Simplify more (divide through by Δx):  = 3x2 + 3x Δx + (Δx)2
And then as Δx heads towards 0 we get:x3 = 3x2
Have a play with it using the Derivative Plotter.

Derivatives of Other Functions

We can use the same method to work out derivatives of other functions (like sine, cosine, logarithms, etc).
But in practice the usual way to find derivatives is to use:
Derivative Rules

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

On Derivative Rules it is listed as being cos(x)
Done.
Using the rules can be tricky!

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

You can't just find the derivative of cos(x) and multiply it by the derivative of sin(x) ... you must use the "Product Rule" as explained on the Derivative Rules page.
It actually works out to be cos2(x) - sin2(x)
So that is your next step: learn how to use the rules.

Notation

"Shrink towards zero" is actually written as a limit like this:

"The derivative of f equals the limit as Δx goes to zero of f(x+Δx) - f(x) over Δx

Or sometimes the derivative is written like this (explained on Derivatives as dy/dx):
 

The process of finding a derivative is called "differentiation".
You do differentiation ... to get a derivative.

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

Derivatives as dy/dx


Derivatives are all about change ...
... they show how fast something is changing (called the rate of change) at any point.

In Introduction to Derivatives (please read it first!) we looked at how to do a derivative usingdifferences and limits.
Here we look at doing the same thing but using the "dy/dx" notation (also called Leibniz's notation) instead of limits.

We start by calling the function "y":
y = f(x)

1. Add Δx

When x increases by Δx, then y increases by Δy
y + Δy = f(x + Δx)

2. Subtract the Two Formulas

From:
y + Δy = f(x + Δx)
Subtract:
y = f(x)
To Get:
y + Δy - y = f(x + Δx) - f(x)
Simplify:
Δy = f(x + Δx) - f(x)

3. Rate of Change

To work out how fast (called the rate of change) we divide by Δx:

4. Reduce Δx close to 0

We can't let Δx become 0 (because that would be dividing by 0), but we can make it head towards zero and call it "dx":
Δx  dx
You can also think of "dx" as being infinitesimal, or infinitely small.
Likewise Δy becomes very small and we call it "dy", to give us:
 

Try It On A Function

Let's try f(x) = x2

 

f(x) = x2
Expand (x+dx)2
Simplify (x2-x2=0)
Simplify fraction
dx goes towards 0

 

Second Derivative

(Read about derivatives first if you don't already know what they are!)
A derivative basically gives you the slope of a function at any point.
The "Second Derivative" is the derivative of the derivative of a function. So:
  • Find the derivative of a function
  • Then take the derivative of that
A derivative is often shown with a little tick mark: f'(x)
The second derivative is shown with two tick marks like this: f''(x)

Example: f(x) = x3

  • Its derivative is f'(x) = 3x2
  • The derivative of 3x2 is 6x, so the second derivative of f(x) is:
f''(x) = 6x
A derivative can also be shown as:  dy , and the second derivative shown as:  d2y
dxdx2

Example: (continued)

The previous example could be written like this:
y = x3
dy = 3x2 
dx
d2y = 6x
dx2

Distance, Speed and Acceleration

A common real world example of this is distance, speed and acceleration:

Example: A bike race!

You are cruising along in a bike race, going a steady 10 m every second.
Distance: is how far you have moved along your path. It is common to use s for distance (from the Latin "spatium").
So let us use:
  • distance (in meters): s
  • time (in seconds): t

Speed: is how much your distance s changes over time t ...
... and is actually the first derivative of distance with respect to time:  
ds
dt
And we know you are doing 10 m per second, so  ds  = 10 m/s
dt

Acceleration: Now you start cycling faster! You increase your speed to 14 m every second over the next 2 seconds.
When you are accelerating your speed is changing over time.
So  ds  is changing over time!
dt
We could write it like this:  
dds
dt
dt
But it is usually written  d2s
dt2
Your speed increases by 4 m/s over 2 seconds, so  d2s  = 4/2  = 2 m/s2
dt2

Your speed changes by 2 meters per second per second.
And yes, "per second" is used twice!
It can be thought of as (m/s)/s but is usually written m/s2

(Note: in the real world your speed and acceleration changes moment to moment, but here we assume you can hold a constant speed or constant acceleration.)

So:Example
Measurement
Distance:s100 m
First Derivative is Speed:
ds
dt
10 m/s
Second Derivative is Acceleration:
d2s
dt2
2 m/s2
And the third derivative (how acceleration changes over time) is called "Jolt" ... !

Differentiable

Differentiable means that the derivative exists ...

Example: is x2 + 6x differentiable?

Its derivative is 2x + 6
(Because Derivative rules tell us the derivative of x2 is 2x and the derivative of x is 1.)
So yes! x2 + 6x is differentiable.
... and it must exist for every value in the function's domain.

Domain

In its simplest form the domain is
all the values that go into a function
doman and range

Example (continued)

When not stated we assume that the domain is the Real Numbers.
For x2 + 6x, its derivative of 2x + 6 exists for all Real Numbers.
So we are still safe ... x2 + 6x is differentiable.
But what about this:

Example: The function f(x) = |x| (absolute value):

|x| looks like this:Absolute Value function
At x=0 it has a very pointy change!
Does the derivative exist at x=0?

Testing

We can test any value "c" by finding if the limit exists:
lim
h→0
f(c+h) − f(c)
h

Example (continued)

Let's calculate the limit for |x| at the value 0:
lim
h→0
|0+h| − |0|  =  lim
h→0
|h| − 0  =  lim
h→0
|h|
hhh

The limit does not exist

To see why, let's compare left and right side limits:
From Left Side:From Right Side:
lim
h→0
|h|  =  −1
h
lim
h→0+
|h|  =  +1
h
The limits are different on either side, so the limit does not exist.

So the function f(x) = |x| is not differentiable
A good way to picture this in your mind is to think:
As I zoom in, does the function tend to become a straight line?
The absolute value function stays pointy even when zoomed in.

Other Reasons

Here are a few more examples:
Floor function
The Floor and Ceiling Functions are not differentiable at integer values, as there is a discontinuity at each jump. But they are differentiable elsewhere.
The Cube root function x(1/3)
Its derivative is (1/3)x-(2/3) (by the Power Rule)
At x=0 the derivative is undefined, so x(1/3) is not differentiable.
At x=0 the function is not defined so it makes no sense to ask if they are differentiable there.
To be differentiable at a certain point, the function must first of all be defined there!
As we head towards x = 0 the function moves up and down faster and faster, so we cannot find a value it is "heading towards".
So it is not differentiable.

Different Domain

But we can change the domain!

Example: The function g(x) = |x| with Domain (0,+∞)

The domain is from but not including 0 onwards (all positive values).
Which IS differentiable.
(And I am "absolutely positive" about that.)
So the function g(x) = |x| with Domain (0,+∞) is differentiable.
We could also restrict the domain in other ways to avoid x=0 (such as all negative Real Numbers, all non-zero Real Numbers, etc).

Why Bother?

Because when a function is differentiable we can use all the power of calculus when working with it.

Continuous

When a function is differentiable it is also continuous.
Differentiable  Continuous
But a function can be continuous but not differentiable. For example the absolute value function is actually continuous (though not differentiable) at x=0.

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.

Integration (Integral Calculus)

Integration can be used to find areas, volumes, central points and many useful things.









Introduction to Integration

Integration is a way of adding slices to find the whole.
Integration can be used to find areas, volumes, central points and many useful things. But it is easiest to start with finding the area under the curve of a function like this:

What is the area under y = f(x) ?

Slices

We could calculate the function at a few points and add up slices of width Δx like this (but the answer won't be very accurate):
We can make Δx a lot smaller and add up many small slices(answer is getting better):

And as the slices approach zero in width, the answer approaches thetrue answer.
We now write dx to mean the Δx slices are approaching zero in width.

That is a lot of adding up!

But we don't have to add them up, as there is a "shortcut". Because ...
... finding an Integral is the reverse of finding a Derivative.
(So you should really know about Derivatives before reading more!)
Like here:

Example: What is an integral of 2x?


We know that the derivative of x2 is 2x ...

... so an integral of 2x is x2
You will see more examples later.

Notation

The symbol for "Integral" is a stylish "S"
(for "Sum", the idea of summing slices):
After the Integral Symbol we put the function we want to find the integral of (called the Integrand),
and then finish with dx to mean the slices go in the x direction (and approach zero in width).
And here is how we write the answer:

Plus C

We wrote the answer as x2 but why + C ?
It is the "Constant of Integration". It is there because of all the functions whose derivative is 2x:
The derivative of x2+4 is 2x, and the derivative of x2+99 is also 2x, and so on! Because the derivative of a constant is zero.
So when we reverse the operation (to find the integral) we only know 2x, but there could have been a constant of any value.
So we wrap up the idea by just writing + C at the end.

Tap and Tank

Integration is like filling a tank from a tap.
The input (before integration) is the flow rate from the tap.
Integrating the flow (adding up all the little bits of water) gives us thevolume of water in the tank.

Imagine the flow starts at 0 and gradually increases (maybe a motor is slowly opening the tap).
As the flow rate increases, the tank fills up faster and faster.
With a flow rate of 2x, the tank fills up at x2.
We have integrated the flow to get the volume.
Example: (assuming the flow is in liters per minute) after 3 minutes (x=3):
  • the flow rate has reached 2x = 2×3 = 6 liters/min,
  • and the volume has reached x2 = 32 = 9 liters.

We can do the reverse, too:
Imagine you don't know the flow rate.
You only know the volume is increasing by x2.
We can go in reverse (using the derivative, which gives us the slope) and find that the flow rate is 2x.
Example: at 2 minutes the slope of the volume is 4, meaning it is increasing at 4 liters/minute, which is the flow rate. Likewise at 3 minutes the slope is 6, etc.
So Integral and Derivative are opposites.
We can write that down this way:
The integral of the flow rate 2x tells us the volume of water:
2x dx = x2 + C
And the slope of the volume increase x2+C gives us back the flow rate:
(x2 + C) = 2x

And hey, we even get a nice explanation of that "C" value ... maybe the tank already has water in it!
  • The flow still increases the volume by the same amount
  • And the increase in volume can give us back the flow rate.
Which teaches us to always add "+ C".

Other functions

Well, we have played with y=2x enough now, so how do we integrate other functions?
If we are lucky enough to find the function on the result side of a derivative, then (knowing that derivatives and integrals are opposites) we have an answer. But remember to add C.

Example: what is cos(x) dx ?

From the Rules of Derivatives table we see the derivative of sin(x) is cos(x) so:
cos(x) dx = sin(x) + C
But a lot of this "reversing" has already been done (see Rules of Integration).

Example: What is x3 dx ?

On Rules of Integration there is a "Power Rule" that says:
xn dx = xn+1/(n+1) + C
We can use that rule with n=3:
xdx = x4 /4 + C
Knowing how to use those rules is the key to being good at Integration.
So get to know those rules and get lots of practice.
Learn the Rules of Integration and Practice! Practice! Practice!
(there are some questions below)

Definite vs Indefinite Integrals

We have been doing Indefinite Integrals so far.
Definite Integral has actual values to calculate between (they are put at the bottom and top of the "S"):
Indefinite IntegralDefinite Integral

Integration Rules

Integration

Integration can be used to find areas, volumes, central points and many useful things. But it is often used to find the area underneath the graph of a function like this:

The integral of many functions are well known, and there are useful rules to work out the integral of more complicated functions, many of which are shown here.
There are examples below to help you.
Common FunctionsFunctionIntegral
Constanta dxax + C
Variablex dxx2/2 + C
Squarex2 dxx3/3 + C
Reciprocal(1/x) dxln|x| + C
Exponentialex dxex + C
ax dxax/ln(a) + C
ln(x) dxx ln(x) − x + C
Trigonometry (x in radians)cos(x) dxsin(x) + C
sin(x) dx-cos(x) + C
sec2(x) dxtan(x) + C
RulesFunctionIntegral
Multiplication by constantcf(x) dxcf(x) dx
Power Rule (n≠-1)xn dxxn+1/(n+1) + C
Sum Rule(f + g) dxf dx + g dx
Difference Rule(f - g) dxf dx - g dx
Integration by PartsSee Integration by Parts
Substitution RuleSee Integration by Substitution

Examples

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

From the table above it is listed as being −cos(x) + C
It is written as:
sin(x) dx = −cos(x) + C

Power Rule

Example: What is x3 dx ?

The question is asking "what is the integral of x?"
We can use the Power Rule, where n=3:
xn dx = xn+1/(n+1) + C
xdx = x4/4 + C

Example: What is √x dx ?

√x is also x0.5
We can use the Power Rule, where n=½:
xn dx = xn+1/(n+1) + C
x0.5 dx = x1.5/1.5 + C

Multiplication by constant

Example: What is 6x2 dx ?

We can move the 6 outside the integral:
6x2 dx = 6x2 dx
And now use the Power Rule on x2:
= 6 x3/3 + C
Simplify:
= 2x3 + C

Sum Rule

Example: What is cos x + x dx ?

Use the Sum Rule:
cos x + x dx = cos x dx + dx
Work out the integral of each (using table above):
= sin x + x2/2 + C

Difference Rule

Example: What is ew − 3 dw ?

Use the Difference Rule:
ew − 3 dw =ew dw − dw
Then work out the integral of each (using table above):
= ew − 3w + C

Sum, Difference, Constant Multiplication And Power Rules

Example: What is 8z + 4z3 − 6z2 dz ?

Use the Sum and Difference Rule:
8z + 4z3 − 6z2 dz =8z dz + 4z3 dz − 6z2 dz
Constant Multiplication:
= 8z dz + 4z3 dz − 6z2 dz
Power Rule:
= 8z2/2 + 4z4/4 − 6z3/3 + C
Simplify:
= 4z2 + z4 − 2z3 + C


Integration by Parts

Integration by Parts is a special method of integration that is often useful when two functions are multiplied together, but is also helpful in other ways.
You will see plenty of examples soon, but first let us see the rule:
u v dx = uv dx −u' (v dx) dx
  • u is the function u(x)
  • v is the function v(x)
As a diagram:
And let us get straight into an example:

Example: What is x cos(x) dx ?

First choose u and v:
  • u = x
  • v = cos(x)
Differentiate u: u' = x' = 1
Integrate v: v dx = cos(x) dx = sin(x)   (see Integration Rules)
Now put it together:
Simplify and solve:
x sin(x) − sin(x) dx
x sin(x) + cos(x) + C

So we followed these steps:
  • Choose u and v
  • Differentiate u: u'
  • Integrate v: v dx
  • Put u, u' and ∫v dx here: uv dx −u' (v dx) dx
  • Simplify and solve
In English, to help you remember, u v dx becomes:
(u integral v) minus integral of (derivative u, integral v)

Let's try some more examples:

Example: What is ∫ln(x)/x2 dx ?

First choose u and v:
  • u = ln(x)
  • v = 1/x2
Differentiate u: ln(x)' = 1/x
Integrate v: 1/x2 dx = x-2 dx = −x-1 = -1/x   (by the power rule)
Now put it together:
Simplify:
−ln(x)/x − ∫1/x2 dx = −ln(x)/x − 1/x + C
−(ln(x) + 1)/x + C

Example: What is ln(x) dx ?

But there is only one function! How do we choose u and v ?
Hey! We can just choose v as being "1":
  • u = ln(x)
  • v = 1
Differentiate u: ln(x)' = 1/x
Integrate v: 1 dx = x
Now put it together:
Simplify:
x ln(x) − 1 dx = x ln(x) − x + C

Example: What is ∫ex x dx ?

Choose u and v:
  • u = ex
  • v = x
Differentiate u: (ex)' = ex
Integrate v: x dx = x2/2
Now put it together:
Well, that was a spectacular disaster! It just got more complicated.
Maybe we could choose a different u and v?

Example: ex x dx (continued)

Choose u and v differently:
  • u = x
  • v = ex
Differentiate u: (x)' = 1
Integrate v: ex dx = ex
Now put it together:
Simplify:
ex − ex + C
ex(x−1) + C
The moral of the story: Choose u and v carefully!
Choose a u that gets simpler when you differentiate it and a v that doesn't get any more complicated when you integrate it.
A helpful rule of thumb is I LATE. Choose u based on which of these comes first:
  • I: Inverse trigonometric functions such as sin-1(x), cos-1(x), tan-1(x)
  • L: Logarithmic functions such as ln(x), log(x)
  • A: Algebraic functions such as x2, x3
  • T: Trigonometric functions such as sin(x), cos(x), tan (x)
  • E: Exponential functions such as ex, 3x

And here is one last (and tricky) example:

Example: ex sin(x) dx

Choose u and v:
  • u = sin(x)
  • v = ex
Differentiate u: sin(x)' = cos(x)
Integrate v: ex dx = ex
Now put it together:
ex sin(x) dx = sin(x) ex -cos(x) ex dx

Looks worse, but let us persist! We can use integration by parts again:
Choose u and v:
  • u = cos(x)
  • v = ex
Differentiate u: cos(x)' = -sin(x)
Integrate v: ex dx = ex
Now put it together:
ex sin(x) dx = sin(x) ex - (cos(x) ex −−sin(x) ex dx)
Simplify:
ex sin(x) dx = ex sin(x) - ex cos(x) − ex sin(x)dx
Now we have the same integral on both sides (except one is subtracted) ...
... so bring the right hand one over to the left and we get:
2ex sin(x) dx = ex sin(x) − ex cos(x)
Simplify:
ex sin(x) dx = ex (sin(x) - cos(x)) / 2 + C

Where Did "Integration by Parts" Come From?

It is based on the Product Rule for Derivatives:
(uv)' = uv' + u'v
Integrate both sides and rearrange:
(uv)' dx = uv' dx + u'v dx
uv = uv' dx + u'v dx
uv' dx = uv − u'v dx
Some people prefer that last form, but I like to integrate v' so the left side is simple:
uv dx = uv dx − u'(v dx) dx

Integration by Substitution

"Integration by Substitution" (also called "u-substitution") is a method to find an integral, but only when it can be set up in a special way.
The first and most vital step is to be able to write our integral in this form:

Note that we have g(x) and its derivative g'(x)
Like in this example:

Here f=cos, and we have g=x2 and its derivative of 2x
This integral is good to go!
When our integral is set up like that, we can do this substitution:
Then we can integrate f(u), and finish by putting g(x) back as u.
Like this:

Example: cos(x2) 2x dx

We know (from above) that it is in the right form to do the substitution:
Now integrate:
cos(u) du = sin(u) + C
And finally put u=x2 back again:
sin(x2) + C
So cos(x2) 2x dx = sin(x2) + C worked out really nicely! (Well, I knew it would.)
This method only works on some integrals of course, and it may need rearranging:

Example: cos(x2) 6x dx

Oh no! It is 6x, not 2x. Our perfect setup is gone.
Never fear! Just rearrange the integral like this:
cos(x2) 6x dx = 3cos(x2) 2x dx
(We can pull constant multipliers outside the integration, see Rules of Integration.)
Then go ahead as before:
3cos(u) du = 3 sin(u) + C
Now put u=x2 back again:
3 sin(x2) + C
Done!
Now we are ready for a slightly harder example:

Example: x/(x2+1) dx

Let me see ... the derivative of x2+1 is 2x ... so how about we rearrange it like this:
x/(x2+1) dx = ½2x/(x2+1) dx
Then we have:
Then integrate:
½1/u du = ½ ln(u) + C
Now put u=x2+1 back again:
½ ln(x2+1) + C
And how about this one:

Example: (x+1)3 dx

Let me see ... the derivative of x+1 is ... well it is simply 1.
So we can have this:
(x+1)3 dx = (x+1)3 · 1 dx
Then we have:
Then integrate:
u3 du = (u4)/4 + C
Now put u=x+1 back again:
(x+1)4 /4 + C
So there you have it.

In Summary

When we can put an integral in this form:
Then we can make u=g(x) and integrate f(u) du
And finish up by re-inserting g(x) where u is.

Differential Equations

In our world things change, and describing how they change often ends up as a Differential Equation: an equation with a function and one or more of its derivatives:

Differential Equations

Differential Equation is an equation with a function and one or more of its derivatives:

Example: an equation with the function y and its derivative dydx  

Solving

We solve it when we discover the function y (or set of functions y).
There are many "tricks" to solving Differential Equations (if they can be solved!), but first: why?

Why Are Differential Equations Useful?

In our world things change, and describing how they change often ends up as a Differential Equation:

Example: Rabbits!

The more rabbits we have the more baby rabbits we will get. Then those rabbits grow up and have babies too! The population will grow faster and faster.
The important parts of this are:
  • the population N at any time t
  • the growth rate r
  • the population's rate of change N
The rate of change (such as "new rabbits per week") at any time equals the growth ratetimes the current population:
dN  = rN
dt
It is a Differential Equation, because it has a function N(t) and its derivative.

And how powerful is mathematics! That short equation says "the rate of change of the population over time equals the growth rate times the population".
Differential Equations can describe how populations change, how heat moves, how springs vibrate, how radioactive material decays and much more. They are a very natural way to describe many things in the universe.

What To Do With Them?

We try to solve them by turning the Differential Equation into a simpler Algebra-style equation (without the differential bits) so we can do calculations, make graphs, predict the future, and so on.

Example: Compound Interest

Money earns interest. The interest can be calculated at fixed times, such as yearly, monthly, etc. and added to the original amount.
This is called compound interest.
But when it is compounded continuously then at any time the interest gets added in proportion to the current value of the loan (or investment).
And the bigger the loan the more interest it earns.
Using t for time, r for the interest rate and V for the current value of the loan:
dV  = rV
dt

And here is a cool thing: it is the same as the equation we got with the Rabbits! It just has different letters. So mathematics shows us these two things behave the same.

Solving
The Differential Equation says it well, but is hard to use.
But don't worry, it can be solved (using a special method called Separation of Variables) and results in:
V = Pert
Where P is the Principal (the original loan).
So a continuously compounded loan of $1,000 for 2 years at an interest rate of 10% becomes:
V = 1000 × e(2×0.1)
V = 1000 × 1.22140...
= $1,221.40
 (to nearest cent)
So Differential Equations are great at describing things, but need to be solved to be useful.

More Examples of Differential Equations

The Verhulst Equation

Example: Rabbits Again!

Remember our growth Differential Equation:
dN  = rN
dt

Well, that growth can't go on forever as they will soon run out of available food.
So let's improve it by including:
  • the maximum population that the food can support k
A guy called Verhulst figured it all out and got this Differential Equation:
dN  = rN(1-N/k)
dt
The Verhulst Equation

Simple harmonic motion

In Physics, Simple Harmonic Motion is a type of periodic motion where the restoring force is directly proportional to the displacement. An example of this is given by a mass on a spring.

Example: Spring and Weight

A spring has a weight attached to it: the weight is pulled down by gravity, but the tension in the spring increases the further down it goes. Eventually the spring bounces back up, then back down, up and down, again and again.
Describe this with mathematics!

The weight is pulled down by gravity, and we know from Newton's Law that force equals mass times acceleration: F = ma
And acceleration is the second derivative of position with respect to time, so:
F = m d2x
dt2

The spring pulls it back up based on how stretched it is (k is the spring's stiffness, and xis how stretched it is): F = -kx
The two forces are always equal:
m d2x  = -kx
dt2

We have a differential equation! It has a function x(t), and its second derivative.
The next step would be to solve this to find how the spring bounces up and down over time.
We could also include "damping" (the slowing down of the bouncing due to friction), as we know it won't bounce up and down the same forever.

Classify Before Trying To Solve

OK, we want to solve them, but how?
Over the years wise people have worked out special methods to solve some typesof Differential Equations.
It is like travel: different kinds of transport have solved how to get to certain places.
Is it near, so we can just walk? Is there a road so we can take a car? Is it over water so we need a ship? Or is it in another galaxy and we just can't get there yet?
So our first task is to classify the Differential Equation.

Ordinary or Partial

The first major grouping is:
  • "Ordinary Differential Equations" (ODEs) have a single independent variable (like y)
  • "Partial Differential Equations" (PDEs) have two or more independent variables.
We are learning about Ordinary Differential Equations here!

Order and Degree

Next we work out the Order and the Degree:

Order

The Order is the highest derivative (is it a first derivative? a second derivative? etc):

Example:

dy+ y2 = 5x
dx
It has only the first derivative dydx , so is "First Order"

Example:

d2y+ xy = sin(x)
dx2
This has a second derivative d2ydx2 , so is "Order 2"

Example:

d3y+ xdy+ y= ex
dx3dx
This has a third derivative d3ydx3 which outranks the dydx , so is "Order 3"

Degree

The degree is the exponent of the highest derivative.

Example:

  (dy)2  + y = 5x2
dx
The highest derivative is just dy/dx, and it has an exponent of 2, so this is "Second Degree"
In fact it is a First Order Second Degree Ordinary Differential Equation

Example:

d3y + (dy)2  + y = 5x2
dx3dx
The highest derivative is d3y/dx3, but it has no exponent (well actually an exponent of 1 which is not shown), so this is "First Degree".
(The exponent of 2 on dy/dx does not count, as it is not the highest derivative).
So it is a Third Order First Degree Ordinary Differential Equation

Be careful not to confuse order with degree. Some people use the word order when they mean degree!

Linear

It is Linear when the variable (and its derivatives) has no exponent or other function put on it.
So no y2, y3, √y, sin(y), ln(y) etc, just plain y (or whatever the variable is).
More formally a Linear Differential Equation is in the form:
dy  + P(x)y = Q(x)
dx

Solving

OK, we have classified our Differential Equation, the next step is solving.


Separation of Variables

Separation of Variables is a special method to solve some Differential Equations
A Differential Equation is an equation with a function and one or more of itsderivatives:

Example: an equation with the function y and its derivative dydx  

When Can I Use it?

Separation of Variables
Separation of Variables can be used when:
All the y terms (including dy) can be moved to one side of the equation, and
All the x terms (including dx) to the other side.

Method

Three Steps:
  • Step 1 Move all the y terms (including dy) to one side of the equation and all the x terms (including dx) to the other side.
  • Step 2 Integrate one side with respect to y and the other side with respect to x. Don't forget "+ C" (the constant of integration).
  • Step 3 Simplify

Example: Solve this (k is a constant)

  dydx = ky
Step 1 Separate the variables by moving all the y terms to one side of the equation and all the x terms to the other side.
Multiply both sides by dx:  dy = ky dx
Divide both sides by y: dyy = k dx
Step 2 Integrate both sides of the equation separately:
Put the integral sign in front:  dyy k dx
Integrate left side:  ln(y) + C = k dx
Integrate right side:  ln(y) + C = kx + D
C is the constant of integration. And we use D for the other, as it is a different constant.

Step 3 Simplify
We can roll the two constants into one (a=D−C):  ln(y) = kx + a
e(ln(y)) = y , so let's take exponents on both sides: y = ekx + a
And ekx + a = ekx ea so we get: y = ekx ea
ea is just a constant so we replace it with c y = cekx
We have solved it:
y = cekx
This is a general type of first order differential equation which turns up in all sorts of unexpected places in real world examples.
We used y and x, but the same method works for other variable names, like this:

Example: Rabbits!

The more rabbits you have the more baby rabbits you will get. Then those rabbits grow up and have babies too! The population will grow faster and faster.
The important parts of this are:
  • the population N at any time t
  • the growth rate r
  • the population's rate of change dNdt
The rate of change at any time equals the growth rate times the population:
dNdt = rN
But hey! This is the same as the equation we just solved! It just has different letters:
  • N instead of y
  • t instead of x
  • r instead of k
So we can jump to a solution:
N = cert

And here is an example, the graph of N = 0.3e2t:

Exponential Growth
There are other equations that follow this pattern such as continuous compound interest.

More Examples

OK, on to some different examples of separating the variables:

Example: Solve this

dy  =1
dxy

Step 1 Separate the variables by moving all the y terms to one side of the equation and all the x terms to the other side.
Multiply both sides by dx:  dy = (1/y) dx
Multiply both sides by y: y dy = dx
Step 2 Integrate both sides of the equation separately:
Put the integral sign in front: y dy = dx
Integrate each side:  (y2)/2 = x + C
We integrated both sides in the one line, and used just one constant of integration C. This saves time, and is perfectly OK as we could have +D on one, +E on the other and just say that C = E−D.

Step 3 Simplify
Multiply both sides by 2: y2 = 2(x + C)
Square root of both sides: y = ±√(2(x + C))
Note: This is not the same as y = √(2x) + C, because the C was added before we took the square root. This happens a lot with differential equations. We cannot just add the C at the end of the process. It is added when doing the integration.
We have solved it:
y = ±√(2(x + C))
A harder example:

Example: Solve this

dy  =  2xy
dx1 + x2

Step 1 Separate the variables
Multiply both sides by dx, divide both sides by y: 
1dy  =2xdx
y1 + x2
Step 2 Integrate both sides of the equation separately:
Put the integral sign in front: 
1dy  = 2xdx
y1 + x2
The left side is a simple logarithm, the right side can be integrated using substitution:
Let u = 1 + x2, so du = 2x dx 
1dy  = 1du
yu
Integrate: ln(y) = ln(u) + C
   
Then we make C = ln(k): ln(y) = ln(u) + ln(k)
So we can get this: y = uk
Now put u = 1 + x2 back again: y = k(1 + x2)

Step 3 Simplify
It is already as simple as can be. We have solved it:
y = k(1 + x2)
An even harder example: the famous Verhulst Equation

Example: Rabbits Again!

Remember our growth Differential Equation:
dN  = rN
dt

Well, that growth can't go on forever as they will soon run out of available food.
A guy called Verhulst included k (the maximum population the food can support) to get:
dN  = rN(1-N/k)
dt
The Verhulst Equation
Can this be solved?
Yes, with the help of one trick ...

Step 1 Separate the variables
Multiply both sides by dt:  dN = rN(1−N/k) dt
Divide both sides by N(1-N/k): 
1dN = r dt
N(1−N/k)

Step 2 Integrate
Put the integral sign in front: 
1dN  = r dt
N(1−N/k)
Hmmm... the left side looks hard to integrate. In fact it can be done, with a little trick.
We start with this: 
1
N(1−N/k)
Multiply top and bottom by k: 
k
N(k−N)
Now here is the trick, add N and −N to the top
(see Partial Fractions):
 
N+k−N
N(k−N)
and split it into two fractions: 
N  +  k−N
N(k−N)N(k−N)
Simplify each fraction: 
1  +  1
k−NN
They can be integrated separately now, like this:
  
1dN + 1dN  = r dt
k−NN
Integrate: −ln(k−N) + ln(N) = rt + C
Done!
(Why did that become minus ln(k−N)? Because we are integrating with respect to N.)

Step 3 Simplify
Negative of all terms: ln(k−N) − ln(N) = −rt − C
Combine ln(): ln((k−N)/N) = −rt − C
Now take exponents on both sides: (k−N)/N = e−rt−C
Separate the powers of e: (k−N)/N = e−rt e−C
e−C is a constant, we can replace it with A: (k−N)/N = Ae−rt

We are getting close! Just a little more algebra to get N on its own:
Separate the fraction terms: (k/N)−1 = Ae−rt
Add 1 to both sides: k/N = 1 + Ae−rt
Divide both by k: 1/N = (1 + Ae−rt)/k
Reciprocal of both sides: N = k/(1 + Ae−rt)
And we have our solution:
  N =  k
1 + Ae−rt

 And here is an example, the graph of 40:
1 + 5e−2t

It starts rising exponentially,
then flattens out as it reaches k=40

Solution of First Order Linear Differential Equations

You might like to read about Differential Equations and Separation of Variables first!
A Differential Equation is an equation with a function and one or more of its derivatives:

Example: an equation with the function y and its derivative dydx  
Here we will look at solving a special class of Differential Equations called First Order Linear Differential Equations

First Order

They are "First Order" when there is only dydx , not d2ydx2 or d3ydx3 etc

Linear

first order differential equation is linear when it can be made to look like this:
dy  + P(x)y = Q(x)
dx
Where P(x) and Q(x) are functions of x.
To solve it there is a special method:
  • We invent two new functions of x, call them u and v, and say that y=uv.
  • We then solve to find u, and then find v, and tidy up and we are done!
And we also use the derivative of y=uv (see Derivative Rules (Product Rule) ):
dy  =  udv  +  vdu
dxdxdx

Steps

Here is a step-by-step method for solving them:
  • 1. Substitute y = uv, and
    dy  =  udv  +  vdu
    dxdxdx
    into
    dy  + P(x)y = Q(x)
    dx
  • 2. Factor the parts involving v
  • 3. Put the v term equal to zero (this gives a differential equation in u and x which can be solved in the next step)
  • 4. Solve using separation of variables to find u
  • 5. Substitute u back into the equation we got at step 2
  • 6. Solve that to find v
  • 7. Finally, substitute u and v into y = uv to get our solution!
Let's try an example to see:

Example: Solve this:

  dydx − yx = 1
First, is this linear? Yes, as it is in the form
dydx + P(x)y = Q(x)
where P(x) = − 1x and Q(x) = 1
So let's follow the steps:
Step 1: Substitute y = uv, and   dydx = u dvdx + v dudx
So this:   dydx − yx = 1
Becomes this:  u dvdx + v dudx − uvx = 1
Step 2: Factor the parts involving v
Factor v: dvdx + v( dudx − ux ) = 1
Step 3: Put the v term equal to zero
v term = zero: dudx − ux = 0
So: dudx = ux
Step 4: Solve using separation of variables to find u
Separate variables: duu = dxx
Put integral sign:  duu =  dxx
Integrate: ln(u) = ln(x) + C
Make C = ln(k): ln(u) = ln(x) + ln(k)
And so: u = kx
Step 5: Substitute u back into the equation at Step 2
(Remember v term equals 0 so can be ignored): kx dvdx = 1
Step 6: Solve this to find v
Separate variables: k dv = dxx
Put integral sign:  k dv =  dxx
Integrate: kv = ln(x) + C
Make C = ln(c): kv = ln(x) + ln(c)
And so: kv = ln(cx)
And so: v = 1k ln(cx)
Step 7: Substitute into y = uv to find the solution to the original equation.
y = uv: y = kx 1k ln(cx)
Simplify: y = x ln(cx)
And it produces this nice family of curves:
 
y = x ln(cx)
 for various values of c
What is the meaning of those curves? They are the solution to the equation   dydx − yx = 1
In other words:
Anywhere on any of those curves
the slope minus yx equals 1
Let's check a few points on the c=0.6 curve:
Estmating off the graph (to 1 decimal place):
PointxySlope (dydx)dydx − yx
A0.6−0.600 − −0.60.6 = 0 + 1 = 1
B1.6011 − 01.6 = 1 − 0 = 1
C2.511.41.4 − 12.5 = 1.4 − 0.4 = 1
Why not test a few points yourself? You can plot the curve here.

Perhaps another example to help you? Maybe a little harder?

Example: Solve this:

  dydx − 3yx = x
First, is this linear? Yes, as it is in the form
dydx + P(x)y = Q(x)
where P(x) = − 3x and Q(x) = x
So let's follow the steps:
Step 1: Substitute y = uv, and   dydx = u dvdx + v dudx
So this:   dydx − 3yx = x
Becomes this:  u dvdx + v dudx − 3uvx = x
Step 2: Factor the parts involving v
Factor v: dvdx + v( dudx − 3ux ) = x
Step 3: Put the v term equal to zero
v term = zero: dudx − 3ux = 0
So: dudx = 3ux
Step 4: Solve using separation of variables to find u
Separate variables: duu = 3 dxx
Put integral sign:  duu = 3  dxx
Integrate: ln(u) = 3 ln(x) + C
Make C = −ln(k): ln(u) + ln(k) = 3ln(x)
Then: uk = x3
And so: u = x3k
Step 5: Substitute u back into the equation at Step 2
(Remember v term equals 0 so can be ignored): x3k ) dvdx = x
Step 6: Solve this to find v
Separate variables: dv = k x−2 dx
Put integral sign:  dv =  k x−2 dx
Integrate: v = −k x−1 + D
Step 7: Substitute into y = uv to find the solution to the original equation.
y = uv: y = x3k ( −k x−1 + D )
Simplify: y = −x2 + Dk x3
Replace D/k with a single constant c: y = c x− x2
And it produces this nice family of curves:
 
y = c x− x2
 for various values of c
And one more example, this time even harder:

Example: Solve this:

  dydx + 2xy= −2x3
First, is this linear? Yes, as it is in the form
dydx + P(x)y = Q(x)
where P(x) = 2x and Q(x) = −2x3
So let's follow the steps:
Step 1: Substitute y = uv, and   dydx = u dvdx + v dudx
So this:   dydx + 2xy= −2x3
Becomes this:  u dvdx + v dudx + 2xuv = −2x3
Step 2: Factor the parts involving v
Factor v: dvdx + v( dudx + 2xu ) = −2x3
Step 3: Put the v term equal to zero
v term = zero: dudx + 2xu = 0
Step 4: Solve using separation of variables to find u
Separate variables: duu = −2x dx
Put integral sign:  duu = −2  x dx
Integrate: ln(u) = −x2 + C
Make C = −ln(k): ln(u) + ln(k) = −x2
Then: uk = e−x2
And so: u = e−x2k
Step 5: Substitute u back into the equation at Step 2
(Remember v term equals 0 so can be ignored): e−x2k ) dvdx = −2x3
Step 6: Solve this to find v
Separate variables: dv = −2k x3 ex2 dx
Put integral sign:  dv =  −2k x3 ex2 dx
Integrate: v = oh no! this is hard!
Let's see ... we can integrate by parts... which says:
 RS dx = R  S dx −  R' (  S dx) dx
(Side Note: we use R and S here, using u and v could be confusing as they already mean something else here.)
Choosing R and S is very important, this is the best choice we found:
  • R = −x2 and
  • S = 2x ex2
So let's go:
First pull out k: v = k  −2x3 ex2 dx
R = −x2 and S = 2x ex2: v = k  (−x2)(2xex2) dx
Now integrate by parts: v = kR  S dx − k  R' (  S dx) dx
Put in R = −x2 and S = 2x ex2
And also R' = −2x and  S dx = ex2
So it becomes: v = −kx2  2x ex2 dx − k  −2x (ex2) dx
Now Integrate: v = −kx2 ex2 + k ex2 + D
Simplify: v = kex2 (1−x2) + D
Step 7: Substitute into y = uv to find the solution to the original equation.
y = uv: y = e−x2k ( kex2 (1−x2) + D )
Simplify: y =1 − x2 + ( Dk)ex2
Replace D/k with a single constant c: y = 1 − x2 + c ex2
Done!

Homogeneous Differential Equations

A Differential Equation is an equation with a function and one or more of itsderivatives:

Example: an equation with the function y and its derivative dydx
Here we look at a special method for solving "Homogeneous Differential Equations"

Homogeneous Differential Equations

A first order Differential Equation is Homogeneous when it can be in this form:
dydx = F( yx )
We can solve it using Separation of Variables but first we create a new variable v = yx
v = yx   is also   y = vx
And dydx = d (vx)dx = v dxdx + x dvdx (by the Product Rule)
Which can be simplified to dydx = v + x dvdx
Using y = vx and dydx = v + x dvdx we can solve the Differential Equation.
An example will show how it is all done:

Example: Solve dydx = x2 + y2xy

Can we get it in F( xy ) style?
Start with: x2 + y2xy
Separate terms: x2xy + y2xy
Simplify: xy + yx
Reciprocal of first term: yx )-1 + yx
Yes! So let's go:
Start with: dydx = ( yx )-1 + yx
y = vx and dydx = v + x dvdx v + x dvdx = v-1 + v
Subtract v from both sides: dvdx = v-1
Now use Separation of Variables:
Separate the variables: v dv = 1x dx
Put the integral sign in front: v dv = 1x dx
Integrate: v22 = ln(x) + C
Then we make C = ln(k): v22 = ln(x) + ln(k)
Combine ln: v22 = ln(kx)
Simplify: v = ±√(2 ln(kx))
Now substitute back v = yx
Substitute v = yx: yx = ±√(2 ln(kx))
Simplify: y = ±x √(2 ln(kx))
And we have the solution.

Another example:

Example: Solve dydx = y(x−y)x2

Can we get it in F( xy ) style?
Start with: y(x−y)x2
Separate terms: xyx2 − y2x2
Simplify: yx − ( yx )2
Yes! So let's go:
Start with: dydx = yx − ( yx )2
y = vx and dydx = v + x dvdx v + x dvdx = v − v2
Subtract v from both sides: dvdx = −v2
Now use Separation of Variables:
Separate the variables: − 1v2 dv = 1x dx
Put the integral sign in front: − 1v2 dv = 1x dx
Integrate: 1v = ln(x) + C
Then we make C = ln(k): 1v = ln(x) + ln(k)
Combine ln: 1v = ln(kx)
Simplify: v = 1ln(kx)
Now substitute back v = yx
Substitute v = yx: yx = 1ln(kx)
Simplify: y = xln(kx)
And we have the solution.
And one last example:

Example: Solve dydx = x−yx+y

Can we get it in F( xy ) style?
Start with: x−yx+y
Divide through by x: x/x−y/xx/x+y/x
Simplify: 1−y/x1+y/x
Yes! So let's go:
Start with: dydx = 1−y/x1+y/x
y = vx and dydx = v + x dvdx v + x dvdx = 1−v1+v
Subtract v from both sides: dvdx = 1−v1+v − v
Then: dvdx = 1−v1+v − v+v21+v
Simplify: dvdx = 1−2v−v21+v
Now use Separation of Variables:
Separate the variables: 1+v1−2v−v2 dv = 1x dx
Put the integral sign in front: 1+v1−2v−v2 dv = 1x dx
Integrate: 12 ln(1−2v−v2) = ln(x) + C
Then we make C = ln(k): 12 ln(1−2v−v2) = ln(x) + ln(k)
Combine ln: (1−2v−v2)−½ = kx
Square and Reciprocal: 1−2v−v2 = 1k2x2
Now substitute back v = yx
Substitute v = yx: 1−2( yx )−( yx )2 = 1k2x2
Multiply through by x2: x2−2xy−y2 = 1k2
We are nearly there ... it is nice to separate out y though!
We can try to factor x2−2xy−y2 but we must do some rearranging first:
Change signs: y2+2xy−x2 = − 1k2
Replace − 1k2 by c: y2+2xy−x2 = c
Add 2x2 to both sides: y2+2xy+x= 2x2+c
Factor: (y+x)2 = 2x2+c
Square root: y+x = ±√(2x2+c)
Subtract x from both sides: y = ±√(2x2+c) − x
And we have the solution.








No comments:

Post a Comment