Linear algebra in practice

Ivan Cnop
Vrije universiteit Brussel
icnop@vub.ac.be

Mixing drinks

Problem: how can I mix drinks if I only have one full glass of  fruit juice and one full glass of gin?

Answer:

drink some fruit juice, replenish glass with gin, pour mixture back until glass of gin is full, and repeat. The  concentration of the gin in both glasses  is denoted cS (soft drink glass) en cA (gin glass) given by

cS(n) = 
      swallow cA(n - 1) + (1 - swallow) cS(n - 1)
cA(n) = (1 - swallow) cA(n - 1) + 
        swallow cS(n)

from initail values

cS[0] = 0;
cA[0] = 1;
often = 16;		
cS[n_]:=cS[n] =  
          cS[n - 1] (1 - swallow) + cA[n - 1] swallow
cA[n_]:=cA[n] =  cS[n] swallow + cA[n - 1] (1 - swallow)

and we compute a list of these values

swallow = 0.1;

concentrationsS = Table[cS[j], {j, often}];

concentrationsA = Table[cA[j], {j, often}];

\(Show[
	{ListPlot[concentrationsS]
	, ListPlot[concentrationsA]
	, 
        Graphics[
          Line[{{0, 1/\((2 - swallow)\)}, {10, 
                1/\((2 - swallow)\)}}]]
	}
, 
      PlotRange -> {0, 1}]\)

Colouring drinks

\(Do[
	
      Show[
			{Graphics[{Hue[cS[j]\  .18], 
              Disk[{0, 0},  .1]}], 
			Graphics[{Hue[cA[j]\  .18], 
              Disk[{ .4, 0},  .1]}]}
	, AspectRatio -> Automatic]
, {j, 0, 
        often}]\)

Problem in matrix form

\(ListPlot[Transpose[{concentrationsS, concentrationsA}]	
	, 
      AspectRatio -> Automatic
	, PlotRange -> {{0, 1}, {0, 1}}]\)

T=(({{1 - swallow, swallow}, {swallow (1 - swallow), 1 - swallow + 
                swallow swallow}}))

T.{cS[4], cA[4]}

% == {cS[5], cA[5]}

T // TableForm

Eigenvalues[T]

Eigensystem[T]

eigenvectors = Last[%] // TableForm

Two dimensional plot

\(graph2D = 
      ListPlot[Transpose[{20\ concentrationsS, 20\ concentrationsA}]	
	, 
        AspectRatio -> Automatic
	, 
        PlotRange -> {{0, 20}, {0, 20}}]\)

Show[
      Graphics[{RasterArray[Table[Hue[.009 i], {i, 1, 20}, {j, 1, 1}]], 
          RasterArray[Table[Hue[.009 j], {i, 1, 1}, {j, 1, 20}]]}], 
      AspectRatio -> Automatic];

Show[{%, graph2D}, GridLines -> Automatic]