You are on page 1of 88

Computational Economics

Assignment

by

Uttam Gupta
(Roll no. 2010120936)

Submitted to

Dr. Niteesh Sahni


Department of Mathematics
School of Natural Sciences
Shiv Nadar University, Greater Noida (U.P.)
(Spring 2021)
(Python codes used in this Assignment)

Bisection Method: This code is used to plot the required continuous function in order to check

the existence of a root in the given interval.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Bisection Method: The following code would help you run the bisection method to find the

desired root in the given interval.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Fixed Point Method: This code is used to plot the required continuous and differentiable function
in order to check for the intersection with y = x line.

This code is used to plot the graph of the derivative of g(x) in order to check the range of the
derivative.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


This code is used to find the number of Iterations of the given function.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Newton – Raphson Method: This code is used to plot the required continuous and differentiable
function in order to check the existence of a root in the given interval.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


This code is used to plot the required continuous and differentiable function in order to check
that if f'(x) is equal to zero or not.

This code is used to plot the required continuous and differentiable function.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


This function plots the graph of the derivative of g(x) in order to check the range of the
derivative.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Lagrange Interpolation Method

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Program for Divided difference method

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


(ASSIGNMENT QUESTIONS)

Exercise 2.1 | Page 55 | Question 6

Use the Bisection method to find solutions, accurate to within 10−5 for the following
problems.

(A) 3𝑥 − 𝑒 𝑥 = 0 for 1 ≤ 𝑥 ≤ 2

(B) 2𝑥 + 3 𝑐𝑜𝑠𝑥 − 𝑒 𝑥 = 0 for 0 ≤ 𝑥 ≤ 1

(C) 𝑥 2 − 4𝑥 + 4 − 𝑙𝑛𝑥 = 0 for 1 ≤ 𝑥 ≤ 2 and 2 ≤ 𝑥 ≤ 4

Solution:

A ) Solution using Python:

3𝑥 − 𝑒 𝑥 = 0 for 1 ≤ 𝑥 ≤ 2

In this question, we have,

𝑛 ≥ log [ (𝑏 − 𝑎) 105 = log [ 105 ] ≈ 17


2 2

Now, according to the question if we consider the end points as a = 1 and b = 2 we

would require utmost 17 iterations to reach the desired root as asked in question.

Therefore, as we can see in the below graph and table, the desired root is 1.51213.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936
B ) Solution using Python:

2𝑥 + 3 𝑐𝑜𝑠𝑥 − 𝑒 𝑥 = 0 for 0 ≤ 𝑥 ≤ 1

Now, In this question If we consider the end points as a = 0 and b = 1, as we can see in

the graph below, there doesnot exist any real root between 0 and 1.

We can directly observe from the figure that the the curves doe sn’t intersect the x-axis.

Hence, there doesnot exist a c ∈[ 0 , 1 ] such that f(c) = 0.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


C ) Solution using Python:

𝑥 2 − 4𝑥 + 4 − 𝑙𝑛𝑥 = 0 for 1 ≤ 𝑥 ≤ 2 and 2 ≤ 𝑥 ≤ 4

Case 1: a = 1 and b = 2

𝑛 ≥ log [ (𝑏 − 𝑎) 105 = log [ 105 ] ≈ 17


2 2

For this question, if we consider a = 1 and b = 2, we would utmost 17 iterations to reach

the desired root, as shown in the graph and solution table below.

Therefore, the desired root is 1.41239

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Case 2: a = 2 and b = 4

𝑛 ≥ log [ (𝑏 − 𝑎) 105 = log [ 105 ] ≈ 18


2 2

Considering end points as a = 2 and b = 4, we would require utmost 18 iterations to

reach the desired root.

As shown in the graph and iteration table, after 18 iterations, th e desired root is 3.05710

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936
Exercise 2.1 | Page 55 | Question 15

Use Theorem 2.1 to find a bound for the number of iterations needed to achieve an

approximation with accuracy 10−4 to the solution of 𝑥 3 − 𝑥 − 1 = 0 lying in the interval [1, 2].

Find an approximation to the root with this degree of accuracy.

Solution:

As we know that,

𝑏−𝑎
| 𝑃𝑛 − 𝑃 | ≤ ≤ 10−4
2𝑛

Here, in this equation, we have a = 1 and b = 2,

After substituting the given values in the above mentioned equation, we get,

2−1
≤ 10−4
2𝑛

2𝑛 ≥ 104

𝑛 log(2) ≥ log (104 )

log(104 )
𝑛≥ ≈ 13.28
log(2)

Now, we are interested in finding the integer value for n, The least number satisfying

this inequality is 14. As 214 = 16384 and this is the least number to satisfy this

mentioned inequality.

Now, using python code, lets find the approximation to the root with the given level of

accuracy and verify that if it is consistent with the bound that we found above.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Refering to the below mentioned graph and Iteration Table, we can say that our desired

value of root is 1.32477

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.1 | Page 55 | Question 18

The function defined by 𝑓(𝑥) = sin 𝜋𝑥 has zeros at every integer. Show that when

-1 < a < 0 and 2 < b < 3. The bisection method converges to

A) 0, If a + b < 2

B) 2, If a + b > 2

C) 1, If a + b = 2

Solution:

Now, according to this given question, 𝑓(𝑥) = 𝑠𝑖𝑛𝜋𝑥 , This implies we have
𝑓(𝑎) < 0
𝑓(𝑏) > 0
This implies, Since we have −1 < 𝑎 < 0 𝑎𝑛𝑑 2 < 𝑏 < 3
1< 𝑎+𝑏 <3

Now, let us say that c be the root of the function 𝑓(𝑥) where c ∈ [a,b].

This implies, 𝑓(𝑐) = 10 for 𝑐 ∈ [𝑎, 𝑏].

Now, Solving the above found results using bisection method,

A) 0 If a + b < 2

1<𝑎+ 𝑏<3
This Implies, 1<𝑎+𝑏 <2

1 𝑎+𝑏
This Implies, < <1
2 2

𝑎+𝑏
𝑆𝑖𝑛 𝜋𝑥 < 𝑓 ( )<1
2

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑎+𝑏
This Implies, 0 < 𝑓( )<1
2

𝑎+𝑏
Now, we can say that there exist c ∈ [ a , ] such that 𝑓(𝑐) = 0
2

But, without the loss of generality, we know as given to us that


𝑎+𝑏
−1 < 𝑎 < 0 𝑎𝑛𝑑 0 < <1
2
Now, after considering these conditions, we have the only possible value for c is 0.

B) 2, If a + b > 2

As solved in the above part, here we can directly reach out to the mathematical part of
the question, as
1<𝑎+𝑏 <3
2<𝑎+𝑏 <3
𝑎+𝑏 3
This implies, 1< <2
2

3𝜋 𝑎+𝑏
This implies, sin <𝑓 ( ) < sin 𝜋
2 2

𝑎+𝑏
Hence, we can say that, −1 < 𝑓 ( )<0
2

