CMSC 455/655   Take home exam   due  Nov. 22  2011

   Warning - ALL WORK MUST BE YOUR OWN
             Your work must be submitted by hard copy

              Make sure you read all the instructions

             Show all work that is relevant to your answers
             if you write your own code include it at the end of the
                exam
             You will be graded on the presentation of your material
               even though all work answers may be correct, if your
               presentation is not well done you will lose points.
             
             You are allowed to use any matlab program that you have
             written or that is available on the web.Be sure to check
             out code that is available on our class web site.
             
             label all figures appropriately (e.g. figure 1a ,etc.)
    *********************************************************************8

       Optimization

    1. In this problem you are to find everything you can about the 
       local extrema (max and min) of the function below. You should
       be able to do this by plotting the function and using matlab
       programs available to you.



                z = F(x,y) = z =  3*(1-x)^2.*exp(-(x^2) - (y+1)^2) ... 
                            - 10*(x/5 - x^3 - y^5)*exp(-x^2-y^2) ... 
                            - 1/3*exp(-(x+1)^2 - y^2)   

           

       on the domain    -4 <= x <= 4, -4 <= y <= 4.



       for this function do all of the following steps:

          a) Plot the function as a surface in three dimensional space.

          b) Plot the contours of this function in its specified domain.
             make sure the contours are labelled.

          c) Use the Nelder Mead method to find at least one local extrema
             with a starting triangle of
               (-2,0), (-2,-1), (-1,-1)

 
             use any other initial parameters (tolerances, etc.) that you
             want as long as they are reasonable.

          e) Now use the 'method of steepest descent' to find a local extrema
             starting from the point (0,-1).


       Write up the results of your work up in a very clear manner.

    ---------------------------------------------------------------------

     2.     For the problem

                min  F(x,y,z) = cos(x^2 + y^2 + z^2 +0.5)  over the domain

                 x^2 + y^2 + z^2  <= 10

 
           b) use a method of your choice
              locate the local extrema (at least one). You might use
              the method of steepest descent or an exhaustive 3d mesh search.
              Describe the results of your computations.




    

   ---------------------------------------------------------------------
     Simulation

     Work EXACTLY one of the problems below


      1.  a) Write matlab code that shuffles a 'new' deck of 52 cards-
             using the following type of shuffle
                the deck is split into two equal parts of 26 each 
                and then the cards from each part are interleaved
                (top card from part A then top card from part B
                 then new top card from deck A, etc.)

          b)  Can you think of some quantitative way to measure how 'mixed up'
              (randomized) the cards are at the end of the shuffle?
          
          c)  Now shuffle a new deck five times using the same type of 
              type of shuffle. Now what is your measure of randomness?
    
      --------------------------------------------------------------------
 
      2.  Simulate the modified game of craps where throwing a four on
          the first toss is an immediate loss (2,3,12 become possible
          'points') and throwing a 7 or 11 is an immediate win. After
          the first toss the game proceeds normally -- if you roll your
          point first you win otherwise if you roll seven before your
          point you lose. Run this simulation 10,000 or more times.
              What is the probability of winning?
      --------------------------------------------------------------------

      3.a  Simulate the following situation. Ten men enter a restaurant
          and check their hats with the hat-check girl. She loses the
          hat checks and gives back the hats randomly as the men leave.
          Simulate this situation at least 1000 times.
          What is the probability that at least one man gets his own hat
          back?

        b) Do the same problem with 20 men instead of 10. 




     *****************************************************************

       ODE
              Do EXACTLY one of the problems below

       1. Solve the initial value problem given by 

             x' =  y

             y' = -x     

             x(0) = 1, y(0) = 0
         
               where x'  denotes  dx/dt , etc.

          a) show plots of the solution (x,y) in:

                        (x,y,t) space

                         phase space 

               where t runs from 0 to 10.

     ------------------------------------------------------------------
        2.  Solve the boundary value problem

                  u'' + u = sin(x)  on  [0,1]

            with u(0) = 0  and u(10 = 2

            by the method of finite differences using a mesh of 10
            interior points. Plot the solution.

     --------------------------------------------------------------------

         3. Solve the problem above  (#2)  using the 'shooting method'.
            Plot the solution.
        

     --------------------------------------------------------------------