4 Sol

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6
At a glance
Powered by AI
The document discusses various interpolation techniques like Newton divided difference interpolation and polynomial interpolation. It also discusses the method of least squares which is used to fit data to polynomials and curves. Hooke's law relates the force applied to a spring and its elongation which can be used to determine the spring constant.

The document discusses interpolation using Newton divided difference interpolation to construct polynomials of different degrees to approximate values. It also discusses polynomial interpolation on equally spaced nodes.

The method of least squares is used to fit data to polynomials and curves by minimizing the sum of squared residuals between the observed and modeled values. It involves setting up normal equations from the model and solving them to determine the coefficients.

Assignment 4

Interpolation and Approximations


1. Using Newton divided difference interpolation, construct interpolating polynomials of degree one, two, and
three for the following data. Approximate the specified value using each of the polynomials.
f (0.43) if f (0) = 1, f (0.25) = 1.64872, f (0.5) = 2.71828, f (0.75) = 4.4816.
Sol.
xi
0
0.25
0.5
0.75

f (xi )
1
1.64872
2.71828
4.4816

first d.d.
2.5949
4.2782
7.0533

second d.d.
3.3667
5.5501

third d.d.
2.9111

We would like to calculate f (0.43). The value x = 0.43 lies between 0.5 and 0.75. Therefore degree one
polynomial is
P1 (x) = f (0.5) + (x 0.5)f [0.5, 0.75] = 2.71828 + (x 0.5) 7.0533
P1 (0.43) = 2.71828 + (0.43 0.5) 7.0533 = 2.224549.
Similarly
P2 (0.43) = 1.64872 + (0.43 0.25) 4.2782 + (0.43 0.25)(0.43 0.5) 5.5501 = 2.34886474.
Also
P3 (x)

1 + (x 0) 2.5949 + (x)(x 0.25) 3.36672 + (x) (x 0.25) (x 0.5)2.9111

P3 (x)

1 + (0.43 0) 2.5949 + (0.43)(0.43 0.25) 3.36672 + (0.43) (0.43 0.25) (0.43 0.5)2.9111 = 2.3606.

2. Show that the polynomial interpolating the following data has degree 3.
x
f (x)

2
1

1
4

0
11

1
16

2
13

3
4

Sol.
x
1
2
0
1
2
3

f (x)
1
4
11
16
13
4

first d. d.
3
7
5
3
17
0

second d.d.
2
1
4
7

third d.d.
1
1
1

fourth d.d.
0
0

fifth d.d.
0

From the table it is clear that the interpolating polynomial has degree 3 as third differences are equal and
therefore remaining all differences of higher-order will be zero.
3. Let f (x) = ex , show that f [x0 , x1 , , xm ] > 0 for all values of m and all distinct equally spaced nodes
{x0 < x1 < < xm }.
Sol. As
f m ()
e
=
> 0.
f [x0 , x1 , , xm ] =
m!
m!
4. The following data are given for a polynomial P (x) of unknown degree
x
f (x)

0
4

1
9

2
15

3
18

Determine the coefficient of x3 in P (x) if all fourth-order forward differences are 1.


Sol.
x
0
1
2
3

f (x)
4
9
15
18

f (xi )
5
6
3

2 f (xi )
1
3

3 f (xi )
4

As all fourth-order forward differences are 1, therefore polynomial will have degree four. Newton interpolation
for equally spaced points is
Pn (x) = Pn (x0 + sh) = f (x0 ) +

n  
X
s
k=1

4k f (x0 ).

Here x0 = 0, h = 1, x = x0 + sh = s. We can write x for variable s.


P (x)

4+x5+

x(x 1)
x(x 1)(x 2)
x(x 1)(x 2)(x 3)
1+
(4) +
1.
2
6
24

From the above expression the coefficient of x3 is -11/12.