𝑎+𝑏
Now, we can say that there exist c ∈ [ , 𝑏] such that 𝑓(𝑐) = 0
2

But, without the loss of generality, we know as given to us that


𝑎+𝑏 3
2 < 𝑏 < 3 𝑎𝑛𝑑 1 < <
2 2

Now, after considering these conditions, we have the only possible value for c is 2.

C) 1, if a + b = 2

In this part, as we already know from before,

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑎+𝑏 2
We can directly say that =2=1
2

𝑎+𝑏
This implies that =1
2

𝑏
Now, Since the 𝑓 (𝑎 + 2) = 𝑓(1) = sin 𝜋 = 0

This brings us to the conclusion that we already arrived at the rood. This implies that

the root is 1.

Exercise 2.1 | Page 55 | Question 19

A trough of length L has a cross section in the shape of a semi -circle with radius r. (As

shown in the figure). When filled with water to within a distance h to the top, the

volume V of the water is given as


𝑉 = 𝐿 [ 0.5 𝜋 𝑟 2 − 𝑟 2 𝑎𝑟𝑐 sin( 𝑟 ) − ℎ(𝑟 2 − ℎ2 )1/2]

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Solution:

As we know and given in the question, we can say that

L = 10 , r = 1 , V = 12.4 cubic ft.

Now we want to calculate the depth of water (h) in the trough to within 0.01 ft.

According to question, substituting the given values in the equation, we have

1
12.4 = 10 [ 0.5 𝜋 − 𝑎𝑟𝑐 sin(ℎ) − ℎ ( 1 − ℎ2 )2 ]

12.4 1
= 0.5 𝜋 − 𝑎𝑟𝑐 sin(ℎ) − ℎ (1 − ℎ2 )2
10

1.24 = 0.5 (3.14) − 𝑎𝑟𝑐 sin(ℎ) − ℎ ( 1 − ℎ2 )1/2

1.24 = 1.57 − 𝑎𝑟𝑐 sin(ℎ) − ℎ ( 1 − ℎ2 )1/2

1
𝑎𝑟𝑐 sin(ℎ) + ℎ(1 − ℎ2 )2 = 1.57 − 1.24

1
𝑎𝑟𝑐 sin(ℎ) + ℎ(1 − ℎ2 )2 = 0.3308

1
𝑎𝑟𝑐 sin(ℎ) = 0.3308 − ℎ(1 − ℎ2 )2

1
sin ( 𝑎𝑟𝑐 sin(ℎ)) = 𝑠𝑖𝑛 ( 0.3308 − ℎ(1 − ℎ2 )2 )

1
ℎ = 𝑠𝑖𝑛 ( 0.3308 − ℎ(1 − ℎ2 )2 )

1
ℎ − 𝑠𝑖𝑛 ( 0.3308 − ℎ(1 − ℎ2 )2 ) = 0

1
Now, let us assume that 𝑓(ℎ) = ℎ − 𝑠𝑖𝑛 ( 0.3308 − ℎ(1 − ℎ2 )2 )

Now, this can be solved using bisection method with the following values,

a = 0 and b = 1, for the tolerance level as follows 0 ≤ ℎ ≤ 𝑟 = 1

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


With the following graph and iteration result, we can say that the depth of water trough

h is 0.16406 at the tolerance level of 0.01.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.1 | Page 55 | Question 20

A particle starts at rest on a smooth inclined plane whose angle θ is changing at a

constant rate
𝑑𝜃
=𝜔<0
𝑑𝑡

At the end of t seconds, the position of the object is given by

𝑔 𝑒 𝜔𝑡 − 𝑒 −𝜔𝑡
𝑥(𝑡) = − 2 ( − sin 𝜔𝑡 )
2𝜔 2

Suppose the particle has moved 1.7ft in 1 second. Find, to within 10−5 , the rate 𝜔 at

which θ changes. Assume that g= 32.17 𝑓𝑡/𝑠 2 .

Solution:

As given in question, 𝑥(1) = 1.7 𝑓𝑡 𝑎𝑛𝑑 𝑔 = 32.17 𝑓𝑡/𝑠 2 . Now we need to find the rate

𝜔 at which 𝜃 changes within the tolerance level 10−5 .

Now substituting the values given to us in the position determining equation, we hav e,

𝑔 𝑒 𝜔 − 𝑒 −𝜔
𝑥(1) = − ( − sin 𝜔 )
2𝜔 2 2

32.17 𝑒 𝜔 − 𝑒 −𝜔
1.7 = − ( − sin 𝜔 )
2𝜔 2 2

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Rearranging,
32.17 𝑒 𝜔 − 𝑒 −𝜔
1.7 + ( − sin 𝜔 ) = 0
2𝜔 2 2

Now let us assume that,

32.17 𝑒 𝜔 − 𝑒 −𝜔
𝑓 ( 𝜔 ) = 1.7 + ( − sin 𝜔 )
2𝜔 2 2

Now using the python code as mentioned above to solve the following equation using

bisection method to approximate the value of 𝜔 at tolerance level 10−5. Now we must

figure out the values of a and b. The graph of the above-mentioned equation for some

values of 𝜔 is as follows:

Now from the graph below, we can clearly see that the function touches the x -axis

between -2 and 1. So now we can assume the values accordingly. Let the value be a = -2

and b = 1.

Hence as shown in the iteration table, we can say that the rate 𝜔 at which θ changes is

-0.31706 at a tolerance level of 10−5 .

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936
Exercise 2.2 | Page 66 | Question 18 (b)

Show that theorem 2.3 may not hold if inequality | 𝑔′(𝑥)| ≤ 𝑘 is replaced by 𝑔′(𝑥) ≤ 𝑘.

Hint: Show that 𝑔(𝑥) = 1 − 𝑥 2 , for 𝑥 ∈ [ 0,1 ], provides a counterexample.

Solution:

According to question and the conditions given to us, we can say that

𝑔(𝑥) = 1 − 𝑥 2 is continuous on [0,1] with g(x) ∈ [0,1], for all x ∈ [a,b]. Also,

𝑔′ (𝑥) = −2𝑥 ≤ 𝑘 ≤ 1, 𝑥 ∈ [0,1]

Now, it can be clearly stated that for any k ∈ (0,1) we have 𝑔′ (𝑥) ∈ [−2,0] for

x ∈ [0,1]. Now we can replace |𝑔′ (𝑥)| ≤ 𝑘 with 𝑔′(𝑥) ≤ 𝑘 and the function will

satisfy conditions of theorem 2.3. This implies, for any number p 0 ∈[0,1] , the

given sequence p n = g (p n-1 )= 1 - (p n-1 ) 2 should converge to a unique fixed point

p∈[0,1]. Now for p 0 =1, we get,

p 1 = g(p 0 ) = g(1) = 1 – 1 2 = 0

p 2 = g(p 1 ) = g(0) = 1 – 0 2 = 1

Therefore,

Our result shows that our sequence is alternating between 0 & 1 for all 𝑘 ≥ 1,

