# Numerical Methods with EXCEL

(Part 1)
Microsoft Excel is a very powerful and widely used spreadsheet. For our Numerical calculations
we shall use Scientific Calculators as well as MS Excel.
Chapter 1: Numbers and Errors
Approximation to Numbers
ecimal places (d!p!): The number of diits counted after the decimal mar!er.
"i#ni\$icant \$i#ures (s!\$!): "ll diits includin #ero are counted from the first non\$#ero diit.
%oundin#: The last retained diit is corrected up if the succeedin diit is reater than or
e%ual to &' otherwise chopped off.
Errors:
"bsolute error ( True value − "pproximate value
)elative error (
value True
value "pprox. value True −
*ercentae of error ( )elative error × +,,
From the definition' if x ( -.&. /to . d.p.0' then
&.& - &+& - ⋅ < ≤ ⋅ x or
. .
+, &. . - +, &. . -
.
+
.
+
− −
× + < ≤ × − x
and the absolute error is
.
.
+
+,

× .
&\$ a number is rounded to n decimal places' the maximum absolute error is
n −
×+,
.
+
!
Consider two numbers .-&.- and ,.,,-.12 which are rounded to 3 s.f.. The errors can be
estimated as follows
For .-&.-' the relative error is
-
.
+
-
.
+
.
+
.
+
+,
-&- . .
+,
+, -&- . .
+,

− −
× <
×
=
×
×
For ,.,,-.12. the relative error is
-
.
+
-
.
+
-
1
.
+
+,
.12 . -
+,
+, .12 . -
+,

× <
×
=
×
×
&\$ a number is rounded to n si#ni\$icant \$i#ures the maximum relati(e error is
+
.
+
+,
+ −
×
n
!
)a*lor+s )heorem with %emainder

0 / 0 /
4 0 + /
0 /
0 /
4 .
0 /
0 / 0 / 0 / 0 /
0 + /
+ .
x R a f
n
a x
a f
a x
a f a x a f x f
n
n
n
+

+ ⋅ ⋅ ⋅ + ′ ′

+ ′ − + =

where
0 /
4
0 /
0 /
0 /
c f
n
a x
x R
n
n
n

=
' c lies between a and x.
Numerical Calculations usin# Excel
To calculate mathematical expressions we need to enter formula in the Excel.
ata Entr*: There are three types of data that can be entered in a cell.
data t*pes examples descriptions
5"6E5 Solution text for caption
C7NST"NT -..3& fixed numerical data
F7)M85" (.9sin/a.0:. for calculation
9 "ll formulas M8ST bein with an e%ual sin /(0.
9 Most of the common functions are available in MS Excel with usual name. The
function name can be typed in either upper or lower case' but Excel displays it in
upper case.
5ist of functions can be searched by clic!in
x
f
 select a cateory  Select a
function.
Curve Sketching
Select data range.
In the Insert menu, select Chart
In the Chart Wizard, select Char type: XY (Scatter) and Chart sub-type.
Select Finish t cmplete the diagram.
Example: Calculate
x
e x x f
; . +
sin 0 /
− −
+ = rounded to 3 d.p. for x ( ,.&' ,.2& and +.,.
C
3 x f/x0
& ,.& (round/asin/c&0:exp/\$.;c&0'30
1 ,.2& ↓
2 +.,
Chapter ,: "olution o\$ E-uations in .ne /ariable
Number o\$ %eal %oots b* 0raphical Method
)ewrite the e%uation
, 0 / = x f
as 0 / 0 /
. +
x f x f = . Then s!etch the raph of
0 /
+
x f y = and 0 /
.
x f y =
*oints of intersection indicate the number of real roots of
, 0 / = x f
.
Location o\$ %oots
<f
0 /x f
is continuous in
= ' > b a
and
0 /a f
and
0 /b f
are opposite in sins i.e.
, 0 / 0 / < b f a f
' then there exists odd number of real roots /at least one root0 of
, 0 / = x f
in
0 ' / b a
.
Method o\$ "olution
1! 1isection Method
5et
0 /x f
be continuous in
= ' >
, ,
b a
and
, 0 / 0 /
, ,
< b f a f
' then an approximation to the
root α of
, 0 / = x f
is
0 /
.
+
, , ,
b a x + =
)epeat the process usin appropriate interval.
,! 2alse Position Method3%e#ula 2alsi Method3Linear Approximation
" root α of
, 0 / = x f
in
0 ' / b a
may be approximated by the value of the x\$intercept of the
line ?oinin the points
00 / ' / a f a
and
00 / ' / b f b
.
0 /
0 / 0 /
0 /
+
a f
a f b f
a b
a x

