0% found this document useful (0 votes)
188 views

Numerical Analysis

This document contains code and calculations related to numerical interpolation using divided differences. It begins by providing sample data and defining a determinantal function to calculate values of f(x) using linear interpolation. It then calculates the first three divided differences for the given data and uses them to determine approximate values of f(x) for various x values using linear interpolation. It also discusses the relationship between divided differences and the mean value theorem. Finally, it presents several problems analyzing properties of divided differences.

Uploaded by

Joshua Cook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views

Numerical Analysis

This document contains code and calculations related to numerical interpolation using divided differences. It begins by providing sample data and defining a determinantal function to calculate values of f(x) using linear interpolation. It then calculates the first three divided differences for the given data and uses them to determine approximate values of f(x) for various x values using linear interpolation. It also discusses the relationship between divided differences and the mean value theorem. Finally, it presents several problems analyzing properties of divided differences.

Uploaded by

Joshua Cook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Math 481A

Assignment 1

Joshua Cook
September 26, 2014

2.1
Use (2.2.5)


f (x0 ) x0 x
1


f (x) =
x1 x0 f (x1 ) x1 x
to calculate values of f (x) when x = 1.1416, 1.1600, and 1.2000 from the following table of rounded data.
x
f (x)

1.1275
0.11971

1.1503
0.13957

1.1735
0.15931

1.1972
0.17902

Code
from numpy import array, empty
from numpy.linalg import det
## data
x_list = [1.1275, 1.1503, 1.1735, 1.1972]
fx_list = [0.11971, 0.13957, 0.15931, 0.17902]
### create a numpy array of data
data=array([
array(x_list),
array(fx_list)])
## define determinantal
def determinantal(x,data,a,b):
localdata = empty([2, 2])
localdata[:,0] = data[:,a]
localdata[:,1] = data[:,b]
determinant = empty([2, 2])
determinant[0,0] = localdata[1,0]
determinant[1,0] = localdata[1,1]
determinant[0,1] = localdata[0,0] - x
determinant[1,1] = localdata[0,1] - x
return 1/(localdata[0,1]-localdata[0,0])*det(determinant)
Result
In [58]: determinantal(1.1416,hw.data,0,1)
Out[58]: 0.1319918421052631
In [59]: determinantal(1.1600,hw.data,1,2)
Out[59]: 0.14782336206896543

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

In [60]: determinantal(1.1200,hw.data,0,1)
Out[60]: 0.11317710526315801

2.2
Calculate the first three divided differences relevant to successive pairs of data in Prob. 1, and use
f (x) f (x0 ) + (x x0 )f [x0 , x1 ] for f [x0 , x1 ]

f (x1 ) f (x0 )
x1 x0

to determine approximate values of f (x) for


x = 1.1600(0.0020)1.1700
where x = m(h)n denotes that x is to take on values between x = m and x = n inclusive at increments of h
units.
Code
def first_dd(p_0,p_1):
return (p_1[1]-p_0[1])/(p_1[0]-p_0[0])
def linear_interp(x,p_0,p_1):
return p_0[1]+(x-p_0[0])*first_dd(p_0,p_1)
Output - Divided Differences
In [62]: hw.first_dd(hw.data[:,0],hw.data[:,1])
Out[62]: 0.87105263157894164
In [63]: hw.first_dd(hw.data[:,1],hw.data[:,2])
Out[63]: 0.85086206896552175
In [64]: hw.first_dd(hw.data[:,2],hw.data[:,3])
Out[64]: 0.83164556962025149
Output - Linear Interpolations
In [67]: hw.linear_interp(1.1600,hw.data[:,1],hw.data[:,2])
Out[67]: 0.1478233620689654
In [68]: hw.linear_interp(1.1620,hw.data[:,1],hw.data[:,2])
Out[68]: 0.14952508620689645
In [69]: hw.linear_interp(1.1640,hw.data[:,1],hw.data[:,2])

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

Out[69]: 0.15122681034482749
INTERPOLATION WITH DIVIDED DIFFERENCES

71

