COMPUTER ALGEBRA WITH MATHEMATICA - DOC - DOC by X1OoHG9

VIEWS: 7 PAGES: 4

									  COMPUTER ALGEBRA WITH MATHEMATICA

    The sessions with Mathematica are intended to be self-contained, with all the instructions
    you need available on the computer screen and in the lecture/demonstration periods. These
    notes are just meant to help to get you started, and to remind you of a number of key points.

GETTING STARTED
     Log on to WTS, locate and double-click on the Mathematica icon.


The MATHEMATICA examples
    The files which you will be using should be copied from the World-Wide Web. Point your
    web browser at Tony Harker’s home page (http://www.cmmp.ucl.ac.uk/~ahh/)
    and follow the links to the Mathematica page. Make copies of the Mathematica files in your
    own workspace. The first collection of files you should download consists of a set of
    familiarisation exercises:

    uclintro.nb      An introduction to Mathematica and what it can do
    graph.nb         Graphics and the visualization of functions
    diffeq.nb        Ordinary differential equations
    numer.nb         Numerical analysis

    You should run through all of the above, to see what sort of things Mathematica can do and,
    more importantly, to get used to the command syntax. There are some simple exercises
    embedded in these files, which you should tackle with as much help as you need from the
    demonstrators. Your log-book (see below) should contain records of these exercises.

     In addition, there are two short tests, two short programming exercises, and a longer
    programming problem to be completed as part of the assessment of the course. The relevant
    files are:
      test1.nb Deadlines: Wednesday 16th October/Wednesday 20th November;
      test2.nb Deadlines: Wednesday 23rd October/Wednesday 27th November.
    I will tell you when these files are available.

      image.nb           A simple image analysis exercise
      plotfield.nb More complex plots and pictures.
      final.nb           The Schrodinger equation for a finite potential well
                         Deadlines: Friday 8th November/Friday 13th December.
    The deadlines for the image analysis, complex plot, and final exercise are also the deadlines
    for handing in laboratory notebooks.

    You might also be interested to see a couple of other examples of the use of Mathematica,
    but note that these do not form part of the assessed course.



                                                 1
     animation.nb A simple example of an animated graph
     datafit.nb    How to fit experimental data using Mathematica
     Huygens.nb    Huygens’s principle and beyond: diffraction
     ising.nb      A study of statistical problems in magnetism.
     Nacl.nb       Drawing a crystal structure
     Pendulum.nb   A double pendulum analysed, with animation
     Phase.nb      Simple introduction to phase space plots
     varia.nb     The variational principle and perturbation theory in quantum mechanics
                  applied to the helium atom

THE NOTEBOOK CONCEPT
       What you see on the screen is controlled by a Windows package called the Mathematica
     Front End (MFE). This serves as an interface between you and the program which does the
     computation, the Mathematica Kernel (MK). MK runs as a separate task. In principle it is
     possible to have several copies of MK running simultaneously, but as MK is quite a large
     program, and can require large amounts of memory, it is more usual to work with only one
     active copy. It is also possible to have MFE running on one machine connected to MK on
     another. In this case, we will run one copy of MFE, one copy of MK, on a single PC for
     each user.
       Interaction through MFE is divided into blocks, for formatted text (essentially, comments),
     expression input, and output.
       Each block of work which is done in Mathematica, which will be a mixture of these types
     of block, may be kept together in a 'notebook'. When Mathematica is loaded, it starts one
     copy of MFE running and opens a new notebook. When it is asked to do a computation
     (rather than just handling text) it will start MK - as a result the first computation will always
     appear to take rather a long time.

       The MFE notebook has some similarities with a hand-written notebook, but also enough
     differences to make the analogy a tricky one. For example, once an expression has been
     typed into a notebook and the SHIFT+RETURN key combination has been pressed, it is
     passed to MK where it is executed, and the result is returned to MFE. If the expression had
     been previously executed, then the result of that execution would be deleted as soon as the
     return key was pressed. It is vital to remember that MK has no way of knowing where the
     input expression was on the notebook: it is the order in which the expressions are passed to
     MK that matters. Another point to be wary of is that if you work with more than one
     notebook but one copy of MK then if you alter, say, the value of x in one notebook then that
     is the current value of x as far as MK is concerned, and it is the value that will be returned
     to either notebook - MK does not keep a separate copy of x for each notebook.


Opening a Notebook
      The usual Windows File/Open operation will open an existing Notebook.

Saving your Work
      As with any computer-based activity, you should save your work frequently. Mathematica
     does not have an autosave feature, so if the system crashes you will lose all the work since
     the last time you forced a save. Be aware of the fact that under WTS Mathematica may not


                                                    2
    close the file cleanly if you run out of disk quota. Also note that the way in which
    Mathematica stores graphical images is very expensive on disk space. It is sometimes a
    good idea to click Kernel/Delete All Output before saving: this will save all the
    commands in your notebook, but not the output, and will therefore need much less disk
    space. You can easily get back to where you were by reloading the file and clicking
    Kernel/Evaluate Notebook.


IF THINGS GO WRONG
     Problems can be divided into two categories - your errors and Mathematica's problems.
     The most likely errors you are likely to make are simple typing errors. To correct such
    mistakes, simply select the appropriate input section, correct the input, and press
    SHIFT+RETURN again. Note that the automatic numbering which Mathematica applies to
    input and output means that once your previous attempt has been overwritten with the new
    one the sections in your notebook will no longer be in consecutive numerical order.

    The Mathematics Kernel itself is fairly robust, both in the code itself and in the reliability of
    its mathematics. It does, however, have to indulge in memory management to clear old
    expressions from its memory and to request more memory for new calculations. Very large
    calculations can get bogged down in this process, and end up by asking for more memory
    than the computer has. Collapse under these circumstances may be gentle (the system exits
    gracefully with a message saying that it has run out of memory) or disastrous. If you need to
    be reassured that Mathematica is still working, look at the bars on the right of the screen. If
    the bar next to one or more cells is darkened, then MK is still busy.
      You should be able to run through all the notebooks without encountering these problems,
    but it is better to be forewarned.
      You may also find the guidelines to debugging helpful (see the link on the web page).
      If you are unfortunate enough to have a file corrupted when trying to save it, let me know. I
    can sometimes recover some or all of your work – though it takes a bit of time.



PRINTING
     You should not find it necessary to print out the whole of every notebook on which you
    work. On the other hand you may wish to preserve some graphs to supplement the records
    in your laboratory notebooks.

LEAVING MATHEMATICA
     The usual Windows sequence of File/Exit will take you out.


LABORATORY NOTEBOOKS FOR THE MATHEMATICA SESSIONS
    The content of a laboratory notebook for the Mathematica sessions will, of course be
    somewhat different from that for more conventional experimental sessions. Nevertheless,
    the same guiding principles apply. The record must contain enough detail to allow you to
    retrieve all the work done: a good way of thinking about this is to imagine that at some
    future point you might want to repeat exactly the same calculation, so that you must note all


                                                   3
   the quantities that you type as input to the program, and any other factors that you think
   might influence the result you are recording (for example, if you are finding out how long a
   calculation takes you will need to know at the very least what processor, clock speed and
   memory are installed on the machine you are using).

   The record must be compiled in your laboratory notebook as work proceeds. As well as
   numerical input and results, your notebook should contain notes you write down in response
   to the problems posed in the Mathematica sessions. Should the Mathematica session
   misbehave in any way, you should record as much detail as possible about the problems
   encountered. If there are points about the operation of the program about which you have to
   ask a demonstrator, record the details - just as you would record any quirks of a piece of
   experimental apparatus.

COURSE ASSESSMENT
   The final course mark will comprise 15% for each of the two tests, 5% for the image
   analysis exercise, 10% for the complex graphics exercise, 40% for the final programming
   exercise, and 15% for the laboratory notebook. The tests will be returned to you during the
   sessions, so that I can comment individually on your answers. Nevertheless it is essential
   that these marked exercises should be handed in together with your laboratory notebooks
   and solutions to the programming exercises by the appropriate deadline for your group.
   This will ensure that all your work can be second marked.

   A.H. Harker
   23 September 2002




                                                4

								
To top