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

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

Open this paper in MathQP

  1. What is the correct code in Sage to evaluate the value of pi correct up to 100 digits?
  2. What will be the result of the following Sage code: texttt exp(11*8+5) - e (11*8+5) ?
  3. What will be your code in Sage to find the natural logarithm of 100 in decimal approximation?
  4. What will be your code in Sage, if you want all the square roots of 4 ?
  5. The output of the Sage code : texttt 4*(10//4) + 10%4 == 10, 3*3<3 is
  6. Which of the following is NOT the correct option for a b c in sage?
  7. What will be the output of the following sage code? ttfamily a=4 b=2 print(a+b*2)
  8. What will be the output of the following sage code? ttfamily a =[1, 3] b=[10, 20, a] print(b)
  9. What is the correct code in Sage to plot the function x 3 - x in -2 < x < 2 ?
  10. What will be the code in Sage to compute displaystyle int 0 1 frac x x 2+1 ,dx ?
  11. What are open source softwares? “Sage is a free and open source mathematical software.” — Explain in brief.
  12. Write sage codes to find the difference between golden ratio and dfrac f 42 f 41 using 20 digits where f n is the n th term of the Fibonacci sequence.
  13. What will be the output of the following sage commands? Explain your answer : texttt y = 3; y = 3 * y + 1; y = 3 * y + 1; y
  14. What will be the output of the following sage commands?
  15. Give the output of the following sage commands texttt 10 (1/2), sin(60)
  16. graph of the function f(x) = x 2 + 1 in the range (-2, 2) .
  17. graph of the tangent line to the above curve : f'(x) = 2x in the range (-2, 2) with gridlines.
  18. one big dot at (1, 2) with size = 40 .
  19. Write sage code to plot the graph of the function given by the polar curve r = 1 + 2 cos 3 theta , quad 0 leq theta leq 2 pi .
  20. Write sage code to plot the graph of the following function : f(x) = 1+x, -1 leq x leq 0 1+x 3, 0 < x < 1 .
  21. Write sage code to plot the function f(x) = dfrac 1 x - x in [-1, 1] . Write also the equation of the asymptote (if it exists).
  22. find f''(x) .
  23. find f'''(x) .
  24. draw the graph of f(x) where -5 < x < 5 with colour blue.
  25. draw the graph of f''(x) where -5 < x < 5 with colour green.
  26. draw the graph of f'''(x) where -5 < x < 5 with colour red.
  27. Evaluate displaystyle int x n ,dx
  28. Evaluate displaystyle int frac cos x sqrt 1+ sin x ,dx
  29. Evaluate displaystyle int 0 1 3x 2 ,dx
  30. Evaluate displaystyle int 0 infty frac 2 sqrt pi e -x 2 ,dx
  31. Evaluate displaystyle int 0 infty frac sin x x ,dx to display 10 digits.
  32. Without using inbuilt functions write a program in sage to determine the total number of primes less than x , print the list of such primes and get an output for x = 98 .
  33. Without using inbuilt function write a program in sage to determine factorial of 10 .
  34. Without using inbuilt functions write a program in Sage to determine in decimal approximation the arithmetic mean and geometric mean of a list of numbers and get an output for the list 20, 15, 24, 31, 45, 17 .
  35. Write the Sage codes (without using inbuilt functions) to find and print the median of the numbers 11, 23, -34, 40, 50 .
  36. Define a matrix in sage whose rows are (1, -3, 4, 7) , (3, 4, 7, 9) , (3, 7, 0, 11) , (1, 3, -4, 8) . Give sage code to find the row reduced echelon form of the matrix.
  37. Write code in sage to find det A and A -1 where A = 1 2 3 4 5 6 7 8 10 .
  38. Assuming the non-trivial solution exists, write sage commands to solve the following system of equations with matrices : 3x - 4y + 5z = 14 x + y - 8z = -5 2x + y + z = 7.
  39. Write sage code to solve the differential equation dfrac dy dx = cos x .
  40. Write sage commands to solve the following Initial Value Problem and plot the solution : frac dy dx = 1 - y, quad y(10) = 2
  41. Write sage commands 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.
  42. Write a program in sage to find the GCD of two numbers a, b using Euclidean Algorithm.
  43. Write sage code for the following : Find the number of digits in 2021! and compute the number of zeros and the number of ones present in 2021! . [Here 2021! means factorial of 2021.]
  44. Write your code in sage to find the root of the polynomial f(x) = x 5 + x 4 + x 3 - x 2 + x - 1 between -1 and 1 .
  45. Write a program in sage to find the greatest of three given integers a, b, c .
  46. Write a program in sage to find the sum of the following series for any finite n : 2 cdot 3 + 4 cdot 5 + 6 cdot 7 + cdots + 2n(2n+1).
  47. Consider the following program : ttfamily i=0 while i < 5: print(i) i=i+1 if i==3: break else: print(0) What will be the output of the program segment?
  48. What should we type to get the value of tan (90 circ ) in R?
  49. The value of factorial of 3 91 in R is
  50. Which of the following R codes will print “Hello, world”?
  51. What will be the output of the following R code? ttfamily > f <- function (a, b) + a 2 + > f (2)
  52. What will be the output of the following R code snippet? ttfamily > paste (“a”, “b”, se = “:”)
  53. The output of the following R program will be : ttfamily > n <- 0 > square <- 0 > while (square <= 100) + n <- n + 1 + square <- n 2 + > print(n) > print(square)
  54. What will be the output of the following R code? ttfamily options (digits = 16) 20/6
  55. Which one of the following is the correct command to obtain the following matrix? A = 20 25 30 20 15 10
  56. How does a vector differ from a list?
  57. What is the output of the code given below? ttfamily A=10 B=20 print(A,B)
  58. texttt x=5;y=2; x=x 2+y 2; y=(x+1)/5; y
  59. texttt x=1:7; x=x+3; x
  60. texttt x=8; x=(x+1)**2; x=sqrt(x); x
  61. texttt A=matrix(c(1,2,3,4), nrow=2);B=matrix(c(4,3,2,1), nrow=2) texttt X=A*B+2; X
  62. texttt x=7:2 ; x=x 2+1; x
  63. texttt x=7:2; x=x 2+2; x=length(x);x
  64. texttt A=matrix(c(1,2,3,4), nrow=2);B=matrix(c(-4,3,-2,1), nrow=2) texttt X=A%*%B+2; X
  65. graph of the function f(x) = x 2 + 1 in range (-2, 2)
  66. graph of the tangent line f'(x) = 2x in range (-2, 2) at the point (1, 2) .
  67. the graph of polar curve r = 1 + 2 cos ( theta ), quad 0 leq theta leq 2 pi
  68. f(x) = |x| + 1 , in -2 leq x leq 2 with blue color
  69. g(x) = sin (x) + 2 cos (x) , in -2 leq x leq 2 with red color.
  70. find f'(x)
  71. find f''(x)
  72. plot f'(x) and f''(x) in [-2, 2] with blue and green colors respectively.
  73. displaystyle int - infty + infty e -x 2 ,dx
  74. displaystyle int - pi + pi sin (5x) ,dx
  75. displaystyle int - pi /4 + pi /4 tan (x) ,dx
  76. displaystyle int - pi /4 + pi /4 e x cdot tan (x) ,dx
  77. displaystyle int -1 +1 frac (1+x 3) (1+x 2) ,dx .
  78. Without using inbuilt functions, write R code to find the mean and median of the data set texttt c(3,4,7,1,7,4,8,9,10,11,2,12).
  79. Without using inbuilt functions, write R code to find GCD and LCM of the numbers 12 and 75.
  80. to find A 3
  81. to find the determinant and the inverse of A
  82. to find the inverse of A as well as to check whether the result is correct.
  83. Solve the following system of equations by a R program : 4x + y - z = 3 2x + 7y + z = 19 x - 3y + 12z = 31.
  84. Write a R program to find roots of the polynomial x 7 + 3x 4 + 8x + 9 .
  85. Write a R program to print first n non-Fibonacci positive integers.
  86. Write a R program to print all the prime numbers in the interval [131, 291] .
  87. Write a R program to find the sum of the series : 1 2 + 2 2 + 3 2 + cdots + N 2.
  88. Discuss how we can solve the differential equation : dfrac dx dt = 1 - x using R commands. Also write the code for plotting the solution in a specific range.