0% found this document useful (0 votes)
28 views17 pages

Quiz1E Merged

The document contains a series of quizzes and tasks for a Numerical Computing course, each with specific questions related to matrix operations, numerical methods, and Python coding. Topics include positive definiteness, matrix multiplication, eigenvalues, integration, differential equations, and iterative methods like Jacobi and Gauss-Seidel. Each quiz and task specifies the marks, instructions, and sometimes includes bonus questions for additional credit.

Uploaded by

Junaid Asrar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views17 pages

Quiz1E Merged

The document contains a series of quizzes and tasks for a Numerical Computing course, each with specific questions related to matrix operations, numerical methods, and Python coding. Topics include positive definiteness, matrix multiplication, eigenvalues, integration, differential equations, and iterative methods like Jacobi and Gauss-Seidel. Each quiz and task specifies the marks, instructions, and sometimes includes bonus questions for additional credit.

Uploaded by

Junaid Asrar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Quiz No.

1 (Numerical Computing CS2008) Total Marks: 15

Name: Roll No.

Section: Date:
Question No.1 (7.5)

For the following matrix:


4 −1 0 0
−1 4 −1 0
𝐴=[ ]
0 −1 4 −1
0 0 −1 4
1. Prove that the matrix is positive definite by checking the principal minors.
2. Store the matrix in a banded storage format.

3. Write python code (include necessary libraries) to solve this.

Question No.2 (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

Name: Roll No.

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.

Question No.2 (9)

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

Name: Roll No.

Section: Date:

Question No.1 (7.5)

Given a banded matrix:


3 −1 0 0
−1 3 −1 0
𝐴=[ ]
0 −1 3 −1
0 0 −1 3
1. Store the matrix in a banded storage format.
1
2
2. Write Python code (include necessary libraries) to solve Ax=b, with 𝑏 = ⟦ ⟧.
2
1
3. Use any Linear Algebra technique to solve it analytically.

Question No.2 (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?
National University of Computer and Emerging Sciences
Islamabad Campus

Numerical Computing (CS-2008) Quiz 2


Date: 30 September 2024 Total Time (Min): 15
Course Instructors Total Marks: 15
Dr. Mir Muhammad Suleman Sarwar, Total Questions: 2

Roll No Section Student Signature


Attempt all the questions

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.

Fall 2024 Quiz, FAST School of Computing Page 1 of 1


National University of Computer and Emerging Sciences
Islamabad Campus

Numerical Computing (CS-2008) Quiz 2


Date: 30 September 2024 Total Time (Min): 15
Course Instructors Total Marks: 15
Dr. Mir Muhammad Suleman Sarwar, Total Questions: 2

Roll No Section Student Signature


Attempt all the questions

Question # 1 [Marks = 7.5]

• 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 # 2 [Marks = 7.5]


• Use Newton’s Method to find an approximate root of the equation f (x) = lnx + x.
Start with an initial guess of x0 = 1.0 and perform 50 iterations. Use tolerance
1.e-4.
Write down python code for naive algorithm of newtons’s method and show output
of three iterations

Fall 2024 Quiz, FAST School of Computing Page 1 of 1


National University of Computer and Emerging Sciences
Islamabad Campus

Numerical Computing (CS-2008) Quiz 2


Date: 30 September 2024 Total Time (Min): 15
Course Instructors Total Marks: 15
Dr. Mir Muhammad Suleman Sarwar, Total Questions: 2

Roll No Section Student Signature


Attempt all the questions

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.

Fall 2024 Quiz, FAST School of Computing Page 1 of 1


National University of Computer and Emerging Sciences
Islamabad Campus Numerical Computing (CS-2008)

Quiz 3

Course Instructor: Dr. Mir Muhammad Suleman Sarwar

Total Time (Min): 15 Total Marks: 15 Total Questions: 2

Date: Section:

Name: Roll No:

Instructions: Attempt all questions. Show all work where required.

Question 1 [Marks = 7.5]


R1
• Evaluate the integral 1
0 1+x2
dx using Simpson’s 1
3 Rule.

• Write Python code for implementing Simpson’s Rule.

Question 2 [Marks = 7.5]


R2 x
• Use the 2-point Gauss quadrature to evaluate the integral I = −2
e− 2 dx.

Fall 2024 Quiz, FAST School of Computing


National University of Computer and Emerging Sciences
Islamabad Campus Numerical Computing (CS-2008)

Quiz 4

Course Instructor: Dr. Mir Muhammad Suleman Sarwar

Total Time (Min): 15 Total Marks: 10 Total Questions: 1

Date: Section:

Name: Roll No:

Instructions: Attempt the question. Show all work where required.

Question 1 [Marks = 10]


Solve the following differential equation:
dy y−x
=
dx y+x
with the initial condition y = 1 at x = 0. Find the approximate value of y at x = 0.1 using Euler
Method.

Bonus (Optional): [Marks = 2]


• 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.

Fall 2024 Quiz, FAST School of Computing


National University of Computer and Emerging Sciences
Islamabad Campus Numerical Computing (CS-2008)

Quiz 4

Course Instructor: Dr. Mir Muhammad Suleman Sarwar

Total Time (Min): 15 Total Marks: 10 Total Questions: 1

Date: Section:

Name: Roll No:

Instructions: Attempt the question. Show all work where required.

Question 1 [Marks = 10]


Solve the following differential equation:
dy
= 3x + y
dx
with the initial condition y = −1 at x = 0. Find the approximate value of y at x = 0.2 using Euler
Method with a step size of h = 0.04.

Bonus (Optional): [Marks = 2]

• 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.

Fall 2024 Quiz, FAST School of Computing


National University of Computer and Emerging Sciences
Islamabad Campus Numerical Computing (CS-2008)

Quiz 5

Course Instructor: Dr. Mir Muhammad Suleman Sarwar

Total Time (Min): 15 Total Marks: 15 Total Questions: 1

Date: Section:

Name: Roll No:

Instructions: Attempt the question. Show all work where required.

Question 1 [Marks = 15]

• 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,

using the initial guess  


1/2
x(0) = 1/2
1/2
and TOL < 10−3 .
• Write a Python function to implement the Gauss-Seidel iterative scheme.

Fall 2024 Quiz, FAST School of Computing


National University of Computer and Emerging Sciences
Islamabad Campus Numerical Computing (CS-2008)

Quiz 5

Course Instructor: Dr. Mir Muhammad Suleman Sarwar

Total Time (Min): 15 Total Marks: 15 Total Questions: 1

Date: Section:

Name: Roll No:

Instructions: Attempt the question. Show all work where required.

Question 1 [Marks = 15]

• 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,

using the initial guess  


1/2
x(0) = 1/2
1/2
and TOL < 10−3 .
• Write a Python function to implement the Jacobi iterative scheme.

Fall 2024 Quiz, FAST School of Computing


National University of Computer and Emerging Sciences
Islamabad Campus Numerical Computing (CS-2008)

Quiz 5

Course Instructor: Dr. Mir Muhammad Suleman Sarwar

Total Time (Min): 15 Total Marks: 15 Total Questions: 1

Date: Section:

Name: Roll No:

Instructions: Attempt the question. Show all work where required.

Question 1 [Marks = 15]

• Consider the following system of linear equations:

2x + y + 3z = 5,
4x + 4y + 7z = 10,
2x + 5y + 5z = 12.

• Perform LU decomposition with partial pivoting on this system.

• Solve the system to find the values of x, y, and z.

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.

Fall 2024 Quiz, FAST School of Computing


National University of Computer & Emerging Sciences
Numerical Computing (CS-2008)
Task # 1
Due Date: 20-05-24
• Find the solution by using the Jacobi and Gauss Seidel method for the following
linear system:
3x1 − x2 + x3 = 1, 3x1 + 6x2 + 2x3 = 0, 3x1 + 3x2 + 7x3 = 4,
 
1/2
using the initial guess x(0) = 1/2 and T OL < 10−3 .

1/2
• Write down Python functions for the implementation of Jacobi and Gauss Seidel
Iterative Schemes.
National University of Computer & Emerging Sciences
Numerical Computing (CS-2008)
Task # 1
Due Date: 20-05-24
• Write the following matrix as product of L and U either by using Dolittle or Crout
Factorization.  
3 −1 1
3 6 2
3 3 7
• Decompose the following matrix as product of L and U by using the idea of Gauss
Elimination  
3 −10 1
1 6 2
2 3 3
National University of Computer & Emerging Sciences
Numerical Computing (CS-2008)
Task # 3
Due Date: 20-05-24
Consider the following system of linear equations:

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.

You might also like