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
- The output of texttt sqrt(144) and texttt sqrt(8) are
- What will be the output of the following sage code? texttt log(sqrt(100 3), 10)
- The output of texttt 19/2 - 19//2 + 19%2 in sage is
- What happens when texttt '2โ == 2 is executed?
- What will be the output of the following sage code? ttfamily for i in range(2.0) : print(i)
- Which of the following is the correct code for computing all divisors of 24 ?
- 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)
- To evaluate sqrt -4 , which one of the following code is correct?
- Which one of the following sage commands is not correct to get the derivative of sin (x 2) ?
- Which one of the following sage codes is correct?
- Give an example to show sage can be used as a calculator.
- What will be the output of the following sage code? State the reason : ttfamily r = 30 area = pi *r 2 print(area)
- Write the sage commands to calculate the expression 500 , frac bigl [1 - (1+0.05) -30 bigr ] 0.05
- Write built-in sage commands to find the common logarithm of sqrt 100 3 . Justify that sage will give the exact answer.
- 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.
- 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()
- How can you plot functions with their asymptotes in sage? Explain for the function f(x) = tan (x) for - pi < x < pi .
- 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.
- 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?
- Correct the following sage code : texttt plot(sin(t), -10, 10)
- How can you plot piecewise functions in sage? Give examples.
- 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.
- Differentiate f(x) = 1/x 2 with sage using the definition of derivative in (0, infty )
- Write sage code to evaluate displaystyle int - infty infty x 2 e -x 2 ,dx .
- Write sage code to evaluate displaystyle int 0 1 frac sqrt x + sqrt x 2 + 1 (x+1) ,dx .
- Write sage code to integrate the function sin (x 2 + y 2) with respect to x and print the result.
- Write a program in sage to find the area of a circle whose perimeter is P in 30 decimal places.
- Write a program in sage without using inbuilt function to print first 20 non-fibonacci positive integers.
- Explain for loop construction giving an appropriate example in SageMath.
- Write a sage function to check whether a number taken from the user is prime or not.
- Find the syntax error in the following code written in sage and correct it. ttfamily x = 1 while x leq 10 print x * 5
- Define a matrix A whose rows are (11, 30, 40, 70) , (30, 40, 70, 90) , (30, 70, 0, 101) , (10, 30, -40, 80) .
- Display the matrix and find the row sums and column sums.
- Compute the determinant of the matrix.
- Find B = AA t and C = A - A t .
- Test to show that the matrix B is symmetric and C is skew-symmetric.
- 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.
- 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.
- 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
- 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.
- texttt sage : s = 0 texttt sage : for k in [1..3] texttt sage : s = s+k texttt sage : s = 2*s texttt sage : s
- texttt sage : s = 0 texttt sage : for k in [1..3] texttt sage : s = s+k texttt sage : s = 2*s texttt sage : s
- 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.
- Write sage code to solve the following polynomial equation : 3 2(x 2 + x + 1) - x 2 - 3x + 2 = 0
- Write sage code to compute the number of zeros and the number of ones present in log (2022!) (where 2022! means factorial of 2022 ).
- What should we type to get the value of sin (45 circ ) in R?
- What will be the output of the following R code? texttt Options (digits = 4) 10/3
- What is the output of the code given below? ttfamily A = 10 B = 20 print (A, B)
- What is the meaning of โ texttt <- โ?
- Which of the following code generate a sequence of integers from 1 to 10 ?
- What is the output of texttt trunc(-9.8) in R?
- 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);
- 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)
- What will be the outcome of the following command? texttt C(1/243, 1/81, 1/64) C(-1/5, -1/4, -1/2)
- What should we type to find the value of displaystyle int 0 1 (x 3 + 2x) ,dx in R?
- texttt a = 7; b = 6; a = a 3-b 2; b = (a+3); b
- texttt a = 1 : 5; a = a/2; a
- texttt a = 20; a = (a/2) 3; a = (a) (1/3); a
- 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
- texttt x = 5:3; x = x 2+1; x
- texttt x = 7:3; x = x 2+2; x = length(x); x
- 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.
- 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.
- 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.
- the graph of polar curve r = 1 + cos theta , 0 leq theta leq pi .
- the following functions in one plot : f(x) = 1+x, -1 leq x leq 0 1+x 2, 0 < x < 1
- find f''(x)
- find f'''(x)
- plot f''(x) and f'''(x) in (-2, 2) with red and green colors respectively in one plot.
- 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 .
- displaystyle int 0 3 (5x 3 + 3x) ,dx
- displaystyle int 0 infty frac 3 sqrt pi e -x 2 ,dx
- displaystyle int 0 1 frac sin x x ,dx
- 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) .
- 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 .
- Write a R program to find sum of 1 3 + 2 3 + dots + 100 3 .
- Write a R program to find the factors of 100 and find the sum of the factors.
- check if A is orthogonal.
- check if inverse of A exist, and if so, check if A = A -1 .
- select even elements of A and change them to 0 .
- 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.
- Solve the following system of equations by a R program : 2x + y + z = 7 x + y - 8z = -5 3x - 4y + 5z = 14
- 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
- Write a R code to solve the differential equation dfrac dy dx = sin x .
- Write a program in R to find the greatest of three given integers a, b, c .
- Write a R program to find roots of a quadratic equation ax 2 - bx - c = 0 .
- Write a R program to find area of a square inscribed in a circle of radius r .