− =
)epeat the process usin appropriate interval.
.
4! "ecant Method
" root near
,
x
and
+
x of
, 0 / = x f
may be approximated by the x\$intercept of the secant
line /chord0 ?oinin the points
00 / ' /
, ,
x f x
and 00 / ' /
+ +
x f x . The iteration formula of the
root is iven by
0 /
0 / 0 /
0 /
+
+
+ n
n n
n n
n n
x f
x f x f
x x
x x

+

− =
' + ≥ n
5! Newton6%aphson Method
The root of the e%uation
, 0 / = x f
may be approximated by x\$intercept of the tanent line
throuh a uess value ,
x
. The iterative formula for successive iteration is
⋅ ⋅ ⋅ =

− =
+
' - ' . ' + ' , '
0 /
0 /
+
n
x f
x f
x x
n
n
n n
For a simple root the converence of the method is of order two and for a multiple root it is
linear.
For a multiple root the rate of converence can be increased by the modi\$ied Newton6
%aphson formula of the form
⋅ ⋅ ⋅ =

− =
+
' - ' . ' + ' , '
0 /
0 /
+
n
x f
x f
m x x
n
n
n n
where m is the multiplicity of the root.
7! 2ixed Point &teration 2ormula
<n order to find a root of the e%uation
, 0 / = x f
by iteration' rearrane the e%uation into a
form
0. /x g x =
The iteration formula is then
⋅ ⋅ ⋅ = =
+
' - ' . ' + ' , 0' /
+
n x g x
n n
<f x
,
is an approximation close to a root of
, 0 / = x f
and
0 /
+ n n
x g x =
+
is an iterative
formula used to find a root of the e%uation near x
,
' then
/i0 if
+ 0 /
,
< ′ x g
the se%uence ⋅ ⋅ ⋅ ' ' '
- . +
x x x will convere to the root.
<n particular'
/a0 if
, 0 / +
,
< ′ < − x g
' then the se%uence will oscillate and convere to the root.
/b0 if
+ 0 / ,
,
< ′ < x g
' then the se%uence will convere to the root without oscillation.
/ii0 if
+ 0 /
,
≥ ′ x g
the se%uence ⋅ ⋅ ⋅ ' ' '
- . +
x x x will divere.
Chapter 4: "olution o\$ "*stem o\$ Linear E-uations
@e shall consider the followin techni%ues which are suitable for numerical solution of linear
system.
1 0aussian Elimination with Partial Pi(otin#
/a0 Select pivotal e%uation for a variable for elimination /the e%uation with maximum
numerical coefficient of that variable in the system0.
-
/b0 Eliminate the chosen variable from the remainin e%uations with respect to the pivotal
e%uation.
/c0 )epeat the process for the subsystem.
/d0 8sin bac!\$substitution find solutions by usin pivotal e%uations.
,! Matrix 2actori8ation Method
<n this method the coefficient matrix A is decomposed into the product of a lower trianular
matrix L and an upper trianular matrix 9.
A : L 9
The system of e%uations becomes
L 9 X : 1
@e rewrite this system as
9 X : ;
L ; : 1
@e first solve for ; usin forward substitution and then find X usin the bac! substitution.
<n practice we use one of the followin alternatives to et uni%ue factori#ation:
/a0 Crout+s formalism: "ll the diaonal elements of 8 is choesen +.
/b0 olittle+s formalism: "ll the diaonal elements of 5 is choesen +.
4! &terati(e Method
<terative method for linear system is similar as the method of fixed\$point iteration for an e%uation
in one variable. To solve a linear system by iteration' we solve each e%uation for one of the
variables' in turn' in terms of the other variables.
"n iterative method converes' for any choice of the first approximation' if every e%uation
satisfies the condition that the manitude of the coefficient of solvin variable is reater than the
sum of the absolute values of the coefficients of the other variables. " system satisfyin this
condition is called diaonally dominant. " linear system can always be reduced to diaonally
dominant form by elementary operations.
(a) <acobi+s Method
Startin with an initial set of values' if not iven' derive a new set of solution.
)epeat the calculations till the re%uired accuracy is obtained.
(b) 0auss6"eidel Method
Start with initial values and update the value of variables in each calculation.
Chapter 5: &nterpolation and 2inite i\$\$erences
Pol*nomial &nterpolation
Aiven the values of a function f/x0 at /n:+0 distinct points n
x x x x ' ' ' '
. + ,
⋅ ⋅ ⋅
we can
construct a uni-ue polynomial of deree less than e%ual to n which satisfies the conditions
n i x f x p
i i
' ' - ' . ' + ' , 0' / 0 / ⋅ ⋅ ⋅ = =
0eneral 2orm
"n nth deree polynomial can be ta!en as
n
n
x a x a x a x a a x p + ⋅ ⋅ ⋅ + + + + =
-
-
.
. + ,
0 /
3
To fit this polynomial to /n:+0 set of points we have to solve /n:+0 simultaneous e%uations
and is very tedious.
Newton 2orm
" form which is convenient to use is suested by Newton is
0 / 0 0/ / 0 0/ / 0 / 0 /
+ + , + , . , + , −
− ⋅ ⋅ ⋅ − − + ⋅ ⋅ ⋅ + − − + − + =
n n
x x x x x x a x x x x a x x a a x p
i(ided i\$\$erences
Bivided differences are defined as follows:
0 / = >
, ,
x f x f =
, +
, +
+ ,
= > = >
= ' >
x x
x f x f
x x f

=
, .
+ , . +
- + ,
= ' > = ' >
= ' ' >
x x
x x f x x f
x x x f

=
=====================!!
,
+ + , . +
- + ,
= ' ' ' > = ' ' ' >
= ' ' ' ' >
x x
x x x f x x x f
x x x x f
n
n n
n

=

 

Note that divided differences are symmetric about their aruments.
Newton &nterpolation 2ormula
<n terms of the divided differences interpolatin polynomial can be written as
 + − − + − + = 0 0/ =/ ' ' > 0 =/ ' > = > 0 /
+ , . + , , + , ,
x x x x x x x f x x x x f x f x p
0 / 0 0/ =/ ' ' ' ' >
+ + , . + , −
− − − +
n n
x x x x x x x x x x f  
2inite i\$\$erence .perators
"ssume that the tabular points
n
x x x x ' ' ' '
. + ,
⋅ ⋅ ⋅
are e%uispaced' that is
n r rh x x
r
' ' . ' + ' , '
,
 = + =
with step si#e h. @e define
"hi\$t .perator: 0 / 0 / h x f x f
r r
+ = Ε
2orward i\$\$erence .perator: 0 / 0 / 0 /
r r r
x f h x f x f − + = ∆
1ac>ward i\$\$erence .perator: 0 / 0 / 0 / h x f x f x f
r r r
− − = ∇
Central i\$\$erence .perator:
0 / 0 / 0 /
. .
h
r
h
r r
x f x f x f − − + = δ
A(era#in# .perator: 0 / 0 / 0 /
. .
h
r
h
r r
x f x f x f − + + = µ
)epeated applications of the difference operators ive the followin hiher order differences:
0 / 0 / nh x f x f
r r
n
+ = Ε
r
n
r
n
r
n
f f x f
+
+
+
0 /

+

∆ − ∆ = ∆
r
n
r
n
r
n
f f x f
+
+
+
0 /

+

∇ − ∇ = ∇
where 0 /
r r
x f f = .
@e also have
&
k
k
k
k
k
k
f
h k
f
h k
x x x x f ∇ = ∆ =
4
+
4
+
= ' ' ' ' >
, . + ,

Newton60re#or* 2orward i\$\$erence &nterpolation
)eplacin the divided differences in the Newton interpolation formula by the forward
differences' we have
,
+ + ,
,
.
.
+ ,
,
,
,
4
0 / 0 0/ /
4 .
0 0/ / 0 /
0 / f
h n
x x x x x x
f
h
x x x x
f
h
x x
f x p
n
n
n

