Quiz1E Merged
Quiz1E Merged
Section: Date:
Question No.1 (7.5)
Take any two 3x3 matrices and write Python code (include necessary libraries) for:
1. Naive matrix multiplication
Also give reason(s), how it is efficient OR not w.r.t other multiplication methods?
Quiz No.1 (Numerical Computing CS2008) Total Marks: 15
Section: Date:
Question No.1 (6)
Solve the following 2x2 matrix analytically to find its eigenvalues and eigenvectors. Also,
normalize the eigenvectors.
4 2
⟦ ⟧
1 3
Write Python code (including necessary libraries) to calculate the eigenvalues,
eigenvectors, and their normalized forms.
Take any two 3x3 matrices and write Python code (include necessary libraries) for:
1. Vectorized Matrix Multiplication
Also tells how it is efficient in terms of other methods of multiplication in 1-2 lines?
Quiz No.1 (Numerical Computing CS2008) Total Marks: 15
Section: Date:
Take any two 3x3 matrices and write Python code (include necessary libraries) for:
Also give reason(s), how it is efficient OR not w.r.t other multiplication methods?
National University of Computer and Emerging Sciences
Islamabad Campus
Question # 1 [Marks = 9]
𝑥
• Evaluate the root of the equation 𝑠𝑖𝑛(𝑥) − 2 = 0 using secant method with
initial estimate of x1 = 1 and x2 = 2.
• Write Python code for the same equation catering the given data and take 𝑡𝑜𝑙 =
1. 𝑒 −6 .
Question # 2 [Marks = 6]
• Consider the function ℎ(𝑥) = 𝑥 5 − 5𝑥 + 4. Show that h(x) has at least one root
in the interval [-3, -2] using Bolzano’s Theorem.
• Consider the function f (x) = x2 − 4. Show that f (x) has at least one root in the
interval [1,3] using Bolzano’s Theorem.
Question # 1 [Marks = 9]
• Evaluate the root of the equation 𝑐𝑜𝑠 (𝑥 ) − 𝑥 𝑒 𝑥 = 0 using secant method with
initial estimate of x1 = 0.5 and x2 = 1.
• Write Python code for the same equation catering the given data and take 𝑡𝑜𝑙 =
1. 𝑒 −6 .
Question # 2 [Marks = 6]
• Consider the function 𝑔(𝑥 ) = 𝑥 3 − 3𝑥 + 1. Show that g(x) has at least one root
in the interval [-2,1] using Bolzano’s Theorem.
Quiz 3
Date: Section:
Quiz 4
Date: Section:
Quiz 4
Date: Section:
• Write the formula for Euler’s Modified Method (also known as Heun’s Method).
• Explain the difference between Euler Method and Euler’s Modified Method.
Quiz 5
Date: Section:
• Find the solution by using the Gauss-Seidel method for the following linear system:
3x1 − x2 + x3 = 1,
3x1 + 6x2 + 2x3 = 0,
3x1 + 3x2 + 7x3 = 4,
Quiz 5
Date: Section:
• Find the solution by using the Jacobi method for the following linear system:
3x1 − x2 + x3 = 1,
3x1 + 6x2 + 2x3 = 0,
3x1 + 3x2 + 7x3 = 4,
Quiz 5
Date: Section:
2x + y + 3z = 5,
4x + 4y + 7z = 10,
2x + 5y + 5z = 12.
Bonus (Optional): [Marks = 5] LU decomposition with partial pivoting involves row swaps to
improve numerical stability. The basic idea is to decompose matrix A into a product of a lower triangular
matrix L, an upper triangular matrix U , and a permutation matrix P , where P A = LU . The linear
system Ax = b becomes LU x = P b, and we solve for x using forward and backward substitution.
For the bonus:
• Explain the role of the permutation matrix P in LU decomposition with partial pivoting.
• Why is partial pivoting important when solving linear systems?
• **OR**: Write the algorithm or the code to perform LU decomposition with partial pivoting.
2x + y + 3z = 5
4x + 4y + 7z = 10
2x + 5y + 5z = 12
Perform LU decomposition with partial pivoting on this system, and then solve it to find
the values of x, y, and z.
National University of Computer & Emerging Sciences
Numerical Computing (CS-2008)
Task # 4
Due Date: 20-05-24
1 1 2
1. Let v1 = 0 , v2 = 1 and v3 = 0 . Use the Gram-Schmidt process to
1 1 −1
orthogonalize the set {v1 , v2 v3 }.
National University of Computer & Emerging Sciences
Numerical Computing (CS-2008)
Task # 5
Due Date: 20-05-24
1 −1 4
Consider the matrix A = 2 3 1.
1 1 1
1. Perform QR factorization on matrix A using Gram-Schmidt process.
2. Check if the Q matrix obtained is orthogonal.
3. Find the upper triangular matrix R.