Hence, we can say that p 2k = 1 and p 2k-1 = 0

Now we can conclude that the theorem does not hold for this function.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.2 | Page 66 | Question 21

Replace the assumption in Theorem 2.4 that “a positive number k < 1 exists with |g’(x)| ≤ k|

with “g satisfies a Lipschitz condition on the interval [a, b] with Lipschitz constant L < 1.”

(See Exercise 27, Section 1.1.) Show that the conclusions of this theorem are still valid.

Solution:

In the given question, let’s suppose that, g ∈ C[a, b] satisfy the altered conditions of theorem 2.4.

That is, g(x) ∈ [a, b], ∀x ∈ [a, b] and ∃ a positive constant L < 1 s.t

|g(x) − g(y)| ≤ L |x − y|, ∀x, y ∈ [a, b]

Now, we require to show that for any p0 ∈ [a, b], the sequence pn = g(pn-1), n ≥ 1 and converges

to the unique fixed-point p of g ∈ [a, b].

Now, first of all, we have to show that g has exactly one fixed point in [a, b]. As we know that, g

satisfies the hypotheses of (i) in theorem 2.3, we can say that g has at least one fixed point in

[a,b]. Now, furthermore assuming that there are two different fixed points,

p = g(p) and q = g(p) such that p ≠ g(p).

This implies, |p − q| = |g(p) − g(q)| ≤ L |p − q| < |p − q|

This is clearly a contradiction. Hence we can conclude that there cannot be two fixed points,

which implies that both p and q are same and the fixed point p = g(p) is unique.

Hence, for proof of theorem 2.4, we conclude that the sequence {pn}n≥0 is defined and pn ∈ [a, b]

since g : [a, b] → [a, b]. The Lipschitz condition yields that,

|pn − p| = |g(pn-1) − g(p)| ≤ L|pn-1 − p|

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now by induction, the hypothesis follows that,

|pn − p| ≤ L |pn-1 − p| ≤ L2 |pn-2 − p| ≤ · · · ≤ Ln |p0 − p|

As the proof of the theorem concludes that 0 < L < 1 implies that,

lim |pn − p| ≤ lim |pn − p|


𝑛→∞ 𝑛→∞

lim |pn − p| ≤ lim Ln |p0 − p| = |p0 − p| lim Ln = |p0 − p| × 0 = 0


𝑛→∞ 𝑛→∞ 𝑛→∞

Hence, pn → p as n → ∞.

Exercise 2.2 | Page 66 | Question 22

Suppose that g is continuously differentiable on some interval (c, d) that contains the fixed-point

p of g. Show that if |g′(p)| < 1, then there exists a δ > 0 such that if | p0 − p| ≤ δ, then the fixed-

point iteration converges.

Solution:

In this question,

for g ∈ C1 [a, b], ∃p ∈ [c, d] s.t g(p) = p and |g′(p)| < 1.

Now let us assume that k = |g′(p)| with 0 < k < 1.

As we know that g′(x) is continuous, hence, by definition for any ε > 0 ∃δ > 0 such that,

∀x ∈ (p − δ, p + δ)

We have, |g′(x) − g′ (p)| < ε

1−𝑘
Now when ε = (∵ k < 1 and ε > 0),
2

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


we have, δ1 ∀x ∈ (p − δ1, p + δ1) s.t,

|g′(x) − g′(p)| < ε

|g′(x)| < | g′(p)| + ε

1−𝑘 1+𝑘
|g′(x)| < k + =
2 2

1+𝑘
Now let us consider that 𝑙 = and as we know that 0 < k < 1, we also get 0 < 𝑙 < 1 and
2

|g′(x)| ≤ 𝑙 ∀x ∈ (p – δ1, p + δ1).

Let’s now assume that δ = δ1/2 and lets us now see the function g defined on [p − δ, p + δ].

Since MVT yields a value ξ ∈ [p − δ, p + δ],

we get g to be continuous and g(x) ∈ [p − δ, p + δ] s.t.

|𝑔(𝑥) − 𝑔(𝑝)| = |𝑔′(ξ)| |x − p| ≤ 𝑙 · δ ≤ δ

Now, as we have g(p) = p, we can say the following,

|g(x) − p| < δ ⇒ g(x) ∈ [p − δ, p + δ]

Now, from above we can say that g is continuous on the interval [p − δ, p + δ] and maps that

interval into itself, its derivative exists and satisfies the condition that 0 < l < 1 s.t

g′(x) ≤ k ∀x ∈ [p − δ, p + δ].

All assumptions of theorem 2.4 are satisfied, and that implies that for any p0 ∈ [p − δ, p + δ] we

have the sequence


pn = g(pn-1) → p.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.2 | Page 66 | Question 24

Let g ∈ C1 [a, b] and p be in (a, b) with g(p) = p and |g′(p)| > 1|. Show that there exists a δ > 0

such that if 0 < |p0 − p| < δ, then |p0 − p| < |p1 − p| . Thus, no matter how close the initial

approximation p0 is to p, the next iterate p1 is farther away, so the fixed-point iteration does not

converge if p0 ≠ p

Solution:

Initially, |g′(x)| > 1 for any value of x ∈ [a, b] close to the fixed-point p.

As we know that g ∈ C1[a, b] and g′ is continuous in [a, b]

⇒ g′ is continuous at p, as p ∈ (a, b)

Thus, for every ε > 0, ∃ δ > 0 s.t

If, 0 < |x − p| < δ ⇒ |g′(x) - g′(𝑝) | < ε

Hence, We can say that,

|g′(x)| = |g′(x)| + |g′(p)| − |g′(p)|

= |g′ (p)| − (|g′(p)| − |g′(x)|)

≥ |g′(p)| − |g′ (p)| − |g′ (x)|

> |g′(p)| − ε

Now, let ε = |𝑔′ (𝑝)| − 1 > 0

This implies, |𝑔′ (𝑥)| > 1

Whenever, 0 < |x − p| < δ

Now let p0 be the first iteration s.t 0 < |p0 − p| < δ and

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


1 = g(p0) be the next iteration.

Now apply MVT, so that we achieve the following,

| p1 – p | = | g(p0) − g(p) | = | g′(ξ) | | p0 – p |

for some ξ between p and p0.

Now Since |ξ − p| < δ,

we have |g′(ξ)| > 1 and so |p0 − p| < |p1 − p|

Therefore, we have p ≠ p0,

Hence, the fixed-point iteration method doesn’t converge.

Exercise 2.3 | Page 75 | Question 5

Use Newton’s method to find solutions accurate to within 10−4 for the following

problems.

a. x3 − 2x2 − 5 = 0, [1, 4]

b. x3 + 3x2 − 1 = 0, [−3, −2]

c. x − cos x = 0, [0, π/2]

d. x − 0.8 − 0.2 sin x = 0, [0, π/2]

Solution:

A) x3 − 2x2 − 5 = 0, [1, 4]

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we know that f(x) is a polynomial function. It is also continuous and differentiable.

