Matrix Evaluation

  1. Write down the MATLAB commands for each of the following tasks.
    (a) Evaluate
    X
    101
    i=1
    i
    2

    sin
    2π(i − 1)
    100
    .
    (Hint: sum)
    (b) Construct a 50 × 50 matrix, A, and fill in even numbers from 2 to
    5000 column-wise, i.e. the first column is 2, 4, 6, 8, · · ·, the second
    is 102, 104, 106, 108, · · ·, and so on. (Hint: reshape)
    (c) Create a new matrix B containing the even rows and the odd columns
    of A.
    (d) Construct the following matrix
    C =









    1 −1 0 · · · · · · 0
    −1 2 −1 0 · · · 0
    0 −1 3 −1 0 · · ·
    .
    .
    .
    .
    .
    .
    .
    .
    .
    0 · · · 0 −1 119 −1
    0 · · · · · · 0 −1 120









    .
    (Hint: diag)
    (Note: You need to submit the m-file containing all the MATLAB commands for the above tasks.)
    1
  2. The following differential equations describe the motion of a spaceship in
    orbit about the earth (located at the origin) and the moon located at (1,0).
    The derivatives are respect to time:
    x
    00 = 2y
    0 + x −
    µ0(x + µ)
    r
    3
    1

    µ(x − µ0)
    r
    3
    2
    − fx0
    ,
    y
    00 = −2x
    0 + y −
    µ0y
    r
    3
    1

    µy
    r
    3
    2
    − fy0
    ,
    with
    µ =
    1
    82.45
    , µ0 = 1 − µ , r1 =
    p
    (x + µ)
    2 + y
    2 , r2 =
    p
    (x − µ0)
    2 + y
    2 .
    (a) By plotting the orbit y(t) versus x(t) with initial conditions
    x(0) = 1.2 , x0
    (0) = 0 , y(0) = 0 , y0
    (0) = −1.04935751 ,
    show that when f = 0, the orbit is periodic with the period T =
    6.19216933. You may use the MATLAB function ode45 to solve the
    ODE numerically.
    (b) With the same initial conditions as in (a), but with f = 1, solve the
    differential equations from t = 0. Plot the orbit to show that the
    spaceship eventually crashes.
    (c) Repeat the computation of (b) with f = 0.1. Can you guess what is
    happening?
    (Note: You need to submit the m-files for producing the plots in (a),
    (b) and (c) and the image files of the plots. Also, please provide the
    description of what happens to the spaceship that you can see from the
    plot of (c).)