CLL113 Quiz 1 Solution

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Q: If a function is real and continuous in the region from a to b and f(a) and f(b) have

opposite signs then there is no real root between a and b.


a) True
b) False

Answer:
Answer: b
Explanation: If a function is real and continuous in the region from a to b and f(a) and f(b)
and if both have different signs then there is at least one real root between a and b. This is
because the function has to cross the x-axis at least once.

–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Q: The equation f(x) is given as x3 – x2 + 4x – 4 = 0. Considering the initial approximation at


x=2 then the value of next approximation correct upto 2 decimal places is given as
__________
a) 0.67
b) 1.33
c) 1.00
d) 1.50

Answer:
Answer: b
Explanation: Iterative formula for Newton Raphson method is given by
x(1)=x(0)+𝑓(𝑥(0))𝑓′𝑥(𝑥(0)).
Hence x0=2 (initial guess), f(x0)=8 and f’(x0)=12.
Substituting the values in the equation we get x1=1.33
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Q: The iterative formula for a secant method is given as _________


a) x(n+1)=𝑥(𝑛−1)𝑓[𝑥(𝑛)]−𝑥(𝑛)𝑓[𝑥(𝑛−1)][𝑓[𝑥(𝑛)]−𝑓[𝑥(𝑛−1)]]
b) x(n+1)=𝑥(𝑛)𝑓[𝑥(𝑛)]−𝑥(𝑛)𝑓[𝑥(𝑛−1)][𝑓[𝑥(𝑛)]−𝑓[𝑥(𝑛−1)]]
c) x(n+1)=𝑥(𝑛−1)𝑓[𝑥(𝑛)]−𝑥(𝑛−1)𝑓[𝑥(𝑛−1)][𝑓[𝑥(𝑛)]−𝑓[𝑥(𝑛−1)]]
d) x(n+1)=𝑥(𝑛)𝑓[𝑥(𝑛)]−𝑥(𝑛−1)𝑓[𝑥(𝑛−1)][𝑓[𝑥(𝑛)]−𝑓[𝑥(𝑛−1)]]

Answer:
Answer: a
Explanation: The Iterative formula for a Secant Method is given by
x(n+1)=𝑥(𝑛−1)𝑓[𝑥(𝑛)]−𝑥(𝑛)𝑓[𝑥(𝑛−1)][𝑓[𝑥(𝑛)]−𝑓[𝑥(𝑛−1)]]
Since there are 2 points considered in the Secant Method, it is also called 2-point method.

–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Q: Secant method converges faster than Bisection method.
a) True
b) False

Answer:
Answer: a
Explanation: Secant method converges faster than Bisection method. Secant method has a
convergence rate of 1.62 where as Bisection method almost converges linearly.
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Q: The Bisection method is also known as ___________________
a) Binary Chopping
b) Quaternary Chopping
c) Tri region Chopping
d) Hex region Chopping

Answer:
Answer: a
Explanation: Bisection Method is also called as Binary Chopping. It is a method involving
the division of the interval into half.

Q: The series form of sinhx can be presented as:


sinhx =(ex-e-x)/2
ex = 1 + x/1! + x2/2! + x3/3!+.....
Using C/C++ program with x =1 and iterations = 5, find the value of sinhx up to 8 decimal
places. Evaluate the sum of the digits of the difference between the numerical and exact value
of sinhx.
Ans: 20
Q: What are the correct option/options for a Gauss Elimination (G-E) code in which a matrix
is an input to the G-E function in which A is the matrix, n is the size of the matrix, b is the
vector, and x is the solution vector?
A) void Gauss_Elimination(int n, double A[][n], double b, double x[])
B) void Gauss_Elimination(int n, double A**, double b*, double *x)
C) Gauss_Elimination(n,A,b,x)
D) b = (double )malloc(n*sizeof(double*));

Q: Solve the linear system of equations.


0.003 59.14 0 0 k 59.17
5.291 -6.130 0 0 l 46.78
0 0 1 0 m 26.00
0 0 0 13.001*t2 n 54.00
Where t is an integer and varies between 1 to 3, take the only integer part of k,l,m and n and
evaluate (k+l)/(m+n).
A) 0.3667
B) 0.8918
C) 0.4230
D) 0.4563

