FF505 – Computational Science
Week 5, Spring 2015 [pdf format]

Work in small groups at the computer to solve the following exercises.

  1. Use MATLAB to generate random 4× 4 matrices A=rand(4) and B=rand(4). For each of the following, compute A1, A2, A3, and A4 as indicated and determine which of the matrices are equal (you can use MATLAB to test whether two matrices are equal by computing their difference):
    1. A1=A*B, A2=B*A, A3=(A′*B′)′, A4=(B′*A′)′
    2. A1=A′*B′, A2=(A*B)′, A3=B′*A′, A4=(B*A)′
    3. A1=inv(A*B), A2=inv(A)*inv(B), A3=inv(B*A), A4=inv(B)*inv(A)
    4. A1=(inv((A*B)′), A2=inv(A′*B′), A3=inv(A′)*inv(B′),
      A4=(inv(A)*inv(B))′

    A simple application of matrix calculus

    Car owners occasionally trade in their used car for a new car and marketing people are interested in the following type of question: Assume that you own a Citroen. Will your next car be another Citroen or a Volkswagen? Customers’ choices eventually determine the market share of different brands. Car dealers need estimates of how the market share of their brand (or brands) will change as a function of time. The problem can be dealt with by matrix algebra, and ends up being an exercise in matrix multiplication.

    Let the index i, 1≤ in denote car brands, in alphabetic order. That is, 1 is Alfa Romeo, 2 is Aston Martin, 3 is Bentley, and n is Toyota. Let also t=1,2, … denote time, measured in years from an arbitrary initial time, and let Fj(t) be the fraction of cars of type j traded in year t. Assume for simplicity that car owners trade their cars in every year1 and let Cij the fraction of cars of brand j which are traded in for a new car of brand i.

    As an example you will use the following data from Table 1 and 2 that are also available in electronic form this xls file or this txt file2. (We limit ourselves to n=5 because the matrices we then need are easily visualized on a screen, there are of course more car brands). The data refer to the absolute numbers, divided by 1000, from which fractions can be derived. We will assume that the distribution of the next outcome depends only on the previous outcome and that the trading fractions are constant over time.


    VolkswagenFiatFordPeugeotToyota
    426436364437336
    Table 1: Cars traded at time 0 for each car brand.


    current car (j)
     
    new car (i)VolkswagenFiatFordPeugeotToyota
    Volkswagen335717586340104
    Fiat375257409551626
    Ford49143614292445
    Peugeot246383373567649
    Toyota55460018250177
    Table 2: Cars traded from a brand to another.


1
This is common for fleet owners, but if you think trading a car in every year is a huge waste of money, just change the unit of time to e.g. five years.
2
Tip: In MATLAB the command xlsread can be used to read files in the xls format