Now, we need to check if f′(x) is equating to zero or not.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, as we can observe from the above graph that f′(x) = 0 for some value of x between

1 and 1.5. Now for our calculations, Let’s consider that f(x) is defined for the values of

x between 1.5 ≤ x ≤ 4

We now construct a function g(x) such that,

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

𝑥 3 −2𝑥 2 −5
This implies, 𝑔(𝑥) = 𝑥 − 3𝑥 2 −4𝑥

As we have observed that |g(x)| < k for 0 < k < 1 is for the case when our x is somewhere

between 1.6 to 4 (approximately),

Now, Iterating using Newton’s method, with initial value of x0 = 1.6.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see in the below Iteration Table, the desired root is 2.6907

B) x3 + 3x2 − 1 = 0, x ∈ [−3, −2]

As we know that, f(x) is a polynomial function, then it is also continuous and differentiable.

Now we need to check that if f′(x) is equal to zero.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) ≤ 0 for all x between −3 and 2.

Since, it is clearly visible that the root lies strictly between −3 and −2 and if we initiate from −3,

then we will not reach −2 (If we would have reached −2, then g(x) would not have defined at

x = −2 as f′(−2) = 0). Hence, we can proceed with this.

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

𝑥 3 + 3𝑥 2 − 1
𝑔(𝑥) = 𝑥 −
3𝑥 2 − 6𝑥

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between −3 to −2.2

(approximately). Now we can start the iteration process with initial value of x0 = −3.

Now, from the iteration below, we can say that the desired root is -2.8794.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


C) x − cos x = 0, [0, π/2]

As we have our function f(x) differentiable and continuous. Now, we need to check if

f′(x) is equating to zero. Now, we have

𝜋
𝑓 ′ (𝑥) = 1 + 𝑠𝑖𝑛𝑥 , 𝑥 ∈ [0, ]
2

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝜋
Now, we can observe that f′(x) ≤ 0 for all x between 0 and 2 .

𝜋
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 0 , 2 ].

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

𝑥 − cos 𝑥
𝑔(𝑥) = 𝑥 −
1 + 𝑠𝑖𝑛𝑥

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 0.5 to 1.6

(approximately). Now we can start the iteration process with initial value of x0 = 0.5

Now, from the iteration below, we can say that the desired root is -0.7391

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


D) x − 0.8 − 0.2 sin x = 0, x ∈ [0, π/2]

As we have our function f(x) to be a polynomial function, which is continuous and

differentiable. Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝜋
Now, we can observe that f′(x) > 0 for all x between 0 and 2 .

𝜋
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 0 , 2 ].

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

𝑥 − 0.8 − 0.2 𝑠𝑖𝑛𝑥


𝑔(𝑥) = 𝑥 −
1 − 0.2𝑐𝑜𝑠𝑥

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 0.8 to 1.2

(approximately). Now we can start the iteration process with initial value of x0 = 0.8

Now, from the iteration below, we can say that the desired root is 0. 9643

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.3 | Page 75 | Question 6

Use Newton’s method to find solutions accurate to within 10−5 for the following

problems.

a. ex + 2-x + 2 cos x - 6 = 0, 1≤𝑥≤2

c. 2x cos 2x – (x-2)2 = 0, 2 ≤ 𝑥 ≤ 3 𝑎𝑛𝑑 3 ≤ 𝑥 ≤ 4

f. sin x – e-x = 0, 0 ≤ 𝑥 ≤ 1 𝑎𝑛𝑑 3 ≤ 𝑥 ≤ 4 𝑎𝑛𝑑 6 ≤ 𝑥 ≤ 7

Solution:

A) ex + 2-x + 2 cos x - 6 = 0, 1≤𝑥≤2

As we have our function f(x) to be a polynomial function, which is continuous and

differentiable. Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) > 0 for all x between 1 and 2.

Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 1 , 2].

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

𝑒 𝑥 + 2−𝑥 + 2𝑐𝑜𝑠𝑥 − 6
𝑔(𝑥) = 𝑥 −
𝑒 𝑥 − 2−𝑥 log 2 − 2𝑠𝑖𝑛𝑥

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 1.6 to 2

(approximately). Now we can start the iteration process with initial value of x0 = 1.6

Now, from the iteration below, we can say that the desired root is 1.82938

C) 2x cos 2x – (x-2)2 = 0, 2 ≤ 𝑥 ≤ 3 𝑎𝑛𝑑 3 ≤ 𝑥 ≤ 4

Case i) 2≤𝑥≤3

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we have our function f(x) to be a differentiable function, which is continuous.

Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) > 0 for all x between 2 and 3.

Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 2 , 3].

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

2𝑥 cos 2𝑥 − (𝑥 − 2)2
𝑔(𝑥) = 𝑥 −
2 [cos 2𝑥 − 𝑥(2 sin 𝑥 + 1) + 2]

As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 2.2 to 2.7

(approximately). Now we can start the iteration process with initial value of x0 = 2.2

Now, from the iteration below, we can say that the desired root is 2. 37069

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Case ii) 3≤𝑥≤4

As we have our function f(x) to be a differentiable function, which is continuous.

Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) > 0 for some value of x before 3.2.

Now, from the above results, we cannot consider any x for which f′(x) = 0, because if so

happens, then g(x) will not be defined.

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

2𝑥 cos 2𝑥 − (𝑥 − 2)2
𝑔(𝑥) = 𝑥 −
2 [cos 2𝑥 − 𝑥(2 sin 𝑥 + 1) + 2]

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x is more than 3.3

(approximately). Now we can start the iteration process with initial value of x0 = 3.3

Now, from the iteration below, we can say that the desired root is 3.72211

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


F) sin x – e -x = 0, 0 ≤ 𝑥 ≤ 1 𝑎𝑛𝑑 3 ≤ 𝑥 ≤ 4 and 6 ≤ 𝑥 ≤ 7

Case i) 0≤𝑥≤1

As we have our function f(x) to be a differentiable function, which is continuous.

Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) > 0 for all x between 0 and 1.

Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 0 , 1].

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

sin 𝑥 − 𝑒 −𝑥
𝑔(𝑥) = 𝑥 −
cos 𝑥 + 𝑒 −𝑥

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 0.4 to 0.8

(approximately). Now we can start the iteration process with initial value of x0 = 0.4

Now, from the iteration below, we can say that the desired root is 0.58853

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Case ii) 3≤𝑥≤4

As we have our function f(x) to be a differentiable function, which is continuous.

Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) > 0 for all x between 3 and 4.

Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 3 , 4].

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

sin 𝑥 − 𝑒 −𝑥
𝑔(𝑥) = 𝑥 −
cos 𝑥 + 𝑒 −𝑥

As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 3 to 3.5

(approximately). Now we can start the iteration process with initial value of x0 = 3

Now, from the iteration below, we can say that the desired root is 3.0963 6

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Case iii) 6 ≤ 𝑥 ≤ 7

As we have our function f(x) to be a differentiable function, which is continuous.

Now, we need to check if f′(x) is equating to zero. Now, we have

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, we can observe that f′(x) > 0 for all the values of x.

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