Q: Construct a matrix whose elements are dependent on two variables:


k = 1 to 4
l = 1 to 4
akl = 1/(k+l-1) and b = [1,1..,1].
Solve the system of equations using the Gauss-Elimination method and evaluate the sum of the
first and the last solution vector.
Ans: 136
Q: Sheldon wants to use dynamic memory allocation for an array of matrices (named mat) of
size k. Identify the correct statement/statements of the code.
A) float mat*[k]
B) mat[a][i] = (float *)malloc(ny*sizeof(float*));
C) mat[a] = (float ** )malloc(nx*sizeof(float*));
D) mat[a] = (float ** )malloc(nx*sizeof(float**));

Q: Solve this system of equations and comment on the nature of the solution using Gauss
Elimination method.

x+y+z=0

-x – y + 3z = 3

-x – y – z = 2

a) Unique Solution
b) No solution
c) Infinitely many Solutions
d) Finite solutions

Answer: b) (No solution)

Explanation: By Gauss Elimination method we add Row 1 and Row 3 to get the following
1 1 1 𝑥 0
matrix: [−1 1 3] [𝑦] = [3]
0 0 0 𝑧 2

Hence the matrix has no solution as 0 ≠ 2.

Q: The elimination process and reduced form of the Matrix in Gauss Elimination method is
respectively known as:
a) Backward Elimination and Column Echelon Form
b) Sideways Elimination and Row-Column Echelon Form
c) Crossways Elimination and Column-Row Echelon Form
d) Forward Elimination and Row Echelon Form

Answer: d) (Forward Elimination and Row Echelon Form)

Explanation: The Elimination process in Gauss Elimination Method is also known as


Forward Elimination. N this method a Matrix is reduced to an Upper Triangular Matrix. The
reduced form of the Matrix in Gauss Elimination Method is called as Row Echelon Form. It
is said so because only Row Operations are considered in Gauss Elimination method.

Q: Starting with initial approximation of values x=y=z=0, what will be the next value of x in
the following set of simultaneous equations with gauss elimination method?
27x + 6y – z = 81,

6x + 15y + 2z = 75,

x + y + 50z = 110

a) 2.25
b) 3.0
c) 3.25
d) 4.0

Answer: b) 3.0

Q: What will be the appropriate C codes for Gauss Elimination & Back Substitution.

a) if(i!=j)
{
ratio = a[j][i]/a[i][i];
for(k=1;k<=n+1;k++)
{
a[j][k] = a[j][k] - ratio*a[i][k];

b) ratio = a[j][i]/a[i][i];

for(k=1;k<=n+1;k++)
{
a[j][k] = a[j][k] - ratio*a[i][k];
}

c) for(i=n-1;i>=1;i--)

{
x[i] = a[i][n+1];
for(j=i+1;j<=n;j++)
{
x[i] = x[i] - a[i][j]*x[j];
}
x[i] = x[i]/a[i][i];
}
d) for(i=n-1;i>=1;i--)

{
x[i] = a[i][n+1];
for(j=i+1;j<=n;j++)
{
x[i] = x[i] - a[j][i]*x[j];
}
x[i] = x[i]/a[i][i];
}
Answer: b & c.
Q: Solve the following equations by Gauss Elimination Method.

x+4y-z = -5

x+y-6z = -12

3x-y-z = 4

a) x = 1.64791, y = 1.14085, z = 2.08451


b) x = 1.65791, y = 1.14185, z = 2.08441
c) x = 1.64691, y = 1.14095, z = 2.08461
d) x = 1.64491, y = 1.15085, z = 2.09451
Answer: a

