using-sage/questions.rst
changeset 302 04fc3e7a0480
parent 217 b595f90016c5
child 361 a28d592851b4
equal deleted inserted replaced
301:af48ecb4dc11 302:04fc3e7a0480
     1 Objective
     1 Objective
     2 ---------
     2 ---------
     3 
     3 
     4 .. A mininum of 8 questions here. 
     4 1. How do you find the limit of the function ``x/sin(x)`` as ``x`` tends to
       
     5    ``0`` from the negative side.
     5 
     6 
     6 1. Question 1
     7    Answer: lim(x/sin(x), x=0, dir="below")
     7 2. Question 2
     8 
     8 3. Question 3
     9 #. Find the third differential of the function ``exp(sin(x)*cos(x^2))``
       
    10  
       
    11    Answer: diff(exp(sin(x)*cos(x^2), x, 3)
       
    12 
       
    13 #. Solve the system of linear equations::
       
    14 
       
    15      x-2y+3z = 7
       
    16      2x+3y-z = 5
       
    17      x+2y+4z = 9
       
    18 
       
    19    Answer::
       
    20 
       
    21      A = Matrix([[1, -2, 3], 
       
    22                  [2, 3, -1], 
       
    23                  [1, 2, 4]])
       
    24 
       
    25      b = vector([7, 5, 9])
       
    26 
       
    27      solve_right(A, b)
       
    28 
       
    29 #. How do you get the factorized form of ``x^4 - 4x^2 + x^3 + 2x + 7`` 
       
    30 
       
    31    Answer::
       
    32 
       
    33       factor( x^4 + x^3 - 4*x^2 + 2*x + 7 )
       
    34 
       
    35 #. list all the primes between 2009 and 2900
       
    36 
       
    37    Answer: prime_range(2009, 2901)
       
    38 
       
    39 #. Which function is used to check primality
       
    40 
       
    41    a. isPrime
       
    42    #. isprime
       
    43    #. is_prime
       
    44    #. prime
       
    45 
       
    46    Answer: is_prime
       
    47 
       
    48 #. How do you list all the combinations of ``[1, 2, 3, 4]``
       
    49 
       
    50 
       
    51    Answer::
       
    52 
       
    53      c1 = Combinations([1, 2, 3, 4])
       
    54      c1.list()
       
    55 
       
    56 #. How do you list all the permutations of ``[1, 3, 2, 3]``
       
    57 
       
    58     Answer::
       
    59 
       
    60       p1 = Permutations([1, 3, 2, 3])
       
    61       p2.list()
     9 
    62 
    10 
    63 
    11 Programming
    64 Programming
    12 -----------
    65 -----------
    13 
    66 
    14 .. A minimum of 2 questions here. 
    67 1. What is the out put of the following code::
    15 
    68 
    16 1. Programming Assignment 1
    69      c1 = Combinations([1, 2, 3, 4])
    17 2. Programming Assignment 2
    70      c2 = Combinations([1, 2, 4, 3])
       
    71 
       
    72      l1 = c1.list()
       
    73      l2 = c2.list()
       
    74 
       
    75      for i in l2:
       
    76          l1.remove(i)
       
    77 
       
    78      print l2
       
    79 
       
    80    Answer: []
       
    81