5. Suppose that f (x) = cos x to be approximated on [0, 1] by an interpolating polynomial on n + 1 equally
spaced points. What step size h ensure that linear interpolation gives an absolute error of at most 106 for
all x [0, 1].
Sol. This example is similar to Example 5 from Notes. We just need to replace the maxima of function
which is
M2

=
=

max |f 00 (x)|

0x1

max | cos x|= 1.

0x1

Thus
h2 /8

0.000001,

h 0.0028.
6. Let i0 , i1 , , in be a rearrangement of the integers 0, 1, , n. Show that
f [xi0 , xi1 , , xin ] = f [x0 , x1 , , xn ].
Sol. Let Let P (x) and Q(x) be two polynomials, such that P (x) interpolates f at {x0 , x1 , , xn } and Q(x)
interpolates f at {xi0 , xi1 , , xin }. Therefore
P (x) = f (x0 ) +

n
X

f [x0 , x1 , , xk ](x x0 ) (x xk1 )

k=0

= f [x0 , x1 , , xn ]xn + lower order terms


Q(x) = f (xi0 ) +

n
X

f [xi0 , , xik ](x xi0 ) (x xik1 )

k=0

= f [xi0 , xi1 , , xin ]xn + lower order terms


Since the polynomial interpolating the same nodes is unique, therefore
f [xi0 , xi1 , , xin ] = f [x0 , x1 , , xn ].

7. Let f (x) = 1/(1 + x) and let x0 = 0, x1 = 1, x2 = 2. Calculate the divided differences f [x0 , x1 ] and
f [x0 , x1 , x2 ]. Using these divided differences, give the quadratic polynomial P2 (x) that interpolates f (x) at
the given node points {x0 , x1 , x2 }. Graph the error f (x) P2 (x) on the interval [0, 2].
Sol.
x
0
1
2

f (x)
1
0.5
0.3333

first d.d.
f [x0 , x1 ] = 0.5
f [x1 , x2 ] 0.1667

second d.d.
f [x0 , x1 , x2 ] = 0.1667

From the table we obtain


P2 (x) = 1 0.5x + 0.1667(x)(x 1)
which is a second degree polynomial. Now
f (x) P2 (x) =

f 3 ()
x(x 1)(x 2).
3!

Calculate third derivative of f and make a plot.


8. Construct the interpolating polynomial that fits the following data using Newton forward and backward
x
f (x)

0
1.5

0.1
1.27

0.2
0.98

0.3
0.63

0.4
0.22

0.5
0.25

difference interpolation. Hence find the values of f (x) at x = 0.15 and 0.45.
Sol. Refer to Example 9 from Notes.
x
0
0.1
0.2
0.3
0.4
0.5

f (x)
1.5
1.27
0.98
0.63
0.22
0.25

f (xi )
0.23
0.29
0.35
0.41
0.47

2 f (xi )
0.06
0.06
0.06
0.06

3 f (xi )
0
0
0

4 f (xi )
0
0

5 f (xi )
0

Use forward difference interpolation to calculate the first value and use backward difference interpolation to
calculate the second value which lies near the end of table.
9. The following data are parts of a table for function f (x) =
x
f (x)

0.1
9.9833

0.2
4.9667

0.3
3.2836

sin x
.
x2
0.4
2.4339

0.5
1.9177

Calculate f 0.25) as accurately as possible


(a) by interpolating directly in this table, (b) by first calculating xf (x) and then interpolating directly in
that table, (c) explain the difference between the results obtained in (a) and (b), respectively.
Sol. Draw the table as for the previous example.
(a)
f (x0 ) = 5.0166,

2 f (x0 ) = 3.3335

3 f (x0 ) = 2.5001,

4 f (x0 ) = 2.002.

Interpolating polynomial gives


P (0.25) = 3.8645.

(b)
f (x0 ) = 0.00499,

2 f (x0 ) = 0.00327

3 f (x0 ) = 0.00001,

4 f (x0 ) = 0.00006.

Interpolating polynomial using these gives


