Professional Documents
Culture Documents
Assignment
by
Uttam Gupta
(Roll no. 2010120936)
Submitted to
Bisection Method: This code is used to plot the required continuous function in order to check
This code is used to plot the graph of the derivative of g(x) in order to check the range of the
derivative.
This code is used to plot the required continuous and differentiable function.
Use the Bisection method to find solutions, accurate to within 10−5 for the following
problems.
(A) 3𝑥 − 𝑒 𝑥 = 0 for 1 ≤ 𝑥 ≤ 2
Solution:
3𝑥 − 𝑒 𝑥 = 0 for 1 ≤ 𝑥 ≤ 2
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.
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.
Case 1: a = 1 and b = 2
the desired root, as shown in the graph and solution table below.
As shown in the graph and iteration table, after 18 iterations, th e desired root is 3.05710
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].
Solution:
As we know that,
𝑏−𝑎
| 𝑃𝑛 − 𝑃 | ≤ ≤ 10−4
2𝑛
After substituting the given values in the above mentioned equation, we get,
2−1
≤ 10−4
2𝑛
2𝑛 ≥ 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.
The function defined by 𝑓(𝑥) = sin 𝜋𝑥 has zeros at every integer. Show that when
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].
A) 0 If a + b < 2
1<𝑎+ 𝑏<3
This Implies, 1<𝑎+𝑏 <2
1 𝑎+𝑏
This Implies, < <1
2 2
𝑎+𝑏
𝑆𝑖𝑛 𝜋𝑥 < 𝑓 ( )<1
2
𝑎+𝑏
Now, we can say that there exist c ∈ [ a , ] such that 𝑓(𝑐) = 0
2
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
Now, after considering these conditions, we have the only possible value for c is 2.
C) 1, if a + b = 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.
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
ℎ
𝑉 = 𝐿 [ 0.5 𝜋 𝑟 2 − 𝑟 2 𝑎𝑟𝑐 sin( 𝑟 ) − ℎ(𝑟 2 − ℎ2 )1/2]
Now we want to calculate the depth of water (h) in the trough to within 0.01 ft.
1
12.4 = 10 [ 0.5 𝜋 − 𝑎𝑟𝑐 sin(ℎ) − ℎ ( 1 − ℎ2 )2 ]
12.4 1
= 0.5 𝜋 − 𝑎𝑟𝑐 sin(ℎ) − ℎ (1 − ℎ2 )2
10
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,
constant rate
𝑑𝜃
=𝜔<0
𝑑𝑡
𝑔 𝑒 𝜔𝑡 − 𝑒 −𝜔𝑡
𝑥(𝑡) = − 2 ( − sin 𝜔𝑡 )
2𝜔 2
Suppose the particle has moved 1.7ft in 1 second. Find, to within 10−5 , the rate 𝜔 at
Solution:
As given in question, 𝑥(1) = 1.7 𝑓𝑡 𝑎𝑛𝑑 𝑔 = 32.17 𝑓𝑡/𝑠 2 . Now we need to find the rate
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
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
Show that theorem 2.3 may not hold if inequality | 𝑔′(𝑥)| ≤ 𝑘 is replaced by 𝑔′(𝑥) ≤ 𝑘.
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,
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
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,
Now we can conclude that the theorem does not hold for this function.
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
Now, we require to show that for any p0 ∈ [a, b], the sequence pn = g(pn-1), n ≥ 1 and converges
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,
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]
As the proof of the theorem concludes that 0 < L < 1 implies that,
Hence, pn → p as n → ∞.
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-
Solution:
In this question,
As we know that g′(x) is continuous, hence, by definition for any ε > 0 ∃δ > 0 such that,
∀x ∈ (p − δ, p + δ)
1−𝑘
Now when ε = (∵ k < 1 and ε > 0),
2
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
Let’s now assume that δ = δ1/2 and lets us now see the function g defined on [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
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.
⇒ g′ is continuous at p, as p ∈ (a, b)
> |g′(p)| − ε
Now let p0 be the first iteration s.t 0 < |p0 − p| < δ and
Use Newton’s method to find solutions accurate to within 10−4 for the following
problems.
a. x3 − 2x2 − 5 = 0, [1, 4]
Solution:
A) x3 − 2x2 − 5 = 0, [1, 4]
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
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
𝑥 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
As we know that, f(x) is a polynomial function, then it is also continuous and differentiable.
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
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
𝑥 3 + 3𝑥 2 − 1
𝑔(𝑥) = 𝑥 −
3𝑥 2 − 6𝑥
(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.
As we have our function f(x) differentiable and continuous. Now, we need to check if
𝜋
𝑓 ′ (𝑥) = 1 + 𝑠𝑖𝑛𝑥 , 𝑥 ∈ [0, ]
2
𝜋
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 0 , 2 ].
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
𝑥 − cos 𝑥
𝑔(𝑥) = 𝑥 −
1 + 𝑠𝑖𝑛𝑥
(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
𝜋
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 0 , 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
Use Newton’s method to find solutions accurate to within 10−5 for the following
problems.
Solution:
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 1 , 2].
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
𝑒 𝑥 + 2−𝑥 + 2𝑐𝑜𝑠𝑥 − 6
𝑔(𝑥) = 𝑥 −
𝑒 𝑥 − 2−𝑥 log 2 − 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
Case i) 2≤𝑥≤3
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 2 , 3].
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
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
Now, from the above results, we cannot consider any x for which f′(x) = 0, because if so
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
2𝑥 cos 2𝑥 − (𝑥 − 2)2
𝑔(𝑥) = 𝑥 −
2 [cos 2𝑥 − 𝑥(2 sin 𝑥 + 1) + 2]
(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
Case i) 0≤𝑥≤1
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 0 , 1].
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
sin 𝑥 − 𝑒 −𝑥
𝑔(𝑥) = 𝑥 −
cos 𝑥 + 𝑒 −𝑥
(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
Hence, we need to proceed with g(x), which is defined for all 𝑥 ∈ [ 3 , 4].
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
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
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
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
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
Solution:
Let A(x, x2) be a point on the graph and B(1, 0) be the given point.
= (1 − x) 2 + (0 − x) 2
= x4 + x2 − 2x + 1
f′(x) = 4x3 + 2x − 2 = 0
Now, let’s continue further without considering all those values of x, for which f′(x) = 0
𝑓(𝑥)
𝑔(𝑥) = 𝑥 −
𝑓 ′ (𝑥)
4𝑥 3 + 2𝑥 − 2
𝑔(𝑥) = 𝑥 −
12𝑥 2 + 𝑥
(approximately). Now we can start the iteration process with initial value of x0 = 0.25
𝑛
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
Solution:
A)
converges quadratically, we will have to determine the limits as given in the definition
|𝑝𝑛+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
We need to suppose that ∃ k > 1 such that the given sequence converges to 0 quadratically.
|𝑝𝑛+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
= ∞
Hence, the assumption that the sequence converges quadratically was false.
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
𝑛
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 α
|𝑝𝑛+1 − 𝑝|
lim
𝑛→∞ |𝑝𝑛 − 𝑝|𝛼
𝑛+1
|10−𝛼 −0|
= lim −𝛼 𝑛
𝑛→∞ |10 − 0|𝛼
𝑛+1
|10−𝛼 |
= lim
𝑛→∞ |10−𝛼𝑛 |𝛼
𝑛
|10−𝛼 ∗𝛼 |
= lim 𝑛
𝑛→∞ |10−𝛼 ∗𝛼 |
= 1
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 )
Solution:
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
|𝑝𝑛+1 −𝑝|
If positive constants are α, λ exists with lim ( |𝑝𝑛 −𝑝|α
) = λ , then,
𝑛→∞
∞
{𝑝𝑛 } 𝑛=0 converges to p of order α with asymptotic error constant λ.
|𝑝𝑛+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 − 𝑝|
----------------------------------------------------------------------
𝑥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.
This implies,
This implies,
2
𝑃1,2 (0.5) =
0.5
This implies,
𝑃1,2 (0.5) = 4
1.2 − (0.56)
𝑃2 (0.5) =
0.1
0.64
𝑃2 (0.5) =
0.1
𝑃2 (0.5) = 6.4
Solution:
As we know that,
Also, we have
(7.5) + (0.5)2.875
𝑃0,1,2,3 (𝑥) =
3
Solution:
𝑃1,2,3 (𝑥) = 4
8 + (1.5 − 3)(3.5)
𝑃2,3 (1.5) =
1.5 − 1
(−0.5)2.5 − (1.5)3.5
𝑃0,1,2 (1.5) =
−2
A) Use Algorithm 3.2 to construct the interpolating polynomial of degree three for the
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
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,
A) Use Algorithm 3.2 to construct the interpolating polynomial of degree four for the
x f(x)
0.0 -6.00000
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,
B)
By divided difference code, we compute the polynomial and get the following output
A) Approximate f(0.05) using the following data and the Newton forward-difference
formula:
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,
From the above code and output, we can say that 𝑓(0.05) ≈ 1.0513
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,
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,
From the above code and output, we can say that 𝑓(0.43) ≈ 1.5373
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,
𝑏−𝑎
Let ℎ = , x0 = a, x1 = a + h, and x2 = b.
3
𝑏
9 3
∫ 𝑓(𝑥)𝑑𝑥 = ℎ𝑓(𝑥1 ) + ℎ𝑓(𝑥2 )
𝑎 4 4
Let 𝑓(𝑥) = 1,
𝑏 𝑏
LHS: ∫𝑎 𝑓(𝑥)𝑑𝑥 = ∫𝑎 𝑑𝑥 = 𝑏 − 𝑎
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
𝑏 𝑏
𝑥3 𝑏 𝑏3 − 𝑎3 2
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] =
𝑎 𝑎 3 𝑎 3
9 𝑏−𝑎 3𝑏 − 𝑎 2
𝑅𝐻𝑆: (𝑎 + ℎ)2 + 𝑏
4 3 4 3
𝑏 − 𝑎 4𝑎2 + 𝑏 2 + 4𝑎𝑏
= [ + 𝑏2]
4 3
4 𝑏−𝑎
= (𝑎2 + 𝑏 2 + 𝑎𝑏)
3 4
(𝑏 − 𝑎)
= (a2 + b2 + ab)
3
𝑏 3 − 𝑎3
=
3
𝑏 𝑏
𝑥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
As we have found out that LHS ≠ RHS, this implies that it does not hold true for 𝑓(𝑥) = 𝑥 3
1
The quadrature formula ∫−1 𝑓(𝑥)𝑑𝑥 = 𝑐0 𝑓(−1) + 𝑐1 𝑓(0)+ 𝑐2 𝑓(1) is exact for all polynomials
Solution:
1 1 1
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑑𝑥 = [𝑥] =1+1=2
−1 −1
−1
1 1 𝑥2 1 1 1
𝐿𝐻𝑆: ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑥 𝑑𝑥 = [ ] = − =0
−1 −1
2 −1 2 2
This implies, − 𝑐0 + 𝑐2 = 0
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
= − 𝑐0 + 𝑐2
2
𝑇ℎ𝑖𝑠 𝑖𝑚𝑝𝑙𝑖𝑒𝑠, 𝑐0 + 𝑐2 =
3
1
Therefore, on solving, we have, 𝑐2 = 3
1
This implies, 𝑐0 = 𝑐2 = 3
4
Also, 𝑐1 = 3
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
A)
B)
D)
2
1
∫ 𝑑𝑥
0 𝑥+4
Solution:
A)
As we know that,
ℎ2 (𝑏 − 𝑎) (2) ∗
𝑓 (𝑥 ) ≤ 10−5
12
12 ∗ 10−5
ℎ2 <
(𝑏 − 𝑎) 𝑓 (2) (𝑥 ∗ )
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 𝑛 ≥ ℎ
𝑏−𝑎 2
𝑛≥ = = 45.6435 ≈ 46
ℎ 4.3 ∗ 10−2
The approximated value of the integral using composite trapezoidal method is 0.405471.
B)
As we know that
ℎ4 (𝑏 − 𝑎) (4) ∗
𝑓 (𝑥 ) < 10−5
180
180 ∗ 10−5
ℎ4 <
(𝑏 − 𝑎) 𝑓 (4) (𝑥 ∗ )
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 𝑛 ≥ ℎ
𝑏−𝑎 2
𝑛≥ = = 4.5180 ≈ 5
ℎ 0.4427
The approximated value of the integral using composite Simpson’s rule is 0.405466.
As we know that
ℎ2 (𝑏 − 𝑎) (2) ∗
𝑓 (𝑥 ) < 10−5
6
6 ∗ 10−5
ℎ2 <
(𝑏 − 𝑎) 𝑓 (2) (𝑥 ∗ )
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 𝑛 ≥ ℎ
The approximated value of the integral using composite Midpoint method is 0.40560.