sin 𝑥 − 𝑒 −𝑥
𝑔(𝑥) = 𝑥 −
cos 𝑥 + 𝑒 −𝑥

As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 6 to 6.5

(approximately). Now we can start the iteration process with initial value of x0 = 6

Now, from the iteration below, we can say that the desired root is 6.28505

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.3 | Page 75 | Question 13

Use Newton’s method to approximate to within 10-4, the value of x that produces the point on the

graph of y = x2 that is closest to (1, 0). [Hint: Minimize [d(x)]2, where d(x) represents the

distance from (x, x2) to (1, 0].

Solution:

Let A(x, x2) be a point on the graph and B(1, 0) be the given point.

Now, we can define f(x) as the square of the distance from A to B.

i.e, f(x) = d(A, B))2

= (1 − x) 2 + (0 − x) 2

= x4 + x2 − 2x + 1

Now, Minimizing the function implies,

f′(x) = 4x3 + 2x − 2 = 0

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we have our function f(x) to be a differentiable function, which is continuou s.

Now, we need to check if f′(x) is equating to zero. Now, we have

Now, we can observe that f′(x) = 0 for some of the values of x.

Now, let’s continue further without considering all those values of x, for which f′(x) = 0

Now, Constructing the function g(x) such that

𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)

4𝑥 3 + 2𝑥 − 2
𝑔(𝑥) = 𝑥 −
12𝑥 2 + 𝑥

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


As we can see from the graph above that |g(x)| < k for 0 < k < 1, when x lies between 0.25 to 2

(approximately). Now we can start the iteration process with initial value of x0 = 0.25

Now, from the iteration below, we can say that, x = 0.5898.

This implies, y = x2 = (0.5898) 2 = 0.3479

Hence, we can say that the required coordinates are:

𝐴(𝑥, 𝑦) = 𝐴 (0.5898 , 0.3479)

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.4 | Page 86 | Question 8

𝑛
8. (a) Show that the sequence pn = 10−2 converges quadratically to 0.

𝑘
(b) Show that the sequence pn = 10−𝑛 does not converge to 0 quadratically, regardless

of the size of the exponent k > 1.

Solution:

A)

Referring to definition 2.7 of the textbook, if we need to prove that a sequence

converges quadratically, we will have to determine the limits as given in the definition

with α = 2. This implies,

|𝑝𝑛+1 − 𝑝|
lim
𝑛→∞ |𝑝𝑛 − 𝑝|2

𝑛+1
|10−2 − 0 |
= lim
𝑛→∞ |10−2𝑛 − 0|2

𝑛+1
|10−2 |
= lim
𝑛→∞ |10−2𝑛 |2

𝑛
|10−2 ∗2 |
= lim 𝑛
𝑛→∞ |10−2 ∗2 |

=1

This implies, the parameter λ = 1 > 0,

This implies that the sequence converges quadratically.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


B)

We need to suppose that ∃ k > 1 such that the given sequence converges to 0 quadratically.

Hence, by definition, we need to find the limit with α = 2 and λ > 0.

This implies that, we can say,

|𝑝𝑛+1 − 𝑝|
lim
𝑛→∞ |𝑝𝑛 − 𝑝|2

𝑘
|10−(𝑛+1) − 0 |
= lim 𝑘
𝑛→∞ |10−𝑛 − 0 |2

𝑘
|10−(𝑛+1) |
= lim 𝑘 𝑘
𝑛→∞ 10−𝑛 . 10−𝑛

𝑘
1 |10−(𝑛+1) |
= lim 𝑘 𝑘
𝑛→∞ 10−𝑛 10−𝑛

𝑘
|10−(𝑛+1) |
Now, As we can see that, as 𝑛 → ∞ then 𝑘 → 1. This implies that,
10−𝑛

1
lim 𝑘
𝑛→∞ 10−𝑛

𝑘
10𝑛
= lim
𝑛→∞ 1

= ∞

But this result contradicts the fact that ∃ a limit λ.

Hence, the assumption that the sequence converges quadratically was false.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 2.4 | Page 86 | Question 9

(a) Construct a sequence that converges to 0 of order 3.

(b) Suppose α > 1. Construct a sequence that converges to 0 zero of order α.

Solution:

A)

𝑛
We need to define a sequence pn = 10−3 , for n ≥ 0.

Here the limit of the sequence is 0, but now check its convergence when α = 3 by definition 2.7.

|𝑝𝑛+1 − 𝑝|
lim
𝑛→∞ |𝑝𝑛 − 𝑝|3

𝑛+1
|10−3 − 0 |
= lim
𝑛→∞ |10−3𝑛 − 0|3

𝑛+1
|10−3 |
= lim
𝑛→∞ |10−3𝑛 |3

𝑛
|10−3 ∗3 |
= lim 𝑛
𝑛→∞ |10−3 ∗3 |

= 1

This implies, the parameter λ = 1 > 0, when α = 3,

This implies that the sequence converges with order 3.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


B)

𝑛
We need to define a sequence pn = 10−𝛼 , for n ≥ 0.

Here the limit of the sequence is 0, but now check its convergence when order is α

(by definition 2.7)

|𝑝𝑛+1 − 𝑝|
lim
𝑛→∞ |𝑝𝑛 − 𝑝|𝛼

𝑛+1
|10−𝛼 −0|
= lim −𝛼 𝑛
𝑛→∞ |10 − 0|𝛼

𝑛+1
|10−𝛼 |
= lim
𝑛→∞ |10−𝛼𝑛 |𝛼

𝑛
|10−𝛼 ∗𝛼 |
= lim 𝑛
𝑛→∞ |10−𝛼 ∗𝛼 |

= 1

This implies, the parameter λ = 1 > 0, when the order is α.

This implies that the sequence converges with order 𝛼 .

Exercise 2.4 | Page 86 | Question 13

The iterative method to solve f(x)=0, given by the fixed-point method g(x)=x, where

2
𝑓(𝑝𝑛−1 ) 𝑓 ′′(𝑝𝑛−1 ) 𝑓(𝑝𝑛−1 )
𝑝𝑛 = 𝑔(𝑝𝑛−1 ) = 𝑝𝑛−1 − ′ − ′ [ ] 𝑓𝑜𝑟 𝑛 = 1,2,3 …
𝑓 (𝑝𝑛−1 ) 2𝑓 (𝑝𝑛−1 ) 𝑓 ′ (𝑝𝑛−1 )

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


has g(p) = g(p) = 0. This will generally yield cubic (α = 3) convergence. Expand the analysis of

Example 1 to compare quadratic and cubic convergence.

Solution:

Reference of example 1: Let 𝑓(𝑥) = 𝑒 𝑥 − 𝑥 − 1.

a) Show that 𝑓 has a zero of multiplicity 2 at x=0.

b) Show that Newton’s method with p 0 =1 converges to this zero but not
quadratically.

For the data provided, to expand the analysis of the example to compare cubic and

quadratic convergence.