− − −
+ + ∆
− −
+ ∆

+ =

Substitutin
h
x x
s
,

= ' we have +
+
− =

s
h
x x
and so on
The above interpolation formula becomes
, ,
.
, ,
4
0 + / 0 . 0/ + /
4 .
0 + /
0 / f
n
n s s s s
f
s s
f s f x p
n

+ − − −
+ + ∆

+ ∆ + =

where
h
x x
s
,

= .
Newton60re#or* 1ac>ward i\$\$erence &nterpolation
)eplacin the divided differences in the Newton interpolation formula by the bac!ward
differences' we have
n
n
n
n n
n
n n
n
n
n
f
h n
x x x x x x
f
h
x x x x
f
h
x x
f x p ∇
− − −
+ + ∇
− −
+ ∇

+ =
− −
4
0 / 0 0/ /
4 .
0 0/ / 0 /
0 /
+ ++ .
.
+

Substitutin
h
x x
u
n

= ' we have +
+
+ =

u
h
x x
n
and so on
The above interpolation formula becomes
n
n
n n n
f
n
n u u u u
f
u u
f u f x p ∇
− + + +
+ + ∇
+
+ ∇ + =
4
0 + / 0 . 0/ + /
4 .
0 + /
0 /
.

where
h
x x
u
n