P (0.25) = 3.958472.
(c) Since differences in (a) are oscillating and not decreasing fast, resulting error in interpolation would be
large. Since differences in (b) tends to become smaller in magnitude, we expect more accurate result in this
case.
10. A fourth-degree polynomial P (x) satisfies 4 P (0) = 24, 3 P (0) = 6, and 2 P (0) = 0, where P (x) =
P (x + 1) P (x). Compute 2 P (10).
Sol. If P (x) is a fourth-degree polynomial, it can be easily proved that P (x) is a third-degree polynomial.
Furthermore, we can prove that 2 P (x) is a second-degree polynomial. Let
Q(x) = 2 P (x) = ax2 + bx + c,
we have
3 P (x) = Q(x) = Q(x + 1) Q(x) = 2ax + a + b,
4 P (x) = (Q(x)) = 2a.
Using the given values, we obtain
c = 0,
a + b = 6,
2a = 24.
2

Therefore c = 0, b = 6, a = 12, and P (10) = Q(10) = 1140.


11. Use the method of least squares to fit the linear and quadratic polynomial to the following data.
x
f (x)

2
15

1
1

0
1

1
3

2
19

Sol. The normal equations for fitting a straight line y = a + bx are


5
X

f (xi )

5a + b

i=1
5
X

5
X

xi

i=1

xi f (xi )

i=1

5
X

xi + b

i=1

5
X

x2i .

i=1

After simplification we get as


a = 7.8,

b = 1,

The required approximation is y = 7.8 + x.


12. By the method of least square fit a curve of the form y = axb to the following data.
x
y

2
27.8

3
62.1

4
110

5
161

Sol. The curve y = axb takes the form Y = A + Bx after taking log, where Y = log y, A = log a. The normal
equations for fitting a straight line Y = A + bx are
4
X

Yi

4A + b

i=1
4
X

Xi Yi

4
X

Xi

i=1

i=1

4
X

Xi + b

i=1

4
X

Xi2 .

i=1

After simplification we get as


A = 1.9988 a = 0.6925,

b = 1.9302,

The required approximation is y = 0.6925 (x)1.9302 .

13. Use the method of least squares to fit a curve y = c0 /x + c1 x to the following data.
x
y

0.1
21

0.2
11

0.4
7

0.5
6

1
5

2
6

Sol. We obtain the normal equations


6
6
6
X
X
X
yi
1
1
+
c
= c0

1
2
x
x
xi
i
i=1
i=1
i=1 i
6
6
6
X
X
X

1
y i x i = c0
+
c
xi .

1
xi
i=1
i=1
i=1

Using given data, we obtain


c0 = 1.9733,

c1 = 3.2818.

Hence the required least square approximation is


y=

1.9733
+ 3.2878 x.
x

14. Hookes law states that when a force is applied to a spring constructed of uniform material, the length of
the spring is a linear function of that force written as
F (l) = k(l E).
The function F is the force required to stretch the spring l units, where the constant E = 5.3 is the length
of the unstretched spring in inches and k is the spring constant.
a. Suppose measurements are made of the length l, in inches, for applied weights F (l), in pounds, as given
in the following table.
F (l)
2
4
6

l
7.0
9.4
12.3

Find the least squares approximation for k.


b. Additional measurements are made, giving more data:
F (l)
3
5
8
10

l
8.3
11.3
14.4
15.9

Compute the new least squares approximation for k. Which of (a) or (b) best fits the total experimental
data?
Sol. (a) A linear function F (l) = k(l E) takes the form y = b x + a, where b = k, and a = kE
The normal equations for fitting a linear function y = a + bx are
3
X

yi

3a + b

i=1
3
X

xi yi

3
X

xi

i=1

i=1

3
X
i=1

xi + b

3
X

x2i .

i=1

After simplification we get as


b = 0.7525 k = 0.7525,

a = 3.1988, kE = 3.1988

The required approximation is


F (l) = 0.7525(l 5.3).
(b) As above.

You might also like