CU SEC-B-2 Scientific Computing with SageMath/R, 2022

University of Calcutta question paper, B.Sc. Honours Semester IV, 2022. Scientific Computing with SageMath/R. Typed in LaTeX, searchable, with a printable PDF.

Open this paper in MathQP

  1. The output of texttt sqrt(144) and texttt sqrt(8) are
  2. What will be the output of the following sage code? texttt log(sqrt(100 3), 10)
  3. The output of texttt 19/2 - 19//2 + 19%2 in sage is
  4. What happens when texttt '2โ€™ == 2 is executed?
  5. What will be the output of the following sage code? ttfamily for i in range(2.0) : print(i)
  6. Which of the following is the correct code for computing all divisors of 24 ?
  7. What will be the output of the following sage code? ttfamily f(x) = 3 * x + 5 g(x) = x 3 + 1 h(x) = f(g(x)) print h(x) print h(1)
  8. To evaluate sqrt -4 , which one of the following code is correct?
  9. Which one of the following sage commands is not correct to get the derivative of sin (x 2) ?
  10. Which one of the following sage codes is correct?
  11. Give an example to show sage can be used as a calculator.
  12. What will be the output of the following sage code? State the reason : ttfamily r = 30 area = pi *r 2 print(area)
  13. Write the sage commands to calculate the expression 500 , frac bigl [1 - (1+0.05) -30 bigr ] 0.05
  14. Write built-in sage commands to find the common logarithm of sqrt 100 3 . Justify that sage will give the exact answer.
  15. Write sage commands to evaluate the following expressions : Value of sqrt [20] e + sqrt [e] 20 in 20 decimal places, the absolute numerical value of dfrac pi frac 22 7 - 1 in 50 decimal places, the value of sqrt 3 + sqrt 3 + sqrt 3 + frac 1 3 in 10 digits.
  16. Give the output of the following sage commands. texttt 27 (1/3) , texttt 64 (1/4) , texttt (2 10) (1/3) , texttt 8 (1/3) + 16 (1/4).n()
  17. How can you plot functions with their asymptotes in sage? Explain for the function f(x) = tan (x) for - pi < x < pi .
  18. Plot the graph of f n(x) = sin n(x) in sage in the interval [0, pi ] for n = 1, 2, dots , 4 . Use different colors and different plot styles for different graphs.
  19. Write sage code to plot a 5 -pedaled rosette, r( theta ) = 2 cos 5 theta , quad 0 < theta < 2 pi In the above plotting which one is the input and which one is the output?
  20. Correct the following sage code : texttt plot(sin(t), -10, 10)
  21. How can you plot piecewise functions in sage? Give examples.
  22. Write sage code to find the first two derivatives of f(t) = ln (1+t 2) and plot them along with the graph f(t) . Use different colors for different graphs.
  23. Differentiate f(x) = 1/x 2 with sage using the definition of derivative in (0, infty )
  24. Write sage code to evaluate displaystyle int - infty infty x 2 e -x 2 ,dx .
  25. Write sage code to evaluate displaystyle int 0 1 frac sqrt x + sqrt x 2 + 1 (x+1) ,dx .
  26. Write sage code to integrate the function sin (x 2 + y 2) with respect to x and print the result.
  27. Write a program in sage to find the area of a circle whose perimeter is P in 30 decimal places.
  28. Write a program in sage without using inbuilt function to print first 20 non-fibonacci positive integers.
  29. Explain for loop construction giving an appropriate example in SageMath.
  30. Write a sage function to check whether a number taken from the user is prime or not.
  31. Find the syntax error in the following code written in sage and correct it. ttfamily x = 1 while x leq 10 print x * 5
  32. Define a matrix A whose rows are (11, 30, 40, 70) , (30, 40, 70, 90) , (30, 70, 0, 101) , (10, 30, -40, 80) .
  33. Display the matrix and find the row sums and column sums.
  34. Compute the determinant of the matrix.
  35. Find B = AA t and C = A - A t .
  36. Test to show that the matrix B is symmetric and C is skew-symmetric.
  37. Write sage code to find the solution of the differential equation dfrac dy dx = 3x 2 . Write also the output. Write the sage code to plot the solution curves corresponding to three suitable choices of the arbitrary constants.
  38. Write sage code to solve the following initial value homogeneous (IVP) : 4 frac d 2 y dx 2 + 4 frac dy dx + 17y = 0, quad y(0) = -1, quad y'(0) = 2 Also plot the solution curve.
  39. Write a sage program to yield a numerical approximation of u n for n = 20 , where u 0 = 1 , u n+1 = frac 1 1 + u n 2 , quad n in mathbb N
  40. Using in-built function in sage find the mode of the following numbers : 1, 1, 2, 3, 1, 3, 3, 5 . Also find how many times the mode has occured.
  41. texttt sage : s = 0 texttt sage : for k in [1..3] texttt sage : s = s+k texttt sage : s = 2*s texttt sage : s
  42. texttt sage : s = 0 texttt sage : for k in [1..3] texttt sage : s = s+k texttt sage : s = 2*s texttt sage : s
  43. Using sage code, create an adding machine that will keep on asking the user for numbers, add them together and show the total after each step. Terminate when user enters a zero.
  44. Write sage code to solve the following polynomial equation : 3 2(x 2 + x + 1) - x 2 - 3x + 2 = 0
  45. Write sage code to compute the number of zeros and the number of ones present in log (2022!) (where 2022! means factorial of 2022 ).
  46. What should we type to get the value of sin (45 circ ) in R?
  47. What will be the output of the following R code? texttt Options (digits = 4) 10/3
  48. What is the output of the code given below? ttfamily A = 10 B = 20 print (A, B)
  49. What is the meaning of โ€œ texttt <- โ€?
  50. Which of the following code generate a sequence of integers from 1 to 10 ?
  51. What is the output of texttt trunc(-9.8) in R?
  52. Which of the following is the correct outcome of the following? ttfamily x = 3 while (x<15) x=5*x-10; if (x==20) break; print (5*x);
  53. Which of the following is the correct output of texttt Y[X[3]] and texttt X[Y[7]] respectively of the following commands : ttfamily Y = C (42, 53, 33, 45, 61, 27, 30) X = C (3, 1, 2, 4, 7, 9, 8)
  54. What will be the outcome of the following command? texttt C(1/243, 1/81, 1/64) C(-1/5, -1/4, -1/2)
  55. What should we type to find the value of displaystyle int 0 1 (x 3 + 2x) ,dx in R?
  56. texttt a = 7; b = 6; a = a 3-b 2; b = (a+3); b
  57. texttt a = 1 : 5; a = a/2; a
  58. texttt a = 20; a = (a/2) 3; a = (a) (1/3); a
  59. texttt A = matrix (c(2, 4, 6, 7), nrow = 2); texttt B = matrix (c(3, 5, 7, 8), nrow = 2); texttt X = A+B; X
  60. texttt x = 5:3; x = x 2+1; x
  61. texttt x = 7:3; x = x 2+2; x = length(x); x
  62. texttt A = matrix (C(1, 2, 3, 4), nrow = 2); texttt B = matrix (C(4, 3, 2, 1), nrow = 2) texttt X = A%*%B; X.
  63. Write a R code to plot graph of the function f(x) = e x 2 + log e x - tan -1 x in the range (3, 5) with blue color and with proper x -label and y -label.
  64. Let, runs of a batsman in last 5 innings are : 51, 18, 99, 76 and 05 . Write a R code to compare his runs per innings using a pie-chart, bar diagram and scatter plot, in a single figure.
  65. the graph of polar curve r = 1 + cos theta , 0 leq theta leq pi .
  66. the following functions in one plot : f(x) = 1+x, -1 leq x leq 0 1+x 2, 0 < x < 1
  67. find f''(x)
  68. find f'''(x)
  69. plot f''(x) and f'''(x) in (-2, 2) with red and green colors respectively in one plot.
  70. Write a R program to tabulate values of the function f(x) = x 5 - 9x + 3 along with its derivative in the interval [-5, 5] with the increment value 0.2 .
  71. displaystyle int 0 3 (5x 3 + 3x) ,dx
  72. displaystyle int 0 infty frac 3 sqrt pi e -x 2 ,dx
  73. displaystyle int 0 1 frac sin x x ,dx
  74. Without using inbuilt functions, write R code to find the geometric mean and mode of the data set texttt C(2, 1, 3, 2, 5, 3, 2, 4, 2, 1, 6) .
  75. Without using inbuilt functions write a program in R to determine the total number of primes less than x , print the list of such primes and get an output for x = 79 .
  76. Write a R program to find sum of 1 3 + 2 3 + dots + 100 3 .
  77. Write a R program to find the factors of 100 and find the sum of the factors.
  78. check if A is orthogonal.
  79. check if inverse of A exist, and if so, check if A = A -1 .
  80. select even elements of A and change them to 0 .
  81. Define a matrix in R whose rows are (1, 7, 4, 3) , (3, 5, 8, 9) , (3, 7, 1, 1) , (1, 2, 1, 2) . Give R code to find the row reduced echelon form of the matrix.
  82. Solve the following system of equations by a R program : 2x + y + z = 7 x + y - 8z = -5 3x - 4y + 5z = 14
  83. Write R code to solve the following differential equation with the boundary conditions : x 0 = 0, ; y(x 0) = 1, ; x 1 = frac pi 2 , ; y(x 1) = 4 frac d 2 y dx 2 + y = 0
  84. Write a R code to solve the differential equation dfrac dy dx = sin x .
  85. Write a program in R to find the greatest of three given integers a, b, c .
  86. Write a R program to find roots of a quadratic equation ax 2 - bx - c = 0 .
  87. Write a R program to find area of a square inscribed in a circle of radius r .