= .
La#ran#e &nterpolatin# Pol*nomial
5arane polynomial of deree one passin throuh two points
0 ' /
, ,
y x
and 0 ' /
+ +
y x is
written as
+
, +
,
,
+ ,
+
+
0 / y
x x
x x
y
x x
x x
x L

+

=
5arane polynomial of deree two passin throuh three points
0 ' /
, ,
y x
' 0 ' /
+ +
y x and
0 ' /
. .
y x is written as
.
+ . , .
+ ,
+
. + , +
. ,
,
. , + ,
. +
.
0 0/ /
0 0/ /
0 0/ /
0 0/ /
0 0/ /
0 0/ /
0 / y
x x x x
x x x x
y
x x x x
x x x x
y
x x x x
x x x x
x L
− −
− −
+
− −
− −
+
− −
− −
=
5arane polynomial of deree three passin throuh four points
0 ' /
, ,
y x
' 0 ' /
+ +
y x '
0 ' /
. .
y x and
0 ' /
- -
y x
is written as
+
- + . + , +
- . ,
,
- , . , + ,
- . +
-
0 0/ 0/ /
0 0/ 0/ /
0 0/ 0/ /
0 0/ 0/ /
0 / y
x x x x x x
x x x x x x
y
x x x x x x
x x x x x x
x L
− − −
− − −
+
− − −
− − −
=
-
. - + - , -
. + ,
.
- . + . , .
- + ,
0 0/ 0/ /
0 0/ 0/ /
0 0/ 0/ /
0 0/ 0/ /
y
x x x x x x
x x x x x x
y
x x x x x x
x x x x x x
− − −
− − −
+
− − −
− − −
+
Similar for hiher deree polynomials.
1