You are on page 1of 2

Numerical Computing - B. Math.

I
Assignment 2 — 2nd Semester 2023-2024

Due date: 28 January, 2024


Note: Total number of points is 20. Two questions out of the five below will be graded
(the choice is upto me but uniform for all students). There are 4 points for completion.
Plagiarism is prohibited. But after sustained effort, if you cannot find a solution, you may
discuss with others and write the solution in your own words only after you have understood
it.

1. (8 points) Check the output and explain the following commands in OCTAVE:

(i) [1 : 4; 5 : 8] and [1 : 4, 5 : 8]
(ii) [10, 12; 13, 14] ∗ eye(2)
(iii) [1, 2; 3, 4]. ∧ 3 and [1, 2; 3, 4] ∧ 3
(iv) disp(ones(3)) and disp ones(3)
(v) x = −3 : 3, x(0), x(1), x[0], ansd x[1]
(vi) x(2, :) and x(:, 2) if x = reshape(1 : 9, 3, 3)
(vii) linspace(1, 10, 80) and logspace(1, 4, 4)
(viii) sin(π) and sin(10000π)

2. (8 points) Use linspace function to create vectors identical to those obtained with the
statements that follow. Use multiple statements where necessary. Write a command
that will test if the vector you produced and the vector given below are equal.

(i) x = 0 : 10
(ii) x = 0 : 0.2 : 10
(iii) x = −12 : −12
(iv) x = 10 : −1 : 1
 
11 5
3. (8 points) Given the matrix C =  2 1, write two OCTAVE statements to create
 

18 7
the column vectors u = (11, 2, 18) and v = (5, 1, 7)T by extracting the columns of C.
T

Write OCTAVE statements to compute the inner product of the vectors u and v, and
the transpose of C.

Statistics and Mathematics Unit, Indian Statistical Institute Page 1 of 2


Soumyashant Nayak: soumyashant@isibang.ac.in
Numerical Computing - B. Math. I: Sheet 2— 2nd Semester 2023-2024
 
  1 0 0 0 1
2 −1 0 0  
2 8 14 20 −1 1 0 0 1
 
 
−1 2 −1 0   
 0 −1 2 −1 , M = 4 10 16 22  , T = −1 −1 1
4. (8 points) Let D =  0 1.
   
6 12 18 −24 −1 −1 −1 1 1
   
0 0 −1 2
−1 −1 −1 −1 1
(a) (2 points) Use diag function to create D
(b) (2 points) Write a one-line expression to create T
(c) (4 points) Use the reshape function and colon notation to create M .

5. (8 points) Plot (separately) the functions sin θ, cos θ for 50 points in [0, 2π]. Connect
the points with a dashed line and create a x-axis label θ and y-axis label sin(θ). Do the
same for the function log x, exp(x) for 100 points in [0.01, 3].

Statistics and Mathematics Unit, Indian Statistical Institute Page 2 of 2


Soumyashant Nayak: soumyashant@isibang.ac.in

You might also like