You are on page 1of 3

Assignment #1

Numerical Analysis (Spring 2021)


Instructor: Dr. M. Mahboob Ur Rahman Total Marks: 110

TA: Waqas Aman Due Date: 3/5/2021

Class: BSEE018 Based on CLOs: CLO 1.

_____________________________________________________________________________

Q.1. Convert the following base-2 numbers to base-10: [6] CLO 1

(a) 101101

(b) 101.011

(c) 0.01101

Q.2. Convert the following base-8 numbers to base-10: [4] CLO 1

(a) 71,263

(b) 3.147.

Q.3. Use Matlab/Python or any other platform to compose your own program based on Fig. 1 and
use it to determine your computer’s machine epsilon. Turn in your code and computer specifications
as answer to this question. [5] CLO 1

Fig. 1

Q.4. In a fashion similar to that in Fig. 1, write a short program in Matlab/Python or any other
platform to determine the smallest number, 𝑥_{𝑚𝑖𝑛}, used on the computer you will be employing
along with the text book. Note that your computer will be unable to reliably distinguish between
zero and a quantity that is smaller than this number. Turn in your code and computer specifications
as answer to this question. [5] CLO 1

Q.5. The infinite series


1
𝑓(n) = ∑𝑛𝑖=1 𝑖4

𝜋4
converges on a value of 𝑓(n) = 90 as ‘’n’’ approaches infinity. Use Matlab/Python or any other
platform to write a program in single precision to calculate 𝑓(n) for n = 10000 by computing the
sum from 𝑖 = 1 𝑡𝑜 10000. Then repeat the calculation but in reverse order—that is, from =
10000 𝑡𝑜 1 using increments of -1. In each case, compute the true percent relative error. Explain the
results. Turn in your code as well. [10] CLO 1

Q.6. Evaluate 𝑒 −5 using two approaches [10] CLO 1


𝑥2 𝑥3
𝑒 −𝑥 = 1 − 𝑥 + 2
− 3!
+⋯ ,

and
1
𝑒 −𝑥 = 1/𝑒 𝑥 = 𝑥2 𝑥3
,
1+𝑥+ + +⋯
2 3!

and compare with the true value of 6.737947 ∗ 10−3 . Use 20 terms to evaluate each series and
compute true and approximate relative errors as terms are added.

Q.7. The following infinite series can be used to approximate 𝑒 𝑥 : [10] CLO 1
𝑥2 𝑥3 𝑥𝑛
𝑒𝑥 = 1 + 𝑥 + 2
+ 3!
+ ⋯+ 𝑛!
.

Use the Taylor series to estimate 𝑓(𝑥) = 𝑒 −𝑥 at 𝑥𝑖+1 = 1 for 𝑥𝑖 = 0.2. Employ the zero-, first-,
second-, and third-order versions and compute the |𝜖𝑡 |for each case.

Q.8. The Maclaurin series expansion for 𝑐𝑜𝑠(𝑥) is [10] CLO 1


𝑥2 𝑥4 𝑥6 𝑥8
cos(𝑥) = 1 − 2
+ 4!
− 6!
+ 8!
−⋯
𝜋
Starting with the simplest version, 𝑐𝑜𝑠(𝑥) = 1, add terms one at a time to estimate 𝑐𝑜𝑠 ( 3 ). After
each new term is added, compute the true and approximate percent relative errors. Use your pocket
calculator to determine the true value. Add terms until the absolute value of the approximate error
estimate falls below 1%.

Q.9. Use zero- through third-order Taylor series expansions to predict 𝑓(3) for [5] CLO 1

𝑓(𝑥) = 25𝑥 3 − 6𝑥 2 + 7𝑥 − 88
using a base point at 𝑥 = 1. Compute the true percent relative error |𝜖𝑡 |for each approximation.

Q.10. Use zero- through fourth-order Taylor series expansions to predict 𝑓(2.5) for [5] CLO 1

𝑓(𝑥) = ln(𝑥)
using a base point at 𝑥 = 1. Compute the true percent relative error |𝜖𝑡 |for each approximation.
Discuss the meaning of the results.

Q.11. Use forward and backward difference approximations of O(ℎ) and a centered difference
approximation of O(ℎ2 ) to estimate the first derivative of the function examined in Q.9. Evaluate
the derivative at 𝑥 = 2 using a step size of at ℎ = 0.2 . Compare your results with the true value of
the derivative. Interpret your results on the basis of the remainder term of the Taylor series
expansion. [10] CLO 1

Q.12. Use a centered difference approximation of O(ℎ2 ) to estimate the second derivative of the
function examined in Q.9. Perform the evaluation at 𝑥 = 2 using step sizes of ℎ = 0.25 and 0.125.
Compare your estimates with the true value of the second derivative. Interpret your results on the
basis of the remainder term of the Taylor series expansion. [10] CLO 1

Q.13. The Stefan-Boltzmann law can be employed to estimate the rate of radiation of energy 𝐻 from
a surface, as in [10] CLO 1

𝐻 = 𝐴𝑒𝜎𝑇 4 ,

where 𝐻 is in watts, 𝐴 = the surface area (𝑚2 ), 𝑒 = the emissivity that characterizes the emitting
properties of the surface (dimensionless), 𝜎 = a universal constant called the Stefan-Boltzmann
constant (= 5.67 * 10−8 𝑊𝑚−2 𝐾 −4), and 𝑇 = absolute temperature (𝐾). Determine the error of 𝐻
for a steel plate with 𝐴 = 0.15 𝑚2, 𝑒 = 0.90, and 𝑇 = 650 ± 20. Compare your results with the
exact error. Repeat the computation but with 𝑇 = 650 ± 40. Interpret your results.

Q.14. Evaluate and interpret the condition numbers for [10] CLO 1

(a) 𝑓(𝑥) = √|𝑥 − 1| + 1 for 𝑥 = 1.00001

(b) 𝑓(𝑥) = 𝑒 −𝑥 for 𝑥 = 10

(c) 𝑓(𝑥) = √𝑥 2 + 1 − 𝑥 for 𝑥 = 300


𝑒 −𝑥 −1
(d) 𝑓(𝑥) = for 𝑥 = 0.001
𝑥
sin 𝑥
(e) 𝑓(𝑥) = 1+cos 𝑥 for 𝑥 = 1.0001𝜋

You might also like