using-sage/questions.rst
author Nishanth <nishanth@fossee.in>
Tue, 12 Oct 2010 10:36:46 +0530
changeset 329 5c8e88276e1f
parent 302 04fc3e7a0480
child 361 a28d592851b4
permissions -rw-r--r--
input_output is now complete

Objective
---------

1. How do you find the limit of the function ``x/sin(x)`` as ``x`` tends to
   ``0`` from the negative side.

   Answer: lim(x/sin(x), x=0, dir="below")

#. Find the third differential of the function ``exp(sin(x)*cos(x^2))``
 
   Answer: diff(exp(sin(x)*cos(x^2), x, 3)

#. Solve the system of linear equations::

     x-2y+3z = 7
     2x+3y-z = 5
     x+2y+4z = 9

   Answer::

     A = Matrix([[1, -2, 3], 
                 [2, 3, -1], 
                 [1, 2, 4]])

     b = vector([7, 5, 9])

     solve_right(A, b)

#. How do you get the factorized form of ``x^4 - 4x^2 + x^3 + 2x + 7`` 

   Answer::

      factor( x^4 + x^3 - 4*x^2 + 2*x + 7 )

#. list all the primes between 2009 and 2900

   Answer: prime_range(2009, 2901)

#. Which function is used to check primality

   a. isPrime
   #. isprime
   #. is_prime
   #. prime

   Answer: is_prime

#. How do you list all the combinations of ``[1, 2, 3, 4]``


   Answer::

     c1 = Combinations([1, 2, 3, 4])
     c1.list()

#. How do you list all the permutations of ``[1, 3, 2, 3]``

    Answer::

      p1 = Permutations([1, 3, 2, 3])
      p2.list()


Programming
-----------

1. What is the out put of the following code::

     c1 = Combinations([1, 2, 3, 4])
     c2 = Combinations([1, 2, 4, 3])

     l1 = c1.list()
     l2 = c2.list()

     for i in l2:
         l1.remove(i)

     print l2

   Answer: []