By definition of the order of convergence, suppose {𝑝𝑛 } 𝑛=0 is a sequence that converges

to p, with p n ≠ p, for all n.

|𝑝𝑛+1 −𝑝|
If positive constants are α, λ exists with lim ( |𝑝𝑛 −𝑝|α
) = λ , then,
𝑛→∞


{𝑝𝑛 } 𝑛=0 converges to p of order α with asymptotic error constant λ.

We know that, by definition,

When α = 2, it is known as quadratic convergence.

When α = 3, it is known as cubic convergence.

|𝑝𝑛+1 −𝑝|
Now we can say that |𝑝𝑛 −𝑝|3
= 0.75 and |𝑝0 − 𝑝| = 0.5
In this case, or cubic convergence, α = 3

|𝑝𝑛+1 −𝑝|
|𝑝𝑛 −𝑝|3
= 0.75 and |𝑝0 − 𝑝| = 0.5

𝑛 −1)/2 3𝑛
|𝑝𝑛 − 𝑝|= (0.75)(3 |𝑝0 − 𝑝|

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Now, if suppose, ||𝑝𝑛 − 𝑝| ≤ 10−8 , 𝑡ℎ𝑒𝑛 𝑡ℎ𝑖𝑠 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛 𝑖𝑠 𝑝𝑜𝑠𝑠𝑖𝑏𝑙𝑒 𝑜𝑛𝑙𝑦 𝑤ℎ𝑒𝑛 𝑛 ≥ 3.

Thus, this gives the comparison of the convergences.

Thus the required result is found.

Exercise 3.2 | Page 124 | Question 6

Neville’s method is used to approximate f(0.5), giving the following table

----------------------------------------------------------------------
𝑥0 = 0 𝑃0 = 0
𝑥1 = 0.4 𝑃1 = 2.8 𝑃0,1 = 3.5
𝑥1 = 0.7 𝑃1 = 2.8 𝑃0,1 = 3.5
27
𝑥1 = 0.7 𝑃1 𝑃0,1 𝑃0,1,2 =
7
----------------------------------------------------------------------

Determine 𝑃2 = 𝑓(0.7)

Solution:

Given that the above are approximated values of f(0.5) using Neville’s method.

Now we can say that,

(𝑥 − 𝑥2 ) 𝑃0,1 (𝑥) − (𝑥 − 𝑥0 ) 𝑃1,2 (𝑥)


𝑃0,1,2 (𝑥) =
𝑥0 − 𝑥2

Substituting values, we have,

(0.5 − 0.7) 𝑃0,1 (0.5) − (0.5 − 0) 𝑃1,2 (0.5)


𝑃0,1,2 (0.5) =
0 − 0.7

This implies,

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


27 (−0.2) 3.5 − (0.5) 𝑃1,2 (0.5)
=
7 −0.7

On simplification and cross multiplication,

27 7 (−0.2) 3.5 − (0.5) 𝑃1,2 (0.5)


( )(− ) =
7 10 1

This implies,

(0.5) 𝑃1,2 (0.5) = −0.7 + 2.7

2
𝑃1,2 (0.5) =
0.5

This implies,

𝑃1,2 (0.5) = 4

Now, to find the value of 𝑃2 = 𝑓(0.7), we can say that

(𝑥2 − 𝑥1 ) 𝑃1,2 (𝑥) + (𝑥 − 𝑥2 ) 𝑃1 (𝑥)


𝑃2 (𝑥) =
𝑥 − 𝑥1

0.3 (4) − (0.2)(2.8)


𝑃2 (0.5) =
0.5 − 0.4

1.2 − (0.56)
𝑃2 (0.5) =
0.1

0.64
𝑃2 (0.5) =
0.1

𝑃2 (0.5) = 6.4

Hence, we calculated that 𝑃2 (0.5) = 6.4

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 3.2 | Page 124 | Question 7

Suppose 𝑥𝑗 = 𝑗, for 𝑗 = 0,1,2,3 and it is known that,

𝑃0,1 (𝑥) = 2𝑥 + 1, 𝑃0,2 (𝑥) = 𝑥 + 1

We need to find 𝑃0,1,2,3 (2.5).

Solution:

As we know that,

(𝑥 − 𝑥0 ) 𝑃1,2 (𝑥) − (𝑥 − 𝑥2 ) 𝑃0,1 (𝑥)


𝑃0,1,2 (𝑥) =
𝑥2 − 𝑥0

(2.5 − 0) 𝑃1,2 (2.5) − (2.5 − 2) 𝑃0,1 (2.5)


𝑃0,1,2 (𝑥) =
2−0

(2.5) 𝑃1,2 (2.5) − (0.5) 𝑃0,1 (2.5)


𝑃0,1,2 (𝑥) =
2

𝑃0,1,2 (𝑥) = 2.875

Also, we have

(𝑥 − 𝑥0 ) 𝑃1,2,3 (𝑥) − (𝑥 − 𝑥3 ) 𝑃0,1,2 (𝑥)


𝑃0,1,2,3 (𝑥) =
𝑥3 − 𝑥0

(2.5 − 0) 𝑃1,2,3 (2.5) − (2.5 − 3) 𝑃0,1,2 (𝑥)


𝑃0,1,2,3 (𝑥) =
3−0

(2.5) 𝑃1,2,3 (2.5) + (0.5) 𝑃0,1,2 (2.5)


𝑃0,1,2,3 (𝑥) =
3

(7.5) + (0.5) 𝑃0,1,2 (2.5)


𝑃0,1,2,3 (𝑥) =
3

(7.5) + (0.5)2.875
𝑃0,1,2,3 (𝑥) =
3

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑃0,1,2,3 (𝑥) = 2.97917

Hence, we calculated that the value of 𝑃0,1,2,3 (𝑥) 𝑖𝑠 2.97917

Exercise 3.2 | Page 124 | Question 8

Suppose xj = j, for j = 0, 1, 2, 3 and it is known that

𝑃0,1 (𝑥) = 𝑥 + 1 , 𝑃1,2 (𝑥) = 3𝑥 − 1

Find 𝑃0,1,2,3 (1.5).

Solution:

(𝑥 − 𝑥1 ) 𝑃2,3 (𝑥) − (𝑥 − 𝑥3 ) 𝑃1,2 (𝑥)


𝑃1,2,3 (𝑥) =
𝑥3 − 𝑥1

(𝑥 − 1) 𝑃2,3 (𝑥) − (𝑥 − 3)(3𝑥 − 1)


𝑃1,2,3 (𝑥) =
3−1

𝑃1,2,3 (𝑥) = 4

Now, we can say that,

8 + (1.5 − 3)(3.5)
𝑃2,3 (1.5) =
1.5 − 1

𝑃2,3 (1.5) = 5.5

In the similar way, we can say that,

(1.5 − 2) 𝑃0,1 (1.5) − (1.5 − 0) 𝑃1,2 (1.5)


𝑃0,1,2 (1.5) =
0−2

(−0.5)2.5 − (1.5)3.5
𝑃0,1,2 (1.5) =
−2

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑃0,1,2 (1.5) = 3.25

Now finally we have to calculate, 𝑃0,1,2,3 (1.5)

(1.5 − 3) 𝑃0,1,2 (1.5) − (1.5 − 0) 𝑃1,2,3 (1.5)


𝑃0,1,2,3 (𝑥) =
0−3

(−1.5) 3.25 − (1.5)4


𝑃0,1,2,3 (𝑥) =
−3

𝑃0,1,2,3 (𝑥) = 3.625

Hence, we calculated the value of 𝑃0,1,2,3 (𝑥) = 3.625

Exercise 3.3 | Page 134 | Question 7

A) Use Algorithm 3.2 to construct the interpolating polynomial of degree three for the

