- 
    
Create X = INDGEN(100).
    [NOTE on IDL syntax: INDGEN is a function.  In IDL the arguments of
    a function are enclosed in parentheses.  In IDL versions 1 through 4,
    the indices of vector or arra variables were also enclosed in parentheses,
    as in X(10). Obviously, this introduced possible ambiguities between
    function and array notation.  Therefore, in IDL version 5, array
    indices are expected to be enclosed by brackets, as in X[10].  You
    should use this syntax when referring to array elements.  This notation
    for array elements is not compatible with IDL V.4 and earlier. 
    However,
    IDL V.5 does accept the parenthesis syntax for array elements, so it is
    compatible with earlier IDL code in this regard.
 
  - 
    
 Use
    built-in IDL functions N_ELEMENTS, MIN, MAX, and TOTAL to answer the
    following:
 
  - 
    
        
    How many elements does X contain?    
                 
    What is the minimum value in X?    
                 
    What is the maximum value in X?    
                 
    What is the sum of all the elements in X?  
 
  - 
    
Use the IDL
    HyperHelp facility to obtain information on any of the built-in routines you
    just used, e.g. ?TOTAL.
 
  - 
    
Print X to your
    terminal window
 
  - 
    
How are values in
    X related to the corresponding subscripts?
 
  - 
    
Is X a
    floating-point array?
 
  - 
    
Print the
    fifteenth entry in X to your terminal
 
  - 
    
Then print the
    entry containing the number 15
 
  - 
    
Is X a row-vector
    or a column-vector?
 
  - 
    
The default
    configuration of the printed data on your screen will tell you.  To
    confirm this, try the following:  PRINT,TRANSPOSE(X)
 
  - 
    
Try the following
    one-line command and inspect its output:
    FOR I=0,99 DO PRINT,I,X[I]
 
  - 
    
Now try: FOR
    I=1,100 DO PRINT,I,X[I]
 
  - 
    
Using the WHERE
    function:
 
  - 
    
Define Q=2*X,
    then type FIND = WHERE(Q LE 40, COUNT)
 
  - 
    
Examine the
    contents of FIND and COUNT so that you understand how the WHERE function
    operates.
 
  - 
    
Predict and
    confirm the response if you type PRINT,Q[FIND]
 
  - 
    
Print to your
    terminal the values of the vector X/10
 
  - 
    
Then print the
    values of X/10.0 and compare the results.
 
  - 
    
Do the same for
    FLOAT(X)/10
 
  - 
    
Do the same for
    FIX(X/10.0)
 
  - 
    
What is the
    difference between Z = X*0.0 and Z = 0? 
 
  - 
    
Print the 11
    elements centered on X = 10  
 
  - 
    
First do this
    using a FOR loop (on a single line)
 
  - 
    
Then do this
    using the standard IDL subscript range notation, e.g. X[2:6].  No FOR
    loop is needed.
 
  - 
    
Compare to the
    following: K=5 & PRINT,X[10-K:10+K]
 
  - 
    
Define Y to be
    the subarray consisting of those 11 elements, using subscript range
    notation; print Y to your window as a check.  
 
  - 
    
Using information
    utilities: 
 
  - 
    
Verify lengths of
    X,Y using the N_ELEMENTS utility
 
  - 
    
Use the SIZE
    utility to find the sizes of X and Y; what other info does it supply?
 
  - 
    
What information
    does the command HELP,X,Y provide?
 
  - 
    
Define Q = Y+3
    --  Note the values that Q contains
 
  - 
    
Define Q = Y*3
    --  Note the values that Q contains
 
  - 
    
Define Q = Y^3
    --  Note the values that Q contains
 
  - 
    
Define Q = Y^4
    --  Note the values that Q contains; why are they not monotonic?
 
  - 
    
Define Q = FLOAT(Y)^4
    --  Note the change.
 
  - 
    
Print the vector
    which results from Q = X*Y
 
  - 
    
What did IDL
    actually do to arrive at this result?
 
  - 
    
Using the
    built-in functions TOTAL and N_ELEMENTS:
 
  - 
    
Find and print
    the mean values of X and Y; 
 
  - 
    
Find and print
    the variances of the two arrays
 
  - 
    
Do the same using
    the built-in functions MEAN and VARIANCE.
 
  - 
    
Do the same using
    the built-in function MOMENT
 
  - 
    
Determine the
    nature of the vector which results when you write Q = X & Q[2] =
    Y.  
 
  - 
    
What will happen
    if you write Q[98] = Y?  Try it.
 
  - 
    
Predict, then
    verify, the outcome of the following operations: 
        Q = [Y,Y]
    Q = [Q,Y]
 
  - 
    
Create a
    16-element vector [1.01, 1.02, 1.03...] using a simple one-line command
    employing FINDGEN.  Verify.
 
  - 
    
Create a
    16-element vector: [1,2,4,8,16....] using a simple one-line command
    employing FINDGEN.  Verify.
 
  - 
    
Create the
    100-element vector Z = 10*X - 0.1*X^2, where X contains the integers between
    0 and 99.
 
  - 
    
Use MAX to
    determine the maximum value of Z.
 
  - 
    
Use WHERE to
    locate the X value for which this maximum occurs.
 
  - 
    
X was an integer
    vector but Z is not.  Why?
 
  - 
    
Using the SHIFT
    function, shift the elements of the array you just created three entries to
    the left.  Verify that the maximum is now in the expected
    location. 
 
  - 
    
Create, using a
    simple one-line command employing FINDGEN, a 1001-element vector containing
    the base-10 logarithms of the integers between 0 and 1000.  Name this
    "ILOG". 
    Verify its contents. 
 
  - 
    
Now create a five
    element vector, Y, containing the numbers 2, 100, 500, 20, and
    999.  
 
  - 
    
Explain the
    vector resulting when you type NEW = ILOG[Y].  Why did we include an
    entry for 0 in defining ILOG? 
 
  - 
    
Optional problem: 
    ILOG in the previous exercise is called a "lookup table."  It
    can be used to accelerate computations in problems where a large number of
    time-consuming transformations such as logarithms are needed.  You can
    estimate the time savings for this example as follows:
 
  - 
    
Write a simple
    one-line IDL command script using "&" as a link between
    individual commands.  Use the SYSTIME(1) function to determine the
    start time.  Then, use a FOR loop to compute the logarithm of an
    integer 40000 times using the standard ALOG10 function.  Then use
    SYSTIME(1) again to determine the end time.  Print the elapsed time.
 
  - 
    
Repeat, now using
    the "ILOG" lookup table instead of ALOG10.