+Calculator and code looks
[lineal.git] / doc / doing_math.html
blob70feefa44de4dbf5c9a7496caf76945e1983d733
2 <html>
3 <head>
4 <title>How to actually do math.</title>
5 </head>
6 <body>
7 <div><a href="./index.html">back to doc index</a></div>
8 <p>So, you want to do math, eh?</p>
9 <p> Assuming you know how to
10 <a href="./matrix_edit.html">create a vector or matrix,</a>
11 let's say you initialize the following variables:
12 <table border="1" style="text-align:center">
13 <tr>
14 <td><b>A</b></td>
15 <td>
16 <pre>
17 [1 2]
18 [3 4]</pre>
19 </td>
20 <td><b>B</b></td>
21 <td>
22 <pre>
23 [3 4]
24 [2 5]</pre>
25 </td>
26 </tr>
27 <tr>
28 <td><b>u</b></td>
29 <td>
30 <pre>(1, 2, 3)</pre>
31 </td>
32 <td><b>v</b></td>
33 <td>
34 <pre>(1, 1, 1)</pre>
35 </td>
36 </tr>
37 </table>
38 Next, go to <a href="../calcupage">/calcupage</a>.
39 If you didn't get here through Lineal, boot it up
40 and find your way back here through from the Lineal's main page.
41 </p>
42 <p>The following commands and sample output should give you a good idea of how to run Lineal.
43 To submit your calculation for processing, hit the
44 <font style="color:green">green "OK" button</font>... not the equals sign.
45 </p>
46 <p>
47 <table width="100%" border="1"
48 style="text-align:center">
49 <tr>
50 <td width="25%"><b>Input</b></td>
51 <td width="15%"><b>Output</b></td>
52 <td width="60%"><b>Explanation</b></td>
53 </tr>
54 <tr>
55 <td><pre>(* A B)</pre></td>
56 <td><pre>[ 7 14]<br/>[17 32]</pre></td>
57 <td>Multiply matrices <b>A</b> and <b>B</b>.
58 Yes, hit the not-asterisk symbol to get the asterisk.
59 You can also just manually type it.</td>
60 </tr>
61 <tr>
62 <td><pre>(det B)</pre></td>
63 <td><pre>7</pre></td>
64 <td>Determinant</td>
65 </tr>
66 <tr>
67 <td><pre>(transpose A)</pre></td>
68 <td><pre>[1 3]<br/>[2 4]</pre></td>
69 <td>Transpose matrix <b>A</b></td>
70 </tr>
71 <tr>
72 <td><pre>(inverse B)</pre></td>
73 <td><pre>[ 5/7 -4/7]<br/>[-2/7 3/7]</pre></td>
74 <td>Matrix <b>B</b>'s determinant isn't zero so the inverse is valid.
75 The inverse function does not check if an inverse actually exists.</td>
76 </tr>
77 <tr>
78 <td><pre>(* B (inverse B))</pre></td>
79 <td><pre>[1 0]<br/>[0 1]</pre></td>
80 <td>Of course the identity matrix is returned, that's the definition of inverse.</td>
81 </tr>
82 <tr>
83 <td><pre>(store "I" (* B (inverse B)))</pre></td>
84 <td><pre>[1 0]<br/>[0 1]</pre></td>
85 <td>The identity matrix we got from the previous operation is stored in the variable <b>I</b>.
86 Refresh the page to see its button appear.</td>
87 </tr>
88 <tr>
89 <td><pre>(store "n" (* 3 2))</pre></td>
90 <td>6</td>
91 <td>You can also use the store function to store regular numbers.</td>
92 </tr>
93 <tr>
94 <td><pre>(* 5 I 1 3/5)</pre></td>
95 <td><pre>[3 0]<br/>[0 3]</pre></td>
96 <td>Scalar-matrix multiplication is perfectly legal.
97 Also, multiplication takes as many arguments as you want.</td>
98 </tr>
99 <tr>
100 <td><pre>(+ A (- B))</pre></td>
101 <td><pre>[-2 -2]<br/>[ 1 -1]</pre></td>
102 <td>When only one term is applied to the subtraction function,
103 it is negated.</td>
104 </tr>
105 <tr>
106 <td><pre>(dot u v)</pre></td>
107 <td>6</td>
108 <td>Regular old dot product.</td>
109 </tr>
110 <tr>
111 <td><pre>(proj u v)</pre></td>
112 <td><pre>(2, 2, 2)</pre></td>
113 <td>Projection of <b>u</b> onto <b>v</b>. Usually written: proj<b><sub>v</sub>u</b></td>
114 </tr>
115 <tr>
116 <td><pre>(orth u v)</pre></td>
117 <td><pre>(-1, 0, 1)</pre></td>
118 <td>The orthogonal component of the projection of <b>u</b> onto <b>v</b>.
119 Usually written: <b>u</b> - proj<b><sub>v</sub>u</b></td>
120 </tr>
121 <tr>
122 <td><pre>(cross u v)</pre></td>
123 <td><pre>(-1, 2, -1)</pre></td>
124 <td>Regular old cross product.</td>
125 </tr>
126 <tr>
127 <td>
128 <pre>(/ 4)</pre>
129 </td>
130 <td>1/4</td>
131 <td>Like subtraction, the division function returns the
132 multiplicative inverse if only one term is applied to it.
133 This trick works with matrices too. BUT in general, matrices
134 do not allow division because it is inherently commutative,
135 matrix multiplication is not.</td>
136 </tr>
137 </table>
138 </p>
139 </body>
140 </html>