unequally spaced points given in the following table:

x f(x)
-0.1 5.30000
0.0 2.00000
0.2 3.19000
0.3 1.00000

B) Add f(0.35) = 0.9726 to the table, and construct the interpolating polynomial of degree 4.

Solution:

A)

By divided difference code, we compute the polynomial and get the following output

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


From the output above, we can say that the constructed polynomial of degree three is,

P3(x) = −556.6667x3 + 185.5x2 − 8.8833x + 2.0

B)

By divided difference code, we compute the polynomial and get the following output

From the output above, we can say that the constructed polynomial of degree four is,

P4(x) = 2730.2434x4 − 1648.7640x3 + 212.8024x2 + 7.4981x + 2.0

Exercise 3.3 | Page 134 | Question 8

A) Use Algorithm 3.2 to construct the interpolating polynomial of degree four for the

unequally spaced points given in the following table:

x f(x)
0.0 -6.00000

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


0.1 -5.89483
0.3 -5.65014
0.6 -5.17788
1.0 -4.28172

B) Add f(1.1) = 3.99583 to the table, and construct the interpolating polynomial of degree 5.

Solution:

A)

By divided difference code, we compute the polynomial and get the following output

From the output above, we can say that the constructed polynomial of degree four is,

P4(x) = 0.0630x4 + 0.1520x3 + 0.5035x2 + 0.9998x − 6.0

B)

By divided difference code, we compute the polynomial and get the following output

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


From the output above, we can say that the constructed polynomial of degree five is,

P5(x) = 181.6428x5 − 363.2226x4 + 230.8383x3 − 51.8096x2 + 4.2693x − 6.0

Exercise 3.3 | Page 134 | Question 9

A) Approximate f(0.05) using the following data and the Newton forward-difference

formula:

x 0.0 0.2 0.4 0.6 0.8


f(x) 1.00000 1.22140 1.49182 1.82212 2.22554

B) Use the Newton backward-difference formula to approximate f(0.65)

C) Use Stirling’s formula to approximate f(0.43).

Solution:

A)

As we know that, divided difference is a general form, we would get same result as forward

difference. So we can use the code for divided difference to approximate f(0.05). This implies,

Approximating the functional value at 0.05, we get

From the above code and output, we can say that 𝑓(0.05) ≈ 1.0513

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


B)

As we know that, divided difference is a general form, we would get same result as backward

difference. So we can use the code for divided difference to approximate f(0.65). This implies,

Approximating the functional value at 0.65, we get

From the above code and output, we can say that 𝑓(0.65) ≈ 1.9156

C)

As we know that, divided difference is a general form, we would get same result as Stirling’s

formula approximation. So we can use the code for divided difference to approximate f(0.43).

This implies,

Approximating the functional value at 0.43, we get

From the above code and output, we can say that 𝑓(0.43) ≈ 1.5373

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 3.3 | Page 134 | Question 10

Show that the polynomial interpolating the following data has degree 3.

x -2 -1 0 1 2 3
f(x) 1 4 11 16 13 -4

Solution:

By divided difference code, we compute the polynomial and get the following output

According to the above output, we can say that the constructed polynomial is as follows,

𝑃3 (𝑥) = −1.0𝑥 3 − 1.0𝑥 2 + 7.0𝑥 + 11.0

This is a degree 3 polynomial. Hence, we have proved.

Exercise 4.3 | Page 202 | Question 16

𝑏−𝑎
Let ℎ = , x0 = a, x1 = a + h, and x2 = b.
3

Find the degree of precision of the quadrature formula,

𝑏
9 3
∫ 𝑓(𝑥)𝑑𝑥 = ℎ𝑓(𝑥1 ) + ℎ𝑓(𝑥2 )
𝑎 4 4

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Solution:

Let 𝑓(𝑥) = 1,

𝑏 𝑏
LHS: ∫𝑎 𝑓(𝑥)𝑑𝑥 = ∫𝑎 𝑑𝑥 = 𝑏 − 𝑎

9 𝑏−𝑎 3 𝑏−𝑎 𝑏−𝑎


RHS: + = (9 + 3) = 𝑏 − 𝑎
4 3 4 3 12

As we have seen above that it holds true for f(x)=1, now let f(x)=x, we have

𝑏 𝑏
𝑥2 𝑏 𝑏 2 − 𝑎2
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] =
𝑎 𝑎 2 𝑎 2

9 𝑏−𝑎 3 𝑏−𝑎
𝑅𝐻𝑆: (𝑎 + ℎ) + 𝑏
4 3 4 3

𝑏−𝑎
= (9𝑎 + 3𝑏 − 3𝑎 + 3𝑏)
12

𝑏−𝑎
= 6(𝑎 + 𝑏)
12

𝑏 2 − 𝑎2
=
2

Hence, it holds true for f(x) = x.

Now, let f(x) = x2, then we can say that,

𝑏 𝑏
𝑥3 𝑏 𝑏3 − 𝑎3 2
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] =
𝑎 𝑎 3 𝑎 3

9 𝑏−𝑎 3𝑏 − 𝑎 2
𝑅𝐻𝑆: (𝑎 + ℎ)2 + 𝑏
4 3 4 3

𝑏 − 𝑎 4𝑎2 + 𝑏 2 + 4𝑎𝑏
= [ + 𝑏2]
4 3

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑏 − 𝑎 4𝑎2 + 4𝑏 2 + 4𝑎𝑏
= [ ]
4 3

4 𝑏−𝑎
= (𝑎2 + 𝑏 2 + 𝑎𝑏)
3 4

(𝑏 − 𝑎)
= (a2 + b2 + ab)
3

𝑏 3 − 𝑎3
=
3

Hence, it holds true for f(x) = x2.

Now, let f(x) = x3, then we can say that,

𝑏 𝑏
𝑥4 𝑏
3
𝑏4 − 𝑎4
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] =
𝑎 𝑎 4 𝑎 4

9 𝑏−𝑎 3𝑏 − 𝑎 3
𝑅𝐻𝑆: (𝑎 + ℎ)3 + 𝑏
4 3 4 3

3(𝑏 − 𝑎) 2𝑎 + 𝑏 3 3 𝑏 − 𝑎 3
= ( ) + 𝑏
4 3 4 3