Q: Using the given expansion of 𝑒 𝑥 for x=1, evaluate the true percent relative error and
approximate percent error:
𝑥
𝑥2 𝑥3
𝑒 = 1 + 𝑥 + + +. ..
2! 3!
Given; True value of 𝑒 = 2.718282, use the first 6 terms
a) 𝜀𝑡 = 0.054949 and 𝜀𝑎 = 0.406760
b) 𝜀𝑡 = 0.059449 and 𝜀𝑎 = 0.306736
c) 𝜀𝑡 = 0.059449 and 𝜀𝑎 = 0.307636
d) 𝜀𝑡 = 0.054994 and 𝜀𝑎 = 0.356760
Solution: b
Value using 6 terms = 2.716666
Value Using 5 terms = 2.708333
True value = 2.718282
𝑇𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒−𝑉𝑎𝑙𝑢𝑒 𝑜𝑏𝑡𝑎𝑖𝑛𝑒𝑑 𝑢𝑠𝑖𝑛𝑔 6 𝑡𝑒𝑟𝑚𝑠
➔ True percent relative error = 𝜀𝑡 = ∗ 100% =
𝑇𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒
2.718282−2.716666
∗ 100% = 0.059449
2.718282
𝐶𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛−𝑃𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
➔ Approximate percent error = 𝜀𝑎 = ∗
𝐶𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
2.716666−2.708333
100% = ∗ 100% = 0.306736
2.716666

Q: On a hypothetical decimal computer with 5 digit mantissa and 1 digit exponent, operate
the following:
0.12472 ∗ 10−3 ∗ 0.74259 ∗ 102
a) 9.21656*10−1
b) 9.26158*10−2
c) 9.26156*10−2
d) 9.26158*10−3
Solution: d
On multiplication we get, 0.00926158248; which is 9.26158*10−3 by chopping off the extra
digits.

Q: For a 8 bit binary computer with 4 bits for mantissa, 1 bit for number sign, 3 bits for
exponent and 1 bit for exponent sign find the statements that are not true?
a) Largest number that can be stored is 102
b) Increasing the number of bits for exponent will decrease the smallest number
that can be stored
c) Smallest positive number that can be stored is 0.0039
d) Increasing the number of bits for mantissa will decrease the smallest number
that can be stored
Solution: a & d
➔ The largest number for the following system will be
0 0 1 1 1 1 1 1 1
Magnitude of mantissa: (2−1 ∗ 1) + (2−2 ∗ 1) + (2−3 ∗ 1) + (2−4 ∗ 1) =0.9375
Magnitude of exponent: (22 ∗ 1) + (21 ∗ 1) + (20 ∗ 1)= 7
Number obtained will be: 0.9375 × 27 = 120

➔ The smallest number for the following system will be


0 1 1 1 1 1 0 0 0
Magnitude of mantissa: (2−1 ∗ 1) + (2−2 ∗ 0) + (2−3 ∗ 0) + (2−4 ∗ 0) = 0.5
Magnitude of exponent: (22 ∗ 1) + (21 ∗ 1) + (20 ∗ 1)= 7
Number obtained will be: 0.5 × 2−7 =0.00390625
Also, increasing bits for mantissa will not affect the smallest number that can be stored,
however increasing bits for exponent will decrease the smallest number that can be stored.

Q: Which of the following is not a sufficient condition for infinite solutions of a system of
linear equations in two variables?
𝑎11 𝑥 + 𝑎12 𝑦 = 𝑏1
𝑎21 𝑥 + 𝑎22 𝑦 = 𝑏2
a) Det ([A])=0
b) Rank {[A|B]} = Rank {[A]} <2
c) Graph of the two equations is collinear
d) None of the above
Solution: a
Determinant being zero doesn’t guarantee infinite solutions as the conditions also hold for the
case of no solutions.

Q: Which of the following are true for (3415)6 ?


a) For base 10, it is equivalent to 830
b) For base 10, it is equivalent to 803
c) It is equivalent to (1002202)3
d) It is equivalent to (1002022)3
Solution: b & c
For the decimal system the number corresponds to as follows:
Number = (60 ∗ 5) + (61 ∗ 1) + (62 ∗ 4) + (63 ∗ 3) = 803
For Base 3;

Quotient Remainder

803/3 267 2

267/3 89 0

89/3 29 2

29/3 9 2

9/3 3 0

3/3 1 0

1/3 0 1

Hence, the number is (1002202)3

Q: Given a small square matrix with n=13, compute the ratio of floating point operations per
second involved in the back substitution step of using gauss elimination to solve a set of
equations to the total floating point operations per second. (Gauss Elimination)
Solution: FLOPS due to back substitution = n^2

Total FLOPS = 2n^3/3 + n^2


1
Ratio = 2𝑛
(1+ )
3

1. 0.896
2. 0.104
3. 0.448
4. 0.552