In
[70]:
In Krogh
[1970J,hw.linear_interp(1.1660,hw.data[:,1],hw.data[:,2])
algorithms are presented for the purpose of making the
use Out[70]:
of Newton's divided-difference
formula for interpolation and numerical
0.15292853448275853
differentiation on a computer compare favorably in efficiency with the use of
other formulas.
In
[71]:of iterated
hw.linear_interp(1.1680,hw.data[:,1],hw.data[:,2])
A method
interpolation similar to that of Aitken [1932bJ
is due
to Neville [1934J;
see also Kopal [1961]. References to additional
Out[71]:
0.15463025862068958
methods of inverse interpolation are included in Sec. 3.12 and Sec. 4.13.
For the use of divided differences in two-dimensional analysis see, for
example,
Salzer [1959J
and Stancu [1964].
In [72]:
hw.linear_interp(1.1700,hw.data[:,1],hw.data[:,2])
Out[72]: 0.15633198275862065
PROBLEMS

2.3

Section 2.2
1 Use (2.2.5) to calculate approximate values of/ex) when x

1.1416, 1.1600, and

INTERPOLATION WITH DIVIDED DIFFERENCES

71

1.2000 from the folIowing rounded data:

(x0 )
f [x0 , x1 ] f (xx11)f
which is the slope, f 0 (x) for a linear function through (x0 , f (x0 )) and (x1 , f (x1 )). For
x0
1.1503
1.1735
1.1972
x 11.1275 In Krogh
[1970J,for
algorithms
presented
the purposedifference
of making the is equal to f 0 (x) if and only if
a linear function, the
slope
is constant
all
x are
R.
Thefordivided
[(x)
0.11971
0.13957
0.15931
0.17902 formula for interpolation and numerical
use of Newton's
divided-difference
f (x) is linear. Therefore, the
divided
difference
is
independent
of
x
x1 ofif and only if f (x) is linear.
0 and
differentiation on a computer compare favorably in efficiency with
the use

2 Calculate the three first divided differences relevant to successive pairs of data
other formulas.
in Prob. 1, and use (2.2.4) to determine approximate
values of/ex) for
A method of iterated interpolation similar to that of Aitken [1932bJ
x is= due
1.1600(O.0020)1.l700t
to Neville [1934J; see also Kopal [1961]. References to additional
methods
3 Prove that /[xo, xd is independent of Xo and
Xl if of
andinverse
only ifinterpolation
lex) is a linearare included in Sec. 3.12 and Sec. 4.13.
function of x.
For the use of divided differences in two-dimensional analysis see, for
4 If lex) = U(X)V(X), show that
example, Salzer [1959J and Stancu [1964].

2.4

/[xo,

xd

5 Iff'(x) is continuous for Xo

u[xo]v[xo,

xd + u[xo, xdv[xd

Xl' show that

f (x0 )
x1 x0
calculate
values of/ex)
u(x01)v(x
, xtl to
J[xo, xo] == 1limUse
f[x(2.2.5)
!'(xo) 1 )approximate
ou(x
1=)v(x
0 ) when x = 1.1416, 1.1600, and
1.2000
= from the folIowing rounded data:
x1 x0
1.1503
1.1735
1.1972
x 11.1275
Section 2.3
u(x0 )v(x0 ) + u(x
u(x0 )v(x
u(x1 )v(x1 )
[(x) 0 )v(x
0.119711 )
0.13957
0.159311 ) +
0.17902
=
6 If the abscissas in Prob. 1 are numbered in increasing
algebraic order, verify
x

x
1
2 Calculate the three first divided differences relevant
to0 successive pairs of data
numericalIy that/[xo, Xl> xz] = /[xz, Xo. xd.
in Prob. 1, and use (2.2.4) to determine approximate values of/ex) for
= u[x1 ]v[x0 , x1 ] + v[x1 ]u[x0 , x1 ]
PROBLEMS
f (x1 )

f [x0 , x1 ]

for some'; between Xo and

Xl>

Section
and hence also
that 2.2
JCl-+XO

t The notation
x =

II,

x = m(h)1I denotes that x is to take on values between x = m and


inclusive, at increments of h units.

2.5

= 1.1600(O.0020)1.l700t

3 Prove that /[xo, xd is independent of Xo and Xl if and only if lex) is a linear


function of x.
4 If lex) = U(X)V(X), show that

/[xo,

xd

5 Iff'(x) is continuous for Xo

for some'; between Xo and

Xl>

u[xo]v[xo,

xd + u[xo, xdv[xd

Xl' show that

and hence also that


J[xo, xo] == lim f[x o, xtl = !'(xo)
JCl-+XO

Section 2.3

Mean Value Theorem

6 If the abscissas in Prob. 1 are numbered in increasing algebraic order, verify


numericalIy that/[xo, Xl> xz] = /[xz, Xo. xd.
t The notation

x = m(h)1I denotes that x is to take on values between x = m and

x =
inclusive, at increments of h units.
This is essentially a proof of the Mean
Value
Theorem, again showing the divided difference as an analog to
slope.
II,

. . . If a function f is continuous on the closed interval [a, b], where a < b, and differentiable on
(a)
the open interval (a, b), then there exists a point c in (a, b) such that f 0 (c) = f (b)f
ba

Math 481A
Assignment 1

Joshua Cook
September 26, 2014
wikipedia


Let g(x) = f (x)

f (x1 ) f (x0 )
(x x0 ) + f (x0 )
x1 x0

Rolles Theorem States that if f (a) = f (b), then f must attain either a maximum or a minimum at some
c between a and b
Then, g(x0 ) = g(x1 ) = 0 for g(x) continuous on [x0 , x1 ], because f 0 (x) is continuous on [x0 , x1 ]. Then, by
Rolles Theorem, there exists in (x0 , x1 ) such that g 0 () = 0.

f (x1 ) f (x0 )
x1 x0
f (x1 ) f (x0 )
g 0 () = f 0 ()
x1 x0
f
(x
)

f
(x
1
0)
f 0 () =
x1 x0

g 0 (x) = f 0 (x)

Figure 1: Mean Value Theorem

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

f (x1 ) f (x0 )
x1 x0
f ( + h) f ( h)
f 0 () = lim
h0
2h
Let + h = x1
f [x0 , x1 ]

(slope of f (x) through (, f ()))

Let h = x0
f ( + h) f ( h)
2h
f [x0 , x0 ] = f 0 ()
f [x0 , x1 ] =

72

72

(as h 0)

INTRODUCTION TO NUMERICAL ANALYSIS

2.7
INTRODUCTION TO NUMERICAL ANALYSIS

7 Suppose that x. = Xo + rh (r = 1,2, ... ), so that the abscissas are at a uniform


spacing h. Show that (2.3.3) then becomes
7 Suppose
that x. = Xo + rh (r = 1,2, ... ), so that the abscissas are at a uniform
_ becomes
(_I)k-1 1 _ (_I)k-1
then
spacing h. Show that (2.3.3) (k)

IXI

i! (k - i)!

hk - IFk!

(k)
i

(_I)k-1 1 _ (_I)k-1
is the binomial coefficient.
IXI Thus
- i!deduce
(k - that
i)!
(k) _

where

hk - IFk!

(k)
i

where

is the binomial
![xo,"coefficient.
., Xk] = Thus deduce
(-ll-lthat !(Xl)

6
k

in this case.
![xo,"
., Xk] =
(-ll-lthe truth
!(Xl)
8 Assuming that x. = Xo + rh,
verify directly
(from the definition)
of the
1
following special cases of the relation
(k) established in Prob. 7:

i =
in this case.
(xi x0 ) . . . (xi xi1 )(xi xi+1 ) . . . (xi xn )
1
8 Assuming that
x.xd
= =Xo - +[I(XI)
rh, verify
directly
(from the definition) the truth of the
![xo,
- !(xo)]
h the relation established in Prob. 7:
following special cases of

If xr = x0 + rh, for r = 1, 2, /dots, xi xk = x0 + ih x0 kh = (i k)h. Then,


![xo, xl> X2] =
1 [!(X2) - 2f(XI) + !(xo)]
![xo,

xd

2!h
= - [I(XI) - !(xo)]

1
1
(k)
![Xo.
i Xl.=X2, X3] = - -3 [!(X3) - 3!(X2) + 3!(XI) - !(Xo)]
3!
h
2)h)- . .2f(XI)
. (h)(h)(2h)
![xo, (ih)((i
xl> X2]
= 1)h)((i
[!(X2)
+ !(xo)] . . . (i k)h

2!h
9 If j'(x) = d!(x)/dx, show that
2.9 ![Xo. Xl. X2, X3] = -1-3 [!(X3) - 3!(X2)

3! h

(1)ki k!
(1)ki
=
k
i!(k 1)!h k
k!hk

3!(XI) - !(Xo)]

unless lex) is linear.


9 If j'(x) = d!(x)/dx, show that

10 If lex) = u(x)v(x), show that the relation established in Prob. 4 generalizes to

the form

unless lex) is linear.


10 If
lex)
= u(x)v(x),
show
that of
thetherelation
in Prob.
generalizes to
Use
induction,
assuming
the truth
relation established
for n = N. showing
that4then

the form

L {(XN+I
k=O

- Xk)U[XO .. . Xk]V[Xk" .. XN+ tl

+ (Xk+l - the
xo)u[xo,,
Xk+tlV[Xk+l>""
Use induction, assuming
truth of the
relation for n XN+I])
= N. showing that then
and that this expression properly reduces to
N

L
k=O

(XN+I - xo) (U[Xo]V[Xo, . .. XN+tl


=
{(XN+I - Xk)U[XO .. . Xk]V[Xk" .. XN+

tl

L+ (Xk+l
u[xo,""

xo)u[xo,,
Xk+tlV[Xk+l>"" XN+I])
Xk]V[Xk... XN+tl

k=l

+ u[xo..
and that this expression properly reduces
to XN+tlV[XN+l]
(XN+I - xo) (U[Xo]V[Xo, . .. XN+tl
N

 
k
i

Math 481A
Assignment 1



d f (x) f (x0 )
f 0 (x) f 0 (x0 )
6
dx
x x0
x x0
0
f (x)(x x0 ) (f (x) f (x0 ))
6
(x x0 )2
f 0 (x)
(f (x) f (x0 ))
6

x x0
(x x0 )2
f 0 (x)
(f (x) f (x0 )) 1

6
x x0
x x0
x x0
f 0 (x)
f 0 (x0 )

6
x x0
x x0
f 0 (x) f 0 (x0 )
f 0 (x) f 0 (x0 )

x x0
x x0

Joshua Cook
September 26, 2014

(for f (x) linear)


(therefore, they are equivalent for a linear function)

Math 481A
Assignment 1

Joshua Cook
September 26, 2014
INTERPOLATION WITH DIVIDED DIFFERENCES

2.11

73

= (ax + h)/(cx + d), obtain expressions for f[x, Yl, f[x, x, Yl, and
f[x, x, Y, y] in compact forms when x'" y.
12 If f(x) = x 5 , obtain expressions for f[a, h, c l, f[a, a, h l, and f[a, a, a] when

11 If f(x)

a'" h '" c.

f [x, y] =

Section 2.4

ay+b
cy+d

ax+b
cx+d

yx

f [x,
y] fdifference
[x, x]
13 Repeat the calculations of Prob. 2, making use of the second
divided
f [x, x, y] =

f[ao, al> a2]'

yx

14 Compare the results of Prob. 13 with those obtained by usingax+b


the second
divided
ay+b
cx+d cy+d
differencef[al> a2, a3] instead.
=
15 Obtain the formula
yx

f [x, y, y] = f [x, y] =

ay+b
cy+d

ax+b
cx+d

yx
f [x, y, y] f [x, x, y]
f [x, x, y, y] =
yx

ay+b
ay+bDIFFERENCES
ax+b
ax+b
INTERPOLATION WITH DIVIDED
75
cy+d cx+d
cx+d cy+d

yx

yx

16 Apply the formula of Prob. 15, neglecting the error term,=to the data of Prob. 1,
yx
obtaining approximate values of the integral of f(x) over0 each subinterval and

ax+b
ax+b
hence obtaining also approximate values of the integral from ay+b
the smallest
abscissa

4
4
cy+d
cx+d
cx+d
the integral
over
to each of the others. Then use interpolation to approximate
=
13
2
(y

x)
3
30
10
[1.14, 1.18].
63

Section 2.5
17 If f(x) = 1/(a - x), show that
f [xo, x., .

, x n]

ax+b
2 ay+b
17
219 2 cx+d
cy+d

(y
515

515

8
= .,------,..,---.,-----:---,.

(a - xo)(a - XI)'" (a - x n)

Also use a similar procedure to obtainf'(3).


2.23
and

148

x)2

515

Determine an analytic expression for

f(x) and check the results.


1
f[xo, xl>""
x m x]
----:---,-----:-------,23 Iff(XI),f(XZ)'
andf(x3)
are=values
a maximum
or minimum
point at
(a - off(x)
xo)(a -near
x.)
(a - xn)(a
- x)
x = deduce
x, obtain
and
thatthe approximation
_1_ = __
1_
a - x
a - Xo

x
+ __x_-_x.::..o_ _
(a - xo)(a - XI)

+
+ ...2
Xl

Xz _

f[xlt xz]

2f[xlt Xz, X3]

and show that it can also be written


more symmetrical
form
+ (xin -thexo)'"
(x - Xn_l) + E(x)

Xl

where

(a X3
- xo)
- x+n )f[xz. X3]
2xz +
_ f[Xlt(axz]
4
4f[xlt Xz, X3]

E(x) = it becomes
n(x)
Show also that, when the abscissas are equaIly spaced,

n(a)(a - x)

where h is the common interval.

x1 , x2 , x3 (
x h, x
+ h), for h sufficiently close to x
.
Section 2.6
0
A maximum or minimum will occur where f (x) = 0.
24 Show that the truncation error associated with linear interpolation of f(x), using
fordinates
(x) canatbe
Newtons
Fundamental
Formula.
Xo approximated
and XI with Xo using
x
Xlt
is not larger
in magnitude than
tMZ(XI - xo)Z

where M z is the maximum value of If"(x) I on the interval [xo, xtJ. Does this
result hold also for extrapolation?
25 Under the assumption that the data in Prob. 1 correspond to the functionf(x) =
sin (log x), show that the truncation error corresponding to linear interpolation
between successive ordinates is smaIler than one unit in the fourth decimal place.
26 Show that the magnitude of the truncation error, corresponding to linear interpolation of the error function

ay+b
cy+d

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

Let f (x) f [x1 ] + (x x1 )f [x1 , x2 ] + (x x1 )(x x2 )f [x1 , x2 , x3 ]


f 0 (x) f [x1 , x2 ] + (2x (x1 + x2 ))f [x1 , x2 , x3 ]
f 0 (
x) f [x1 , x2 ] + (2
x (x1 + x2 ))f [x1 , x2 , x3 ] = 0
2
xf [x1 , x2 , x3 ] f [x1 , x2 ] + (x1 + x2 )f [x1 , x2 , x3 ]
INTERPOLATION WITH DIVIDED DIFFERENCES

Similarly x

2
x
x

75

f [x1 , x2 ] + (x1 + x2 )f [x1 , x2 , x3 ]


2f [x1 , x2 , x3 ]
0
(x1 + x2 )
f [x1 , x2 ]

4
4
2
2f [x1 , x2 ,13
x3 ]
(x2 + x3 ) 3 f [x30
] 10
2 , x363

62f [x219
2
1 , x2 , x3 ]17
148
(x1 + x2 ) 8 f [x
(x2 + x3 )
f [x2 , x3 ]
515
1 , x2 ]

2
2
2f [x1 , x2 , x3 ]
1 , x2 , x3 ]
82f [x515
(x1 + 2x2 + 8x3 ) 515f [x1 , x2 ] + f [x2 , x3 ]

4
4f [x1 , x2 , x3 ]

Also use a similar procedure to obtainf'(3). Determine an analytic expression for


f(x) and check the results.
equally spaced
x1 = near
x2 a hmaximum
and x3or=minimum
x2 + h.point at
23 For
Iff(XI),f(XZ)'
andf(x3)abscissas,
are values off(x)
x = x, obtain the approximation

Xl

+
2

Xz _

f[xlt xz]

f [x
x2 ] + f [x2 , x3 ]
2f[xlt
Xz,1 ,X3]

x
x2

4f [x1 , x2 , x3 ]
and show that it can also be written in the more symmetrical form

Xl

2xz

f [xX3]
1 , x2 ] + f [x2 , x3 ]
X3 _ f[Xlt
xz]
+ 1f[xz.
x
2
f [x2 ,x3 ]f [x1 ,x2 ]
4
4f[xlt Xz, X3]
2h

Show also that, when the abscissas are equaIly spaced, it becomes
2 f [x1 , x2 ] + f [x2 , x3 ]

x2

where h is the common interval.

h f [x2 , x3 ] f [x1 , x2 ]
f3 f1
2
x2
h f3 2f2 + f1

2.24

Section 2.6
24 Show that the truncation error associated with linear interpolation of f(x), using
x
Xlt is not larger in magnitude than
ordinates at Xo and XI with Xo
tMZ(XI - xo)Z

where M z is the maximum value of If"(x) I on the interval [xo, xtJ. Does this
result hold also for extrapolation?
25 Under the assumption that the data in Prob. 1 correspond to the functionf(x) =
Alternative
method
fortruncation
derivingerror
error
is by defining
sin (log x), show
that the
corresponding
to linear interpolation
between successive ordinates is smaIler than one unit in the fourth decimal place.
26 Show that the magnitude of the truncation error,
corresponding
linearinterF (x)
= f (x) toy(x)
K(x)
polation of the error function

for (x) =

Qn

i=0 (x

J; f:

t
xi ) and K is defined
K(x)
= f (x) y(x) at n + 2 points, x0 , ..., xn and
' dt
erf X =so that e-

Then, for a linear function, f (x), F (x) = 0, three times, F 0 (x) = 0, twice times, F 00 (x) = 0, once. Take
F 00 () = 0.

76

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

INTRODUCTION TO NUMERICAL ANALYSIS

between Xo and

Xl>

cannot exceed

For a linear interpolation y 00 (x) = 0, therefore K =

f 00 ()
2!

and the error is given by

f 00 ()

and hence is smaller than (Xl - xo)2/8.


E(x) =
(x)
2!
27 In the special case when the abscissas are equally spaced, with separation
h, show
that the magnitude
of
the
truncation
error
corresponding
to
second-degree
inter00
f ()
For
M2
polation
based3!on, ordinates at Xo, Xl> and X2 does not exceed (M3h 3)/(9./3),
where M 3 is the maximum value of Ifm(x)1 on the interval [xo. X2]. Show also
M2 to occurMat2 distances of
that, on the average, the largest errors may be expected
E(x)
(x) =
(x x0 )(x x1 )
about h/.Ji 0.58h from the central abscissa. (Translate
the origin
2!
2! to the point
x = Xl')
maximum
on the
entire
interval
i.e. associated with third-degree
28 With
Show a
that
the magnitude
of the
truncation
error
interpolation based on ordinates at equally spaced points Xo, Xl> X2, and X3 does
not exceed (3M4h 4)/128 for interpolation between Xl and X2M
and
is, on the average,
2
4 )/24
E(x)
not(xexceed
x0(M
)(x4 h
x1 )
largest at the center of that interval. Show also that
it does
2!
for interpolation between Xo and Xl or between X2 and X3' with a maximum to be
expected, on the average, at a distance of about (3 - .JS)h/2
0.38h from Xo
2.29
or X3. where M 4 is the maximum value of liV(x)! on [xo, X4] in all cases. [Translate the origin to the midpoint (Xl + x2)/2.]
29 Obtain the formula
f(x) = f(xo)

(x - xo)f'(xo)

(x - XO)2J[XO' Xo,

xrl

(x - XO)2(X - xI)f[xo. xo. Xl' Xl]

E(x)

where
E(x)

and show that

-r,.(x - XO)2(X -

h4

IE(x)1 ;"i: max


384

IfiV(x)1

30 If f(x) = 1/(x + 1) and y(x) is the polynomial approximation of degree n which


1
2
f (x)
f [x0X] +
[x0, ,n,x0show
] + that
(x)f
x0(2.6.5)
, x1 ] +
3 (x)f
0 ,of
[(x)=when
=
0, (x)f
1, 2, ...
the [x
use
leads
to the[x0 , x0 , x1 , x1 ] + E(x)
agrees with
error bound = f + (x x )f 0 (x) + (x x )2 f [x , x , x ] + (x x )2 (x x )f [x , x , x , x ] + E(x)
0
0
0
0
0
1
0
1
0
0
1
1
IE(x) I < Ix(x - 1) (x - n)1
whereas (2.6.1) permits the less conservative bound
1
(4)
(4)
IE(x)1 < - - - I x ( x - 1)(x)f
.. (x - ()
n)1
(n

=
+ E(x)
I)!

4!

when X
O.
1
x0 )2 (x x1 )2 f (4) ()
= to (x
31 Suppose that a table presents values of [(x) rounded
24 r decimal places at a uniform interval h in x, and that linear interpolation is employed for the calculation of

Maximum E(x) at E 0 (x) = 0.

E 0 (x) = 2(x x0 )(x x1 )2 + 2(x x0 )2 (x x1 ) = 0


x1 + x2
= (x x0 )(x x1 )(4x 2x1 2x0 ) = x
=
2
Maximum E(x) =

h4
384

max |f (4) (x)|

or X3. where M 4 is the maximum value of liV(x)! on [xo, X4] in all cases. [Translate the origin to the midpoint (Xl + x2)/2.]
29 Obtain the formula
f(x) = f(xo)

(x - xo)f'(xo)

(x - XO)2J[XO' Xo,

xrl

(x - XO)2(X - xI)f[xo. xo. Xl' Xl]

E(x)

where

Math 481A
E(x) =1 -r,.(x
Assignment
and show that

2.30

Joshua Cook
September 26, 2014

- XO)2(X -

h4

IE(x)1 ;"i: max


384

IfiV(x)1

30 If f(x) = 1/(x + 1) and y(x) is the polynomial approximation of degree n which


agrees with [(x) when X = 0, 1, 2, ... , n, show that the use of (2.6.5) leads to the
error bound
IE(x) I < Ix(x - 1) (x - n)1
whereas (2.6.1) permits the less conservative bound
1
IE(x)1 < - - - I x ( x - 1) .. (x (n

+ I)!

n)1

when X
O.
31 Suppose that a table presents values of [(x) rounded to r decimal places at a uniformhave
interval
in x, and thatequations
linear interpolation is employed for the calculation of
We
theh following

E(x) = (x)f [x0 , x1 , . . . , xn , x]


1
E(x) =
f (n+1) ()(x)
(n + 1)!
1
= f [x0 , x1 , . . . , xn , x] =
f (n+1) ()
(n + 1)!

(2.6.1)
(2.6.5)
(2.6.8)

The last implied by the equivalence of the first two. Yet the author claims that the first equation implies
|E(x)| <

1
|(x)|
(n + 1)!

and the second implies


|E(x)| < |(x)|
on the given interval x = 0, 1, 2, . . . , n. Note the equal spacing of the interval.
What about the framing of this problem allows the two error expressions to differ?
The answer lies in the derivatives of f (x).
n
0
1
2
3
4
5
n
n+1

f n (x)
(x + 1)1
1!(x + 1)2
2!(x + 1)3
3!(x + 1)4
4!(x + 1)5
5!(x + 1)6
(1)n n!(x + 1)(n+1)
(1)n+1 (n + 1)!(x + 1)(n+2)

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

1
f (n+1) ()(x)
(n + 1)!
1
E(x) =
(1)n+1 (n + 1)!( + 1)(n+2) (x)
(n + 1)!
E(x) =

(2.6.5)

|E(x)| = ( + 1)(n+2) (x)


116

|E(x)| (x)

INTRODUCTION TO NUMERICAL ANALYSIS

PROBLEMS

3.1 3.2
Section
1 By noticing that the zeroth lagrangian coefficient function of degree n takes on
the value unity when x = Xo and the value zero when x = Xl>' , x.. and by

considering the associated divided-difference table (or otherwise), show that


lo(x)

= I +x-- -Xo- +
Xo - Xl

(x - xo)(x - Xl)
(Xo - Xl)(XO - Xz)

+ ...

(X - Xo) .. (X - Xn-l)
(XO - Xl) . (XO - Xn)

and that similar expansions can be written down by symmetry for the other coefficient functions.
2 Derive the lagrangian interpolation formula directly from the newtonian divided.
This
problem
is asking us to express each lagrangian coefficient function as a polynomial using Newtons
difference
formula.
3 Fundamental
If y(x) is the polynomial
of degree
n whichlagrees
with be
f(x)estimated
at the distinct
Formula.
Therefore,
aspoints
0 (x) can
X = Xo, Xl>'" ,X.. and if n(x) == (x - xo)(x - Xl)'" (X - x n), obtain the
lagrangian form of y(x) by determining the coefficients in the partial fraction
expansion of the ratio

l0 (x) f [x0 ] + 1 (x)f [x0 , x1 ] + 2 (x)f [x0 , x1 , x2 ] + + (x)f [x0 , . . . , xn ]


y(X)

---..!!L

fn(x)
f [x1 , x2 ] f [x0 , x1 ]
1 f0L.- X - Xt
k=O
f (x0 ) + (x x0 )
+ (x x0 )(x x1 )
+ ...
x1 x0
x2 x0
(Multiply both members by X-X. and let X -> x )
f2 f1
0
xf11 f
f0
4 Show that
x0
1 + (x x0 )
+ (x x0 )(x x1 ) x2 x1
+ ...
1 al
x1 x0
x2 x0
1 az a!
- al)(a3 - al)(a3 - a z)
f0
x = x(az
0

+ (x x0 )(x x1 )
+ ...
1 1a3+
x0 x1
(x1 x0 )(x2 x0 )
and use this fact to express the result
ofx
expanding
x
(xthe
left-hand
x0 )(x member
x1 ) of (3.2.3)
0
1of
+the first column,
+ and equating the result+to. .zero,
.
with respect to the elements
x x1
(x0 x1 )(x0 x2 )
in lagrangian form when n = 2. 0
5 Generalize the result of Prob. 4 to show that

This could certainly be repeated for other langrangian coefficient functions.

n-l

an
= (az -

al)(a3 - al)(a3 -

aZ)(a4 -

al)(a4 - aZ)(a4 - a3)'" (an - an-I)

and to derive the lagrangian form of the interpolation polynomial from (3.2.3) in
the general case. (The determinant involved here is often called Vandermonde's
determinant.)

and that similar expansions can be written down by symmetry for the other coefficient functions.
2 Derive the lagrangian interpolation formula directly from the newtonian divided.
difference formula.
3 If y(x) is the polynomial of degree n which agrees with f(x) at the distinct points
X = Xo, Xl>'" ,X.. and if n(x) == (x - xo)(x - Xl)'" (X - x n), obtain the
lagrangian form of y(x) by determining the coefficients in the partial fraction
Math 481A
expansion of the ratio

Assignment 1

y(X)
n(x)

3.4

Joshua Cook
September 26, 2014

---..!!L
L.X - Xt
k=O

(Multiply both members by X-X. and let X -> x )


4 Show that
1 al
1 az a! = (az - al)(a3 - al)(a3 - a z)
1 a3
and use this fact to express the result of expanding the left-hand member of (3.2.3)
with respect to the elements of the first column, and equating the result to zero,
in lagrangian form when n = 2.
5 Generalize the result of Prob. 4 to show that





a21
a a22 a1 a21 a1 a21
a22 = 2
+

a3 a23 a3 a23 a2 a22


n-l
a23
an




a2 a
a1- an-I)
= (az - al)(a3 - al)(a3 - aZ)(a4 - al)(a4 - aZ)(a4
- 2a3)'"
a2 (an
a1 a1 a1 a1 a1


=

+
a3 a3 from
a3(3.2.3)
a3 ain3 a2 a2 a2
3
and to derive the lagrangian form of the interpolationapolynomial

1

1

1

a1
a2
a3

the general case. (The determinant involved here=is often called Vandermonde's
determinant.)

a2 a3 a3 a2 a2 a3 a1 a3 a3 + a1 a1 a3 +
a1 a2 a2 a1 a1 a2 + a1 a2 a3 a1 a2 a3
=
a3 (a2 a3 a1 a3 + a1 a1 a1 a2 )+
a2 (a2 a3 + a1 a2 a1 a1 + a1 a3 )
(a3 a2 )(a2 (a3 a1 ) a1 (a3 a1 ))
(a3 a2 )(a2 a1 )(a3 a1 )


1

y 1
1

x0
x1
x2



1
x20

2
x1 f (x0 ) 1
1
x22






1 x x 2
1 x x 2
x2




x21 + f (x1 ) 1 x0 x20 f (x2 ) 1 x0 x20 = 0
1 x2 x22
1 x1 x21
x22

x0 x20
x1 x21 l0 (x)f (x0 ) + l1 (x)f (x1 ) l2 (x)f (x2 )
x2 x22

x
x1
x2


1

y 1
1

For l0 (x) = (x1 x)(x2 x1 )(x2 x)


l1 (x) = (x0 x)(x2 x0 )(x2 x)
l2 (x) = (x0 x)(x1 x0 )(x1 x)
Then

Math 481A
Assignment 1

Joshua Cook
September 26, 2014

y(x1 x0 )(x2 x1 )(x2 x0 ) = (x1 x)(x2 x1 )(x2 x)f (x0 )+


(x0 x)(x0 x2 )(x2 x)f (x1 )+
(x0 x)(x1 x0 )(x1 x)f (x2 )
(x1 x)(x2 x1 )(x2 x)
f (x0 )+
(x1 x0 )(x2 x1 )(x2 x0 )
(x0 x)(x0 x2 )(x2 x)
f (x1 )+
(x1 x0 )(x2 x1 )(x2 x0 )
(x0 x)(x1 x0 )(x1 x)
f (x2 )
(x1 x0 )(x2 x1 )(x2 x0 )
(x1 x)(x2 x)
(x0 x)(x2 x)
(x0 x)(x1 x)
y=
f (x0 )
f (x1 ) +
f (x2 )
(x1 x0 )(x2 x0 )
(x1 x0 )(x2 x0 )
(x2 x1 )(x2 x0 )
y=

Math 481A
Assignment 1

Joshua Cook
September 26, 2014
LAGRANGIAN MEmODS

3.6

117

6 By considering the limit of the three-point lagrangian interpolation formula


relative to xo, Xo + 8, and Xl> as 8 -> 0, obtain the formula
f(x)

(Xl - x)(x + Xl 2- 2xo) f(xo)


(Xl - xo)

+ (X

- XO}(XI Xl - Xo

X) f'(xo)

(X - xo): f(XI)
(Xl - Xo)

+ E(x)

where

7 Write down a determinantal equation analogous to (3.2.3) but corresponding to


the requirement that
f (x) = l0 f0 + l f + l1 f1 + E(x)
y(X) = A o
Al cos X + A 2 sin x

(x)
For Xli ==Xo, Xl> and X2.
agree with f(x) when
establish the identity
(x xi ) 0 (xThen
i)
0
sin
al
1 cos al
Where (x) = (xi x0 ) . . . (xi xn )
(Omitting (xi xi ))
1 cos a2 sin a2 = 4 sin t(a2 - al) sin t(a3 - al) sin t(a3 - a2)
(x x )(x x1 )
I cos a3 sin a3
l0 =
(x
0 inxthe
 )(x
0 x1 )form (due to Gauss):
and use this result to express y(x)
following
(x x0 )(x x1 )
=t(x - X2) f( )
() = sin t(x - Xl)lsin
yx
(x -X2,)
x0 )(x x1 )
sin texo - XI) sin t(xo
(x
) )
+ sin lt(x=- xo)
sinxt(x
-
X2)xf(x
0 )(x
1
sin t(XI
- (x
xo)
sinxt(XI
X2)x ) I
1
0 )(x-1
+ sinxtex
f(X2)
(x
)(x- xo)
x1sin
) tex - Xl)
(x
x0 )(x x1 )
(x x0 )(x x )
Then f (x) =
f +
f1 + E(x)
0 +- XI)
sin t(X2 - xo) sin f
t(X2
(x0 x )(x0 x1 )
(x x0 )(x x1 )
(x1 x0 )(x1 x )
Show also that the formula resulting from deleting the t's in the arguments of the
(x x )(x x1 )
(x x0 )(x x1 )
(x x0 )(x x )
sines (and due
to Hermite)
Then
f (x) = defines the approximation
f0 +
f +
f1 + E(x)
(x0 x1 )
(x x1 )
(x1 x0 )(x1 x )
y = A o + A I cos 2x + A 2 sin 2x
(x x )(x x1 )
(x x0 )(x x1 )
(x x0 )2
which agrees lim
withff(x)
(x) at
= the
limsame three points. Also
f0 predict
+ lim the form of the
f +
f1 + E(x)
0
x1 )when an approximation
(x of
the
x1 )
(x1 x0 )2
0
generalization0
of the Gauss0
formula(x
to the
case
form
(x x0 )(x x1 )
1
(x x0 )(x x1 )
1
(x x0 )2
=
f0 lim
+
lim f +
f1 + E(x)
y = A o + AI cos X + A 2 sin X (x
+ 0...
nx +
A 2n sin nx(x0 x1 )
0 
+x1A)2n - 1 cos0
(x1 x0 )2
is to agree withf(x) at the 2n
Xo,xXI'
verify
correctf0 and (x
xthe
x1 )
f
(x x0 )2
(x+Ixpoints
0 )(x
0 )(x
1 ) ... ' X2n,
lim
+
lim
+
f1 + E(x)
ness of this conjecture. =
0 
0 
(x0 x1 )
(x0 x1 )
(x1 x0 )2
(x x0 )(x x1 )
f f0
(x x0 )2
=
lim
+
f1 + E(x)
Section 3.3
0
(x0 x1 )

(x1 x0 )2
8 Prove that (3.3.20) is valid when
span R of the(xvalues
(x Xxis0outside
)(x xthe
x0Xo,
)2 . .. , Xn,
1) 0
(x0the
) +function
f1 + E(x)
by writing F(x) == f(x) - =y(x) - Kn(x), showingfthat
(x0 x1 )
(x1 x0 )2
F(r)(x) = j<r)(x) - yC')(x) - Kn(r)(x)

With error

E(x) =

1
1
f (n+1 ()(x) = (x x0 )2 (x x1 )f 000 ()
(n + 1)!
6

You might also like