𝑏−𝑎 (2𝑎 + 𝑏)
= [3 + 𝑏3 ]
4 3

𝑏 − 𝑎 8𝑎3 + 𝑏 3 + 12𝑎2 𝑏 + 6𝑎𝑏 2


= [ + 𝑏3 ]
4 32

𝑏 − 𝑎 8𝑎3 + 𝑏 3 + 12𝑎2 𝑏 + 6𝑎𝑏 2 + 9𝑏 3


= [ ]
4 9

𝑏 − 𝑎 8𝑎3 + 10𝑏 3 + 12𝑎2 𝑏 + 6𝑎𝑏 2


= [ ]
4 9

As we have found out that LHS ≠ RHS, this implies that it does not hold true for 𝑓(𝑥) = 𝑥 3

Hence, the degree of precision is 3.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 4.3 | Page 202 | Question 17

1
The quadrature formula ∫−1 𝑓(𝑥)𝑑𝑥 = 𝑐0 𝑓(−1) + 𝑐1 𝑓(0)+ 𝑐2 𝑓(1) is exact for all polynomials

of degree less than or equal to 2. Determine c0, c1, and c2.

Solution:

Let us assume that f(x) = 1, for degree 0,

1 1 1
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑑𝑥 = [𝑥] =1+1=2
−1 −1
−1

𝑅𝐻𝑆: 𝑐0 (1) + 𝑐1 (1) + 𝑐2 (1) = 𝑐0 + 𝑐1 + 𝑐2 = 2

Let f(x) = x, for degree 1, we can say that

1 1 𝑥2 1 1 1
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] = − =0
−1 −1
2 −1 2 2

𝑅𝐻𝑆: 𝑐0 (−1) + 𝑐1 (0) + 𝑐2 (1) = 𝑐0 + 𝑐1 + 𝑐2 = 2

This implies, − 𝑐0 + 𝑐2 = 0

Hence, we can say that 𝑐0 = 𝑐2

From the above two results, we can say that,

2𝑐0 + 𝑐1 = 2 𝑜𝑟 2𝑐2 + 𝑐1 = 2

Now, according to the question, let f(x) = x2, for degree 2, we have

1 1 𝑥3 1
2
1 1 2
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] = + =
−1 −1
3 −1 3 3 3

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑅𝐻𝑆: 𝑐0 + 𝑐1 (0) + 𝑐2

= − 𝑐0 + 𝑐2

2
𝑇ℎ𝑖𝑠 𝑖𝑚𝑝𝑙𝑖𝑒𝑠, 𝑐0 + 𝑐2 =
3

From before, we have c0 = c2 ,

1
Therefore, on solving, we have, 𝑐2 = 3

1
This implies, 𝑐0 = 𝑐2 = 3

4
Also, 𝑐1 = 3

Exercise 4.4 | Page 210 | Question 2

Use the Composite Trapezoidal rule with the indicated values of n to approximate the following
integrals:

0.5
A) ∫−0.5 cos2 𝑥 𝑑𝑥 , 𝑛 = 4

0.5
B) ∫−0.5 x ln(x + 1) 𝑑𝑥 , 𝑛 = 6

1.75
C) ∫0.75 (sin2 𝑥 − 2 𝑥 𝑠𝑖𝑛𝑥 + 1)𝑑𝑥 , 𝑛=8

𝑒+2 1
D) ∫𝑒 𝑑𝑥 , 𝑛 = 8
xlnx

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Solution:

A)

The approximated root using composite trapezoidal rule is 0.911933

B)

The approximated root using composite trapezoidal rule is 0.093630

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


C)

The approximated root using composite trapezoidal rule is -0.48932

D)

The approximated root using composite trapezoidal rule is 0.44034

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Exercise 4.4 | Page 210 | Question 13

Determine the values of n and h required to approximate

2
1
∫ 𝑑𝑥
0 𝑥+4

to within 10-5 and compute the approximation. Use

A) Composite Trapezoidal rule

B) Composite Simpson’s rule

C) Composite Midpoint rule

Solution:

A)

As we know that,

|𝐸| < 10−5

ℎ2 (𝑏 − 𝑎) (2) ∗
𝑓 (𝑥 ) ≤ 10−5
12

12 ∗ 10−5
ℎ2 <
(𝑏 − 𝑎) 𝑓 (2) (𝑥 ∗ )

This implies that,

1
12 ∗ 10−5 2
ℎ< [ ]
(𝑏 − 𝑎) 𝑓 (2) (𝑥 ∗ )

Now, we have computed the value of h, now we can use this expression to find the value of n,

𝑏−𝑎
This implies 𝑛 ≥ ℎ

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Using the above python code, we can say that we have.

ℎ ≤ 0.04382 ≈ 4.3 ∗ 10−2 , This implies that,

𝑏−𝑎 2
𝑛≥ = = 45.6435 ≈ 46
ℎ 4.3 ∗ 10−2

Now we must approximate the integral using n = 46.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


According to our results obtained, we can say that,

The approximated value of the integral using composite trapezoidal method is 0.405471.

B)

As we know that

|𝐸| < 10−5

ℎ4 (𝑏 − 𝑎) (4) ∗
𝑓 (𝑥 ) < 10−5
180

180 ∗ 10−5
ℎ4 <
(𝑏 − 𝑎) 𝑓 (4) (𝑥 ∗ )

This implies that,

1
180 ∗ 10−5 4
ℎ< [ ]
(𝑏 − 𝑎) 𝑓 (4) (𝑥 ∗ )

Now, we have computed the value of h, now we can use this expression to find the value of n,

𝑏−𝑎
This implies 𝑛 ≥ ℎ

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


Using the above python code, we can say that we have.

ℎ ≤ 0.4427, This implies that,

𝑏−𝑎 2
𝑛≥ = = 4.5180 ≈ 5
ℎ 0.4427

Now we must approximate the integral using n = 5.

According to our results obtained, we can say that,

The approximated value of the integral using composite Simpson’s rule is 0.405466.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


C)

As we know that

|𝐸| < 10−5

ℎ2 (𝑏 − 𝑎) (2) ∗
𝑓 (𝑥 ) < 10−5
6

6 ∗ 10−5
ℎ2 <
(𝑏 − 𝑎) 𝑓 (2) (𝑥 ∗ )

This implies that,

1
6 ∗ 10−5 2
ℎ< [ ]
(𝑏 − 𝑎) 𝑓 (2) (𝑥 ∗ )

Now, we have computed the value of h, now we can use this expression to find the value of n,

𝑏−𝑎
This implies 𝑛 ≥ ℎ

Using the above python code, we can say that we have.

ℎ ≤ 0.03098, This implies that,

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936


𝑏−𝑎 2
𝑛≥ = = 64.5497 ≈ 65
ℎ 0.03098

Now we must approximate the integral using n = 65.

According to our results obtained, we can say that,

The approximated value of the integral using composite Midpoint method is 0.40560.

UTTAM GUPTA ug929@snu.edu.in Roll No. 2010120936

You might also like