Q: Given a small square matrix with n=17, compute the ratio of floating point operations per
second involved in the elimination step of using Thomas algorithm to solve a set of equations
to the total floating point operations per second. (Thomas)

Solution: FLOPS due to elimination = 6*(N-1)

Total FLOPS = 8*(N-1)+1


6
Ratio = 1
(8+ )
𝑁−1

1. 0.744
2. 0.256
3. 0.372
4. 0.628

Q: Solve the following set of questions using iterative method of Gauss Seidel Method with
initial guess as (0,0,0). Calculate number of iterations required until two successive iterations
are identical when rounded to three significant digits.

5x-2y+3z=-1

-3x+9y+z=2

2x-y-7z=3

Solution :-

Total Equations are 3

5x-2y+3z=-1

-3x+9y+z=2
2x-y-7z=3

From the above equations


xk+1=1/5(-1+2yk-3zk)

yk+1=1/9(2+3xk+1-zk)

zk+1=1/-7(3-2xk+1+yk+1)

Iterations are tabulated as below

Iteration x y z
1 -0.2 0.1556 -0.5079
2 0.167 0.3343 -0.4286
3 0.1909 0.3335 -0.4217
4 0.1864 0.3312 -0.4226
5 0.1861 0.3312 -0.4227

1. 4
2. 5
3. 3
4. 6

Q: Derive iteration equations for the Jacobi method to solve

20x + y – 2z = 17

3x + 20y – z = -18

2x – 3y + 20z = 25

Solution :
x = 1/20 (17 – y +2z)
y = 1/20 (-18 -3x + z)
z = 1/20 (25 -2x +3y)

1. x = 1/20 (17 – y +2z)


y = 1/20 (-18 -3x + z)
z = 1/20 (25 -2x +3y)

2. x = 1/3 (-18-20y+z)
y = -1/3 (25-20z-2x)
z = -1/2 (17-20x-y)
3. Cannot find solution. Divergent

4. x = 1/2(25-20z+3y)
y = 17+2z-20x
z = -1(-18-20y-3x)

Q: A steady-state heat balance for a copper wire can be represented as

𝑑2 𝑇
– 0.15T = 0
𝑑𝑥 2

𝑇(0) = 𝑇1 = 240

𝑇(10) = 𝑇2 = 150

Obtain a tridiagonal matrix (suitable for numerical solution) for a wire of L=10-m length. Use
n = 6 i.e. there exist 6 temperatures [T1, T2, T3, T4, T5, T6] .

Solution =

(𝑥6 − 𝑥1) (10 − 0)


∆𝑥 = 𝑁−1 = 5 =2

𝑇(i-1) − 2.6𝑇(i) + 𝑇(i+1) = 0

𝑇(1) =240 and 𝑇(6) =150


𝑇(1) −2.6𝑇(2) +𝑇(3) =0

𝑇(2) −2.6𝑇(3) +𝑇(4) =0

𝑇(3) −2.6𝑇(4) +𝑇(5) =0

𝑇(4) −2.6𝑇(5) +𝑇(6) =0

Using BCs,

1. q1 = -2.6 , q2 = -2.6 , q3 = -2.6, q4 = -2.6

r1 = 1 , r2 = 1 , r3 = 1

p2 = 1 , p3 = 1 ,p4 = 1

s1 = -240 , s2 = 0 , s3 = 0 , s4 = -150

2. q1 = -5.75 , q2 = -5.75 , q3 = -5.75, q4 = -5.75

r1 = 1 , r2 = 1 , r3 = 1

p2 = 1 , p3 = 1 ,p4 = 1

s1 = -240 , s2 = 0 , s3 = 0 , s4 = -150

3. q1 = -2.6 , q2 = -2.6 , q3 = -2.6, q4 = -2.6

r1 = 1 , r2 = 1 , r3 = 1

p2 = 1 , p3 = 1 ,p4 = 1

s1 = -150 , s2 = 0 , s3 = 0 , s4 = -240

4. q1 = -5.75 , q2 = -5.75 , q3 = -5.75, q4 = -5.75


r1 = 1 , r2 = 1 , r3 = 1

p2 = 1 , p3 = 1 ,p4 = 1

s1 = -150 , s2 = 0 , s3 = -240 , s4 = 0

You might also like