Harold Thimbleby - http://www.uclic.ucl.ac.uk/harold
This file is the background for establishing some matrix identities for the calculator examples used in the papers.
In[26]:=
![NameOf[matrix_, name_List] := NameOf[matrix] = RowBox[Map[NameOf[matrix, #] &, name]] ; NameOf[matrix_, name_String] := NameOf[matrix] = FrameBox[GridBox[{{name}}]] ; problemNameOf[matrix_, name_String] := problemNameOf[matrix] = FrameBox[GridBox[{{name}}]] ; problemNameOf[matrix_] := NameOf[matrix] ; <br /> explain[mat_] := Module[{v = {StyleForm["d", FontSlant -> Italic, FontFamily -> "Times"], StyleForm["m", FontSlant -> Italic, FontFamily -> "Times"]}}, {problemNameOf[mat], "=", MatrixForm[mat], " ", {v} // TraditionalForm, " -> ", {v . mat} // TraditionalForm} ] ; <br /> explainList[matlist_] := StylePrint[GridBox[Map[(explain[#]) &, matlist], ColumnAlignments -> Left] // DisplayForm, Background -> RGBColor[1, 1, 0.6]]](HTMLFiles/mathcalc_1.gif)
In[7]:=
![NameOf[ac = (0 0), "AC"] ; 0 1 NameOf[mp = (1 1), "M+"] ; 0 1 NameOf[mm = (1 -1), "M-"] ; 0 1 NameOf[cs = (-1 0 ), "±"] ; 0 1 NameOf[mrc = (0 0), "MRC"] ; 1 1 NameOf[mmrce = (1 0 ), {"-", "MRC", "="}] ; -1 1 NameOf[mrcmrc = (0 0), {"MRC", "MRC"}] ; 1 0 mats = { ac, mp, mm, mrc, cs, mmrce, mrcmrc} ;](HTMLFiles/mathcalc_2.gif)
![]()
In[15]:=
![]()
![]()
In[16]:=
![]()
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
In[17]:=
![problemNameOf[swap = (0 1), "SWAP DISPAY & MEMORY"] ; 1 0 problemNameOf[savedisplay = (1 1), "SAVE DISPLAY"] ; 0 0 problemNameOf[zerodisplay = (0 0), "ZERO DISPLAY"] ; 0 1 problemNameOf[zeroeverything = (0 0), "ZERO DISPAY & MEMORY"] ; 0 0 problemNameOf[zeromemory = (1 0), "ZERO MEMORY"] ; 0 0](HTMLFiles/mathcalc_42.gif)
In[22]:=
![]()
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
|
|
|
= |
|
|
|
|
The function howto finds the shortest products (with no more terms than maxTerms) that get to the goal. You can change limit to make it search further. Note that maxTerms refers to matrices, rather than button presses (e.g., mrcmrc is the product of two button presses).
In[23]:=
![howto[goal_, maxTerms_: 8] := Module[{rec, tried, i}, rec[m_, depth_, maxDepth_, soln_] := Module[{n, product, s, i}, If[MemberQ[tried, μ[m]], Return[False]] ; AppendTo[tried, μ[m]] ; For[n = 1, n <= Length[mats], n ++, product = m . mats _ [[ n ]] ; s = Append[soln, NameOf[mats _ [[ n ]]]] ; If[goal == product, StylePrint[RowBox[{"To implement ", problemNameOf[goal], "press", RowBox[s]}] // DisplayForm, Background -> RGBColor[1, 1, 0.5]] ; Return[True], If[depth < maxDepth && rec[product, depth + 1, maxDepth, s], Return[True] ] ] ; ] ; Return[False] ; ] ; For[i = 1, i <= maxTerms, i ++, tried = {} ; If[rec[IdentityMatrix[2], 1, i, {}], Return[]] ] ; StylePrint[RowBox[{problemNameOf[goal], " not possible in no more than ", ToString @ maxTerms, " terms."}] // DisplayForm, Background -> RGBColor[1, 1, 0.5]] ]](HTMLFiles/mathcalc_69.gif)
![]()
In[24]:=
![]()
![]()
![]()
![]()
![]()
![]()
In[25]:=
![]()
![]()
Converted by Mathematica (May 2, 2003)