Math Calculus
Math Calculus
Calculus by definition is a study of small thing. What small thing ? We will look at this
in a short while.
Now suppose we want to find the gradient of a tangent line to a curve given by
y = f(x) ( Fig 1 )
Fig 1
Suppose P(x,f(x)) is the point on the curve where we are supposed to find the
gradient of the tangent line. We pick another point P1 on the curve and draw a line
joining P and P1 . This line is known as secant line . Suppose P1 has coordinate
( x+h, f(x+h)) . The gradient of this secant line is
f (x + h) _ f (x)
msec = . Now as h → 0 the point P1 will move closer and
h
closer to P. At the same time the secant line will approach the tangent line at P .
Thus the gradient of the secant line ( msec ) will approach the gradient of the tangent
line ( mtan ).
f (x + h) _ f (x)
Mathematically we write lim msec = lim = mtan .
h→0 h→0 h
This mtan is also known as the derivative of f(x) and oftenly denoted as f ‘(x).
dy
If y = f(x) then f ‘(x) is also written as . The d means difference in y and x .
dx
So as you can see the study of small thing is actually refers to h → 0 i.e becomes
smaller and smaller.
1
2.2 First Principle Formula
Definition
f (x + h) _ f (x)
f ' (x) = lim .
h→0 h
The above formula is also known as First Principle Formula. This process of
finding derivative is commonly known as “differentiation”.
Example 1
Solution
2
Example 2
Solution
As you can see finding f ‘(x) every time using the First Principle Formula is
rather laborious. Instead mathematicians have worked out most of the f ‘(x) using
the formula and put it into a table for the benefit of most scientists and engineers.
Example 3
4
Find the value of the gradient of the tangent line for f (x) = at x = 2.
x3
Solution
3
2.3 Rules of Derivatives
In many applications one works with a mixture of functions, not just single
function. For this mathematicians have provide certain proven rules for the purpose.
1. Additive Rule : ( f ± g )’ = f ’ ± g ‘ .
2. Product Rule: (f g ) ‘ = f g ‘ + g f ‘.
f gf ' _ fg '
3. Quotient Rule : ( )' = .
g g2
Example 4
Solution
Example 5
6 sin x
(a) f(x) = x5cos x (b) f(x) = exlog2x (c ) f(x) =
x2 + 1
Solution
4
Sometimes we need to use more than a rule to find the derivative. See the
following example
Example 6
x 3e x
Find f ‘(x) if f(x) =
x ln x + 3
Example 7
3
(a) f(x) = cos(7x) (b) f(x) = (8x2 + x)4 (c ) f(x) = ln(ln (x)) (d) f(x) = e x sin x
5
Often the case we need to use all the four rules as in the following example
Example 8
x 2e 3 x + 1
Find f ‘(x) if f(x) =
cos 3 x .
Often in the case an equation or expression is given in a mixed mode i.e the
variables x and y are mixed together.
For example x + y = 7 or x2 + y2 = 9 or y2 = xy + cos(xy) are example of the mixed
mode. Equations of this type is known as implicit form on contrary with the other
type which is explicit form. In explicit form y is given in terms of x only . In this way
the derivative is straight forward.
6
Now if given implicitly, how do we find the derivative ? We must aware that y is a
function of x. So to differentiate xy for example we need to use product rule since
y is a function of x.
d dy
So dx ( xy ) = x + y(1)
dx
d 3 d 3 dy
Also dx (y ) for example should be dx (y ) = 3y2 dx .
Example 9
dy
Find dx if xy3 + sin(y2) = x2 + y2
Example 10
Solution
7
2.5 Applications of Derivatives
Aside from finding gradient of tangent lines to curve, derivatives found itself in lots
of applications. We will look at some of them.
In any of the shape above you will notice that the gradient of the tangent line to
each one is positive. Similarly for the ones that are decreasing ( Fig 3a, b c .)
We will have gradient of the tangent line to each one of decreasing components
are negative. So we have the following observation :
Example 11
Find all the x values for which the graph of f(x) = 2x2 - 7x +5 is increasing .
Solution
8
Example 12
Find all values of x for which the graph of f(x) = 12xe3x is decreasing.
Solution
Fig4
The points A and C are the maximum points and B and D are minimum points. We
also call these points the extremum points. These extremum can be considered local
as they are the highest and lowest points compared to their left and right neighbours.
At these extremum points the tangent lines are horizontal, thus the gradient is zero.
The maximum point has tangent lines with positive gradient on the left and negative
gradient on the right ( Fig 5a) while the minimum point has tangent lines with
negative gradient on the left and positive gradient on the right. This observation will
lead to First Derivative Test. We will first define critical value and then state the test.
9
Definition
Note : We use the notation c- to denote a value a bit less than c and c+ to denote a
value a bit more than c .
Example 13
Given the function f(x) = 6x3 + 9x2 - 108x + 7. Find all extremum points.
Sketch the graph.
Example 14
Given the graph y = xln x . Find all extremum points to the graph.
Sketch the graph.
Solution
10
There is another alternative to spot these extremum i.e via Second Derivative Test.
At the minimum point (c,f( c)), f ‘(x) is negative on the left of this point and gradually
becomes less negative as it moves towards the minimum point and assume zero
value at the minimum point. Then as it moves to the right it gradually becomes more
and more positive. This means f ‘(x) is an increasing function . Thus the derivative of
f ‘(c) should be positive i.e f ‘’(c) > 0 .
Likewise at the maximum point, f ‘(x) is a decreasing function and hence f ‘’( c) is
negative i.e f ‘’(c ) < 0 .
Example 15
Solution
11
Now what happen if f ‘’( c) = 0 ? . Well if this is the case then the test will be
inconclusive. First Derivative Test need to be carried out.
dy
If y = f(x) then f ‘(x) can also be written as dx . This is not just a symbol but
represent the change in y with respect to change in x . It comes from the First
Principle Formula where we can write
dy Δy
dx as Δlim
x → 0 Δx . This actually give the instantaneous rate of change at
x value.
Example 16
An inverted cone full of water leaks at the nozzle with 0.5 cm3/sec. The cone is 50
cm high and has radius 20 cm at the base. Find how fast the water level inside the
cone is dropping.
Solution
12
Example 17a
A ladder 3m long is slanted against a wall and is sliding down. The top of the
ladder is sliding down at the rate of 2cm/sec. Find the rate of the bottom part of the
ladder is moving on a smooth ground when the top part is 1m above the ground.
Solution
Example 17b
A ship travels along a straight line following the path of y = 2x + 3 and continues
travelling that path. A buoy is at coordinate of (50,80). Find the coordinate of the
ship when it is nearest to the buoy. Calculate this nearest distance.
13
2.4.4 Approximation
dy Δy dy Δy
As stated above dx = Δlim
x → 0 Δx . This means ≈
dx Δx
when Δx very small
dy
Thus Δy ≈ dx Δx when Δx very small .
very small for the estimate to be good. The smaller the Δx the better will be the
estimate.
Example 18
2
Given y = x + 8 . Estimate the value of y when x is (a) 1.5 (b) 1.1
14
L’Hopital’s Rule ( Limits revisited )
f (x)
Suppose we are given and f(x) and g(x) have derivatives of all order.
g( x )
f (a) ∞ 0 f (x) f ' (x)
Suppose is in the form of or . Then lim = lim provided the
g(a) ∞ 0 x → a g( x ) x → a g' ( x )
_
x → a can be replaced by x → ∞ or x → a + or a .
Example
ln x sin x x_3 x 3 _ 2x 2 7
(a) lim (b) lim (c ) lim 2 _ _ (d ) lim
x → x x →0 x x →3 x x 6 x → 4 x 3 _ x _ 6
15
Calculus of Functions of two variables.
z= x2 + y2 x2 + y2 = 4
x2 + y2 + z2 = 9 2x + 3y + 4z = 12
z2 = x2 + y2 x2 + y2 + z2/4 = 1
16
To differentiate these functions we have to do it partially. We
introduce the following :
Suppose z = f (x, y)
z
Denote derivative of z with respect to x while y fixed
x
z
and derivative of z with respect to y while x fixed.
y
Example
Given z = x3y4 + 2x + y - 7
z z
Then 3 x2y4 + 2 . 4x3y3 + 2x + 1 .
x y
Example
z z
Given z = x2 sin (x/y) . Find ,
x y
z
To find , we have to employ product rule.
x
17
Most of the rules in functions of single variable are applicable here. However the
chain rule needs modification.
z z x z y z z x z y
Then r x r y r and s x s y s .
Example
Given z = x2 + 2y x = r s2 y = 2r - s
z
Then r
z
s
18
Approximation and Normals of functions of two variables
z z
then z x y .
x y
We call this The Small Increment Formula. The smaller the change in x and y
the better will be the approximation.
Example
Normals to surfaces.
Since z = f(x,y) will always give us surfaces then given a point on a surface there
will be a tangent plane to this surface.
19
It can be shown that the normal vector to the tangent plane of the surface
z = f(x,y) is given as the vector
z z z z
n= , ,1 or , ,1 . More generally if a surface is
x y x y
given as F (x, y, z ) = c where c is constant then the normal vector to the surface
F F F
is n = , ,
x y z .
Example
20
Lagrange Mutiplier
Example
Find the maximum and the minimum of f(x,y) = xy when the constraint is
4x2 + 8y2 = 16 .
21
Example
Find the point on the sphere x2 + y2 + z2 = 36 that are closest to and farthest from
the point (1, 2, 2).
22
Chapter 3 Integral Calculus
Fig 1
One way to do this is to draw thin rectangles onto the graph and estimate the total
area of these rectangles . We enlarge Fig 1 for you to see what is going on. ( Fig 2)
Fig 2
x =b
So A ≈ �yΔx .
x =a
For A to be more accurate Δx has to be very small, which means we have to take
more and more rectangles. Then how can A be exact ? Well, we have to make
Δx → 0 and at the same time the number of rectangles goes to infinity.
x =b
b
The last expression above is written as ∫
a
ydx
1
Later we will see how ∫ relates itself to derivative that we studied.
d
So if
dx
( f (x)) = g(x) then ∫ g(x)dx = f (x) .
This is the most important discovery for which it arises to the birth of integral
calculus.
Using the above we can quickly can many formulae to integration as shwn in the
table below.
f(x) f(x)
∫ f (x)dx ∫ f (x)dx
1 x ex ex
a ax cos x sin x
x x2/2 sin x - cos x
axn ax /(n+1) n ≠ -1
n+1
tan x - ln cos x
1/x ln x sec2 x tan x
ax a /ln a
x
cosh x sinh x
To check whether the entries are correct we can differentiate the second and the
fourth columns and see that they are equal to the first and hhird column
respectively.
d ax 1 x ax
For example ( )=
dx ln a ln a
(a ln a) = a x . Hence ∫ a dx = ln a .
x
d ax n +1 a
Also for n ≠ -1 ( )= ((n + 1) x n ) = ax n .
dx n + 1 n +1
n +1
ax
Hence ∫ ax n dx = .
n +1
2
Using the table we can straight away conclude that
_
7x 4 1 x 5 +1 _ 1
(a) ∫ 7 x dx = + C (b) ∫ 5 dx = ∫ x dx = _
_
3 5
= +C
4 x 5+1 4x4
5
3
x2 5
( c) ∫ 5 x 3
dx = ∫ 5 x dx = 5
2
5
= 2 x 2
+C .
2
b
We also have ∫a
f (x) dx = F (a) _ F (b) where ∫ f (x)dx = F (x) + C
Example 1
2 x 3 + 3x + 7
Evaluate ∫ x 2 dx .
Solution
Example 2
7 2 7
Given that ∫ g(x)dx = 10
2
and ∫ g(x)dx = 4. Find ∫ g(x)dx.
5 5
3
3.4 Techniques of Integration
Of course the table alone won’t help very much to integrate complicated functions.
We need certain technique to get around it.
du
In this method we let u = h(x) and then find. We manipulate this and
dx
substitute into the integral so as to change the x form to u form.
Example 3
Solution
1 1
In general ∫e ax
dx = e ax + C ,
a ∫ cos ax dx = a sin ax + C .
4
Example 4
1
Evaluate each of the following (a) ∫ x ln x dx (b) ∫ sin 3
x cos x dx
1
(c ) ∫ ax + b .
dx
Solution
Example 5
2
∫ ( x + 2)
3
Evaluate x dx
1
5
3.4.2 Integration By Parts ( IBP )
∫ udv = uv ∫ vdu
_
which is the famous integration by parts formula and is usually written this way.
Example 6
6
As seen in ( c) , the method is rather laborious. Imagine if we need to find
∫x 4
sin 3x dx . To get around this a tabular form of IBP is designed. In this form
we will have two columns, one for differentiating and another one is for
integration. We will show how we do this tabular form for ∫x 2
sin 3x dx and
∫x 4
sin 3x dx .
Example 7
7
3.4.3 Integration By Partial Fractions
1 3 (4 + x ) + 3x 4 + 4 x
+ = = .
x x +4 x(x + 4) x(x + 4)
1 3 4 + 4x
So given + we arrive to .
x x +4 x(x + 4)
4 + 4x 1 3
Now what if is given. How can we arrive to + ?
x(x + 4) x x +4
p(x)
Suppose we have where p and q are polynomials and deg(p) < deg(q).
q( x )
p(x)
(a) If q contains linear factors (ax + b)(cx + d) then contains partial
q( x )
A B
fractions of the form + .
ax + b cx + d
p(x)
(b) If q contains linear factors (ax + b)(cx + d)2 then contains partial
q( x )
A B C
fractions of the form + + .
ax + b cx + d (cx + d )2
8
p(x) A Bx + C
contains partial fractions of the form + 2 .
q( x ) ax + b cx + dx + e
Example 8
3 3
Express
x(2 x + 1)
into partial fractions. Hence evaluate ∫ x(2 x + 1) dx .
Example 9
2x + 3 2x + 3
Express
(x + 2)(2 x + 1)2
into partial fractions. Hence evaluate ∫ (x + 2)(2x + 1) dx .
9
Example 10
x x
Express
(x + 3)(x 2 + 4)
into partial fractions. Hence evaluate ∫ (x + 3)(x 2
+ 4)
dx .
10
3.4.4 Integration Using Trigonometric Identities
In this section we will learn how to integrate some of the trigonometric of the
functions. We will use some of the identities and formulae in trigonometry.
Here are some of the identities that are oftenly used in this integration.
Basic Identities
1. cos2 x + sin2 x = 1
2. 1 + tan2 x = sec2 x
3. 1 + cot2 x = cosec2 x
Product Formula
1
6. sin x sin y = [cos (x _ y ) _ cos( x + y)]
2
1
7. cos x cos y = [cos (x _ y )+ cos( x + y)]
2
1
8. sin x cos y = [sin(x + y )+ sin( x _ y)]
2
1
9. cos x sin y = [sin(x + y ) _ sin( x _ y)]
2
Example 11
Find each of the following (a) ∫ sin x cos 2 x dx (b) ∫ cos 3 x dx (c ) ∫ sin
2
x dx
11
Example 12
Evaluate ∫
0
2
cos 2 x cos 5x dx .
12
3.5 Applications of Integral
In early part of this chapter we have discussed a bit on finding area under a curve. In
this section we will learn to calculate the area.
Consider a region between the graph of a function y = f(x) and x axis from
x = a to x = b . ( Fig 3 )
Fig 3
b b
A= ∫a
y dx or ∫
a
f (x) dx .
Example 13
Solution
13
Example 14
Solution
Consider the region between graph x = g(y) and the y axis from y =c to y = d.
( Fig 4 )
Fig 4
d d
A= ∫ x dy
c
or ∫ g(y)dy
c
14
Example 15
6
Find the area between y = and the y axis from y = 1 to y = 5.
x
Suppose the upper graph is y2 = f(x) and the lower graph is y1 = g(x).
Let A be the region between the two graphs, from x = a to x = b. ( Fig 5 )
If we draw vertical rectangles onto A then each rectangle with width dx will
have length y2 - y1 . Thus each rectangle will have area (y2 - y1)dx . This leads us to
the formula for A as
b b
A= ∫ (y
a 2
_
y1 ) dx or ∫ ( f (x)
a
_
g(x)) dx
b
This A can also be memorised as ∫ (upper
a
graph _ lower graph) dx .
15
Example 16
Suppose the right graph is x2 = f(y) and left graph is x1 = g(y) . Let A be the area
between the two graphs between y = c and y = d ( Fig 6 )
Fig 6
Draw horizontal rectangles onto A . The width of a rectangle is dy and length for
each rectangle is x2 - x1 . Thus the area is (x2 - x1)dy . This leads to the formula of
A as
d d
A= ∫ (x
c 2
_
x1 ) dy or ∫ ( f (y)
c
_
g(y)) dy
d
A can also be memorised as A = ∫ (right graph
c
_
lef graph) dy .
16
Example 17
Find the area enclosed by the graphs y = 6 - x, y = -2x and the x axis .
Solution
Imagine that the region between the graph y = f(x) and x axis from x = a to x = b
is revolved 3600 about the x axis. If the region is a right triangle ( Fig 7a ) then we
will obtain a full cone (Fig 7b)
b b
V= ∫ πy
a
2
dx or ∫ π( f (x))
a
2
dx .
17
Example 18
The region bounded by y = x2, x = 2 and x = 5 and x axis is revolved about the x
axis. Find the volume of the solid generated.
Solution
Example 19
Solution
18
Integration of Functions of two variables
When the integral is computed it will give the volume of a solid with base R and
top the surface z = f(x,y) .
4 5 2
and f(x,y) = x2y + y we will let f (x , y)dA = 1 2 x y y dydx
R
Example
4 5 2
Compute 1 2 2 x 3y dydx . Interpret the value.
19
Ordinary Differential Equations
Often the case especially in engineering we are given for example equations
involving rate of change. Suppose velocity is twice that of time . Find the velocity,
displacement and so on.
Firstly every ODE must have an order. This order is given as the highest order of
derivative in the equation.
Example
Determine the order of each
1. dy/dx = x2 + 1
2. d2y/dx2 = dy/dx - 7x
3. (dy/dx)4 + d3y/dx3 = cos x
Solving ODE
ODE is solved according to its type. We will learn two types of ODE of First Order
1. Separable equation
An ODE which can be separated the x on one side and the y on the other side.
When separated the x and the y we have the form f(y)dy = g(x)dx. The
solution to the equation can then be found by integrating both sides.
Example
Solve dy/dx = xy +y
20
Example
Solve : exdy/dx = y3 ,
y = 1 when x = 0
2. Linear Equation
P ( x )dx
To solve this equation we multiply the left and right by e , which is known
as integrating factor. Let us remind that before multiplying ensure rhat the
equation must be in the above form.
21
Example Solve xdy/dx + (3x + 1)y = x2
22
Chapter 4 Numerical Methods
Trapezoidal Rule
b b_a
∫a f (x)dx ≈ 2n [ f (x0 ) + 2 f (x1 ) + 2 f (x2 ) + .... + 2 f (xn _ 1 ) + f (xn )]
b_a
where xk = a + k for k = 0, 1, 2, …, n.
n
b
As n → ∞ the right hand side will approach ∫a
f (x) dx .
Example 1
2
Use Trapezoidal Rule to approximate ∫x
0
3
dx using n = 8.
Check your answer using straight forward integration.
Solution
b_a 2
a = 0, b = 2 , n = 8. Δ= = = 0.25
n 8
k xk f(xk) m
0 0 0 1
1 0.25 0.0156 2
2 0.5 0.1250 2
3 0.75 0.4219 2
4 1.0 1.000 2
5 1.25 1.9531 2
6 1.5 3.3750 2
7 1.75 5.3594 2
8 2.0 8.000 1
Total = 32.5
2 2
∫0 x 3 dx ≈ 2(8) [Total ] = 4.0625 Check : Exact ans is 4.
1
Example 2
Consider a plot of land with given coordinates. Estimate the area of the land by
Trapezoidal Rule.
0 1 2 3 4 5 6
Solution
b_a
∫ ( f (x) g(x))dx ≈
b
_
Then [Δ 0 + 2Δ 1 + 2Δ 2 + ... + 2Δ n _ 1 + Δ n ]
a 2n
where Δ k = f (x k ) _ g(x k ) k = 0,1,2,...., n and
b_a
xk = a + k for k = 0, 1, 2, …, n.
n
2
Example 3
Solution
b_ a
a = 1, b = 3 , n = 5 = 0.4 f(x) = 4x3 g(x) = 3x
n
k xk f(xk)-g(xk) m
0 1 1 1
1 1.4 6.776 2
2 1.8 17.928 2
3 2.2 35.992 2
4 2.6 62.504 2
5 3.0 99 1
Total = 346.4
2
∫ (4 x 3x )dx ≈
3
3 _
(Total ) = 69.28 Exact = 68.
1 2(5)
Notice that the error is 1.28. Should we use n > 5 then the estimation would be
better.
This Trapezoidal Rule of two functions can be used if we know the difference
between two ordinates.
Example 4
Consider a plot of land below with difference in ordinates given. Estimate the area
of the land.
3
4.2 Simpson’s Rule
Simpson’s Rule
b b_a
∫a f (x)dx ≈ 3n [ f (x0 ) + 4 f (x1 ) + 2 f (x2 ) + 4 f (x3 ) + ... + 4 f (xn _ 1 ) + f (xn )]
b_a
where xk = a + k for k = 0, 1, 2, …, n.
n
b
As n → ∞ the right hand side will approach ∫a
f (x) dx .
Example 5
5
Estimate ∫ x ln x dx
2
using n = 6.
Solution
b_a
a=2 b=5 = 0.5
n
k xk f(xk) m
0 2 1.3863 1
1 2.5 2.2907 4
2 3.0 3.2958 2
3 3.5 4.3847 4
4 4.0 5.5452 2
5 4.5 6.7683 4
6 5.0 8.0472 1
Total = 80.8903
5 5_2
∫2 x ln x dx 3(6) (Total ) = 13.4817.
≈
4
Simpson’s Rule ( in case of two functions )
b_a
∫ ( f (x) g(x))dx ≈
b
_
Then [Δ 0 + 4Δ 1 + 2Δ 2 + ... + 4Δ n _ 1 + Δ n ]
a 3n
where Δ k = f (x k ) _ g(x k ) k = 0,1,2,...., n and
b_a
xk = a + k for k = 0, 1, 2, …, n.
n
Example 6
Rework Example 4 using Simpson’s Rule for the case of two functions.
5
4.3 Newton’s Method for Approximating Roots
In this section we will learn how to estimate roots of equations. Some equations
are quite easy to find the root such as 2x - 9 = 1 which will give the root x = 5 .
However many equations are difficult to find the roots for example 4sin x = x
Although the equation seems to be very simple but to find the root ( the x value ) is
difficult. We have no other alternative but to estimate.
There are many estimation methods of finding roots. One of them is Newton’s
Method.
f (x 0 + h) _ f (x 0 ) f (x 0 + h) _ f (x 0 )
This means f ‘(x0) ≈ or h ≈ when h is small.
h f '(x 0 )
_ f (x 0 ) _ f (x 0 )
So h ≈ . Therefore a better root is x0 + h ≈ x0 .
f '(x 0 ) f '(x 0 )
Theorem
Suppose f(x) is continuous on [a,b] and suppose f(a) > 0 (or < 0) and
f(b) < 0 ( or > 0) . Then there is a c in (a,b) such that f( c) = 0.
The above theorem which we gave without proof guarantees that f(x) = 0 has at
least a root if f is continuous on [a,b] provided f(a) and f(b) have different signs.
6
Example 7
Solution
Let the first root be x0 = 0.5 . Then f (0.5) = -.8513 and f ‘(0.5) = 2.6487
Putting into Newton’s Formula we get
_ .8513
x1 = 0.5 - = 0.8214.
2.6487
0.0951
x2 = 0.8214 - = 0.7924.
3.2737
0.0011
x3 = 0.7924 - = 0.7921
3.2087
If we let our final root to be 0.792 we have given the answer correct to 3 dec.
places as the first three decimals of x2 and x3 are the same.
Example 8
Solution
7
0.68290
So x1 = 1 - = -0.75509, which is out of range.
0.0806
Notice that f ‘(1) is too small compared to f (1) . Use trial root = 1.5 .
Example 9
1 a
To find a one can use the Mechanic Formula xn+1 = ( x n + ) , n =1,2,…
2 xn
Derive this formula using Newton’s Method. Use the formula above to estimate
10 correct to two dec. places.
Oftenly we need to estimate a point between two known points, or three known
points etc. How can we do this ? One answer to this is interpolation. In this section
we will look into three types of interpolation : Linear Interpolation, Lagrange
Quadratic Interpolation and Lagrange Cubic Interpolation.
Suppose two points are known P0(x0, y0) and P1(x1,y1) . For given x where x0
< x < x1 we wish to find P(x,y) .
Now to find the y value we can draw straight line joining P0 and P1 ( Fig 1 ) and
draw right angle triangle beneath it.
Let P(x,y) be the point we wish to seek and it is on the line between P0 and P1.
8
Fig 1
y _ y 0 y1 _ y 0
If m is the gradient then mP0P = mP0P1 ⇒ _ = _ .
x x 0 x1 x 0
y1 _ y 0 _ x _ x1 x _ x0
Thus ⇒ y = y 0 + _ (x x 0 ) = y 0 _ + y1 _ .
x1 x 0 x 0 x1 x1 x 0
x _ x1 x _ x0
L0 = _ and L1 = = _ .
x 0 x1 x1 x 0
Suppose points P0(x0, y0) and P1(x1,y1) are known. Then for a given x ,
y can be estimated by
1
x _ x1 x _ x0
y = �y i Li where L0 = and L1 = = .
i =0 x 0 _ x1 x1 _ x 0
Example 10
Solution
Here x0 = 2 y0 = 5 x1 = 9 y1 = 50.
6_9 6 _ 2 215
y = y0L0 + y1L1 = 5( _ ) + 50( _ ) = ≈ 30.714 .
2 9 9 2 7
9
4.4.2 Lagrange Quadratic Interpolation
Now suppose three points are known. Then we can find a quadratic function
through all these three points. The interpolation formula is just an extension to the
above formula.
Suppose points P0(x0,y0), P1(x1, y1) and P2(x2,y2) are known. Then for a given x,
y can be estimated by
y= �y L i i
i =0
x _ x1 x _ x 2 x _ x 0 x _ x2 x _ x 0 x _ x1
where L0 = ( )( ) L 1 = ( )( ) L == ( )( )
x 0 _ x1 x 0 _ x 2 x1 _ x 0 x1 _ x 2 2 x 2 _ x 0 x 2 _ x1 .
Example 11
Given three points (1,17), (5,69) and (10,179). Estimate the value of y if x = 7.
Solution
x0 = 1 y0 = 17 x1 = 5 y1 = 69 x2 = 10 y2 = 179
7 _ 5 7 _ 10 7 _ 1 7 _ 10 7_1 7_5
y = y0L0 + y1L1 + y2L2 = 17( _ )( _ ) + 69( _ )( _ ) + 179( _ )( _ ) = 107.
1 5 1 10 5 1 5 10 10 1 10 5
10
Example 12
Given the following plotted points. Find a quadratic function which can
estimate the curve.
Suppose points P0(x0,y0), P1(x1, y1) , P2(x2,y2) and P3(x3,y3) are known. Then for a
given x, y can be estimated by
3
y= �y L i i
i =0
x_ x x_ x x_ x x_ x x_ x x_ x
where L0 = ( _ 1 )( _ 2 )( _ 3 ) L1 = ( _ 0 )( _ 2 )( _ 3 )
x0 x1 x0 x2 x0 x2 x1 x0 x1 x2 x1 x3
x _ x0 x _ x1 x _ x3 x _ x0 x _ x1 x _ x2
L2 = ( _ )( _ )( _ ) L3 = ( _ )( _ )( _ )
x2 x0 x2 x1 x2 x3 x3 x0 x3 x1 x3 x2
11
Example 13
Given four points (1,6), (2,31), (5,454), (8, 1903) . Estimate the value of y when
x = 6.
Solution
x0 = 1 y0 = 6 x1 = 2 y1 = 31 x2 = 5 y2 = 454 x3 = 8 y3 = 1903
Example 14
The points (0,-23), (2,-25), (3,1) and (5,167) are on a cubic polynomial. Find the
polynomial.
By Lagrange we have y =
_ _ _ _ _ _ _ _ _ _ _ _
23( x 2 )( x 3)( x 5 ) 25( x 0 )( x 3 )( x 5 ) 1( x 0 )( x 2 )( x 5 ) 167( x 0 )( x 2 )( x 3)
0 _ 2 0 _ 3 0 _ 5 2_0 2_3 2_5 3_ 0 3_ 2 3_5 5_0 5_2 5_3
23 3 25 1 167 3
(x 10 x 2 31x 30) (x 3 8 x 2 15 x) (x 3 7 x 2 10 x) (x 5 x 2 6 x)
30 6 6 30
2 x 3 x 2 7 x 23.
12
Numerical Solution To Non Linear First Order ODE
1. Euler Method
Before we go to non linear example we look first at the equation which can be
solved by methods studied.
Example
Solution
The equation can be put into dy/dy - (1/5)y = x which is linear.
If we solve using the method studied we get y = 22ex/5 -5x - 25.
This is the exact solution to the equation.
h= 1:
With x0 = 0 y0 = -3 and f(x,y) = x + y/5
we have y1 = y0 +f(x0,y0)h
=-3+ f(0,-3)(1)=-3+(-0.6)= -3.6
y2 = y1 +f(x1,y1)h
= -3.6+f(1,-3.6)(1) = -3.32
y3 = y2 +f(x2,y2)h
= -3.32 + f(2, -3.32) = -1.984
y4 = y3 +f(x3,y3)h
= -1.984+f(3,-1.984)= 0.6192
y5 = y4 +f(x4,y4)h
= 0.6192 + f(4, 0.6192) = 4.7430.
13
h=0.2 :
y1 = y0 +f(x0,y0)h
=-3+ f(0,-3)(0.2)=-3+(-0.12)= -3.12
y2 = y1 +f(x1,y1)h
= -3.12+f(0.2,-3.12)(0.2) = -3.205
y3 = y2 +f(x2,y2)h
= -3.205 + f(0.4, -3.205)(0.2) = -3.253
y4 = y3 +f(x3,y3)h
= -3.253+f(0.6,-3.253)(0.2)= -3.263
y5 = y4 +f(x4,y4)h
= -3.263 + f(0.8, -3.263) = -3.234
Example
Solve the non linear ODE : dy/dx = x + y1/2, where y(0)= 1. Use step size of
h = 0.5. Solve for y when x = 2.
14
Solution
x0 = 0 y0 = 1 f(x,y) = x + y1/2
Y1 = 1 + f(0,1)(0.5) = 1.5
Y2 = 1.5 + f(0.5,1.5)(0.5) = 2.3624
Y3 = 2.3624 + f(1.0, 2.3624)(0.5) = 3.6309
Y4 = 3.6309 + f(1.5,3.63091)(0.5) = 5.3336
This is perhaps the most popular to many engineers and scientist. However it is
not very convenient like Euler’s Method.
We calculate all the values for k’s and pluck into the formula yi+1.
Note that y0, y1, y2,…. corresponding to x0, x1, x2,…..
Example
Solution
x0 = 0 y0 = 1 f(x,y) = x + y1/2
k1 = f(x0,y0) = f(0,1)= 1
k2 = f(x0+h/2, y0+ 0.5k1h)= f(0+0.5/2, 1+ 0.5(1)0.5)
=f(.25,1.25)= 1.3680
k3 = f(x0+h/2, y0+ 0.5k2h)= f(0+0.5/2, 1+ 0.5(1.3680)0.5)
= f(.25,1.342)= 1.4084
15
k4 = f(x0+h, y0+ k3h) = f(0.5, 1+1.4084(.5))= f(0.5,1.7042)= 1.8055
16