3/23/15

Physics and Hide-and-Seek

Close your eyes, count to ten, open your eyes, and seek out your friends. Is she behind the curtain? No. Is he in the hallway closet? No. Maybe someone is hiding under the bed? Yes!

Before we close our eyes, everyone is collected in front of us. Once our eyes shut our playmates are free to move about the house in search of a good hiding place. When we open our eyes, after counting carefully and steadily to ten, everyone has disappeared! We seek them out, haphazardly at first, but after a few rounds it is discovered that there are only about seven places in the house that people can fit and not be easily seen. To find them we need only check each location they could possibly be, one by one. At this point the excitement has worn off and a new game is invented to be played until everyone must go home for dinner.

The impulse to play hide-and-seek is the same which brought about the discovery of the basic principles of mechanical physics. Balls are thrown into the air and, after a long while, it is discovered that, of all the paths they could take, each ball seems to have a parabolic trajectory. This, now trivial, similarity between the events of balls tossed through the air was identified only after a long, and at times tedious, process of human thought, inquiry, and eventually observation.

Here, we are not worried about the historical order of events which led to our basic understanding of classical kinematics and dynamics, but rather how such ideas can be connected to our everyday experience and imagination. Behind the principles of modern theoretical mechanics, built by Galileo, Kepler, Leibniz, Newton, Euler, Lagrange, and Hamilton (to name a few), are simple similarities between events from everyday life that just so happen to be stated with the greatest amount of clarity and exactness in the language of mathematics.

If you sit in your house looking out a window at two neighborhood kids tossing a ball back and forth you might notice that when they throw the ball really hard they either make a big arc high above their heads or aim the ball right at each other. They never seem to throw the ball softly and straight at each other except when they want it to hit the ground and roll to the other kid.

Being of an acutely curious disposition, you get a marker and trace out the path of the ball on your window. You realize that though you now know what was the shape of the path of the ball, you are unable to say where it happened to be at each moment in time. You get clever, and use string to create a grid over the window so that each part of the window is boxed in by string.

+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+

You get a metronome and each time it ticks you keep count and write the number of ticks you have heard in the box where the ball is at.

+---+---+---+---+---+---+---+---+---+
|   |   |   | 2 |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   | 1 |   | 3 |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+
|   | 0 |   |   |   | 4 |   |   |   |
+---+---+---+---+---+---+---+---+---+

You decide to put this data into a table so that you can make more observations. You quickly realize that you have to label the rows and columns in order to transform your figure into a table.

    0   1   2   3   4   5   6   7   8
  +---+---+---+---+---+---+---+---+---+
0 |   |   |   | 2 |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+---+
1 |   |   | 1 |   | 3 |   |   |   |   |
  +---+---+---+---+---+---+---+---+---+
2 |   |   |   |   |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+---+
3 |   |   |   |   |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+---+
4 |   | 0 |   |   |   | 4 |   |   |   |
  +---+---+---+---+---+---+---+---+---+

So you make your table with three columns, the first being time (or number of clicks that you've heard from the metronome) the second being the row and the third being the column.

Time Row Column
---------------
   0   4      1
   1   1      2
   2   0      3
   3   1      4
   4   4      5

You notice a pattern in the numbers: the columns keep going up and the rows go down and back to where they started. This makes sense with what you saw, because the ball went up in the air and then came back down, and it went from one kid to the other. In order to get a better sense of how the location of the ball changed with time you make another table that gives the difference between the location of the ball in a row and column between each click of the metronome.

Intervals  Row Change  Column Change
------------------------------------
      0,1          _3              1
      1,2          _1              1
      2,3           1              1
      3,4           3              1

The change in columns is constant over each time interval, and the change in rows goes from being negative 3 to positive 3 by steps of 2.

Having recently finished your algebra homework, you realize that you know how to write out the functions for these tables, what luck!

Time  Row            Column
----------------------------
t     (t-2)^2        t+1
      (t^2)+(_4*t)+4

You perform this same procedure a number of different times and find that each equation you write out for the row and column has a similar form. The column equations always look like (a*t)+b for some numbers a and b, whereas the row equations always look like t^2+(u*t)+v for some numbers u and v. It is odd that EVERY equation for rows has a t^2 term that isn't ever multiplied by any other constant! You are left wanting more, and needing to understand WHY such a strange thing happens...

3/19/15

Love and the Cosmos

When an artist casts their critical eye upon the landscapes that surround them they seek out a similarity between their canvas and the world. With the stroke of a brush, color brings lines and shapes to life. The products of such intense efforts reveal to us a message filled with data from the terrain coupled with the seemingly mystical meanings brought out of the artists mind. The painting encapsulates the events which created it.

Cosmically the artist's acts are insignificant, being nothing more than the minor motions of a collection of matter dwarfed by the earth, moon and sun. Yet, for us, a beautiful painting might fill our minds with love, joy, or sorrow whose measure is, in that moment, beyond definition.

The cosmic insignificance of our acts does not imply they are morally insignificant. As clumps of atoms our acts are brief and of such a strikingly local nature that an account of the cosmos lacking our collected past, present, and future could not be criticized for its incompleteness.  How is one with a scientific outlook to recover the apparent importance of our daily acts to ourselves and others?

The solution is so simple that most are apt to ignore its elegance: we choose to care for ourselves and others more than our apparent cosmic insignificance.

Our wants and desires separate us from the impersonal force that is nature. That we seek out the good and do what we can to eliminate the bad is a consequence of our innate impulses and desires. For those afflicted with melancholy or a brooding cynicism, such statements of simplistic optimism are easily disregarded (or quickly squashed). Luckily, our prolonged existence is more the product of what has been good in humanity than what might be called bad.

I hold that Russell's definition of the good life is an effective tool for eliminating the growing trend to relativize, and subsequently undermine, our collective notion of good: "The good life is one inspired by love and guided by knowledge".

The contrarian must quickly identify that what is loved by me may be despised by another. To which one must respond that though an act may be inspired by the greatest of human features, love, we can not be allowed to take that which inspires us as an arbiter of action.

We are, as a species, lucky that the strength of love is directed by some towards an increase in knowledge that has let us live with a larger helping of love than what was possible in the past. We live, happily, with a multitude of facts that not only extend our lives and enhance our opportunities to love one another, but which owe their very identification to the same love which they continue to guide and inspire.

Our skill for consulting what is known before acting is always capable of improvement. Though we live in an age of information we struggle to harness its power when making decisions and building strategies. To those with a love of power there is nothing more enticing than the perfection of this untapped bounty. If such power and knowledge is to be available for giving direction to our loving desires then it must be built with such ends in mind. The cultivation of techniques whose obscurity isolates knowledge from the masses will only undo what good might have first brought about their creation.

The skill for guiding loving acts with our knowledge is called wisdom. To build the future we all wish to occupy we must not lose sight of what makes life good and must be constantly reminded that "love is wise and hatred is foolish".

3/17/15

The Multiplication Table as Paths through the Addition Table


Moving right in the addition table adds one, moving left subtracts one, moving up subtracts one, and moving down adds one. See if you can find the multiplication table inside the addition table using sequences of moves.

Addition Table
============================
0  1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9 10
2  3  4  5  6  7  8  9 10 11
3  4  5  6  7  8  9 10 11 12
4  5  6  7  8  9 10 11 12 13
5  6  7  8  9 10 11 12 13 14
6  7  8  9 10 11 12 13 14 15
7  8  9 10 11 12 13 14 15 16
8  9 10 11 12 13 14 15 16 17
9 10 11 12 13 14 15 16 17 18
============================

Multiplication Table
===========================
0 0  0  0  0  0  0  0  0  0
0 1  2  3  4  5  6  7  8  9
0 2  4  6  8 10 12 14 16 18
0 3  6  9 12 15 18 21 24 27
0 4  8 12 16 20 24 28 32 36
0 5 10 15 20 25 30 35 40 45
0 6 12 18 24 30 36 42 48 54
0 7 14 21 28 35 42 49 56 63
0 8 16 24 32 40 48 56 64 72
0 9 18 27 36 45 54 63 72 81
===========================

3/9/15

A dialogue on the iterated design of a J phrase "the diagonal of" as applied to arbitrary arrays

   
   NB. Iterated designs of the verb "the diagonal of" as applied to an arbitrary array.
   
   NB. 'di' is the unary verb 'list the boxed indices of the diagonal atoms in a square table (2-array) whose axes have length'
   di=:<@,~"0@i.
   di 3
+---+---+---+
|0 0|1 1|2 2|
+---+---+---+
   di 5
+---+---+---+---+---+
|0 0|1 1|2 2|3 3|4 4|
+---+---+---+---+---+
   
   NB. The result of 'di n' can be given as the left argument to the verb '{' (from) to extract the diagonal of a right argument that is an n by n table.
   t0=:i. 3 3  NB. t0 is the 3 by 3 table of the first 9 nonnegative integers.
   
   t0
0 1 2
3 4 5
6 7 8
   
   NB. The list of boxed indices of the diagonal atoms in a square table (2-array) whose axes have length 3, from t0 gives a list of the diagonal atoms of t0 starting from the atom with index 0 0 and ending with the atom having index 2 2. More simply,
   (di 3) { t0
0 4 8
   
   t1=:4 4$'abcde'
   
   t1
abcd
eabc
deab
cdea
   
   (di 4){ t1
aaaa
   
   NB. $ gives the shape of its right argument whose first and second items are equal to n when the right argument is an n by n table. So the relevant argument to 'di' is the head of $.
   
   (di@{.@$t1){t1
aaaa
   
   NB. This can be recast as a fork which takes a square table and returns its diagonal.
   diag=: (di@{.@$){]
   
   diag t0
0 4 8
   diag t1
aaaa
   
   NB. To accommodate rectangular tables we choose the minimum axes length from the shape of the argument using the verb '<./' which gives the min of a list of numeric atoms.
   
   diag=: (di@{.@<./@$){]
   
   NB. First, it is checked on the square tables
   diag t0
0 4 8
   diag t1
aaaa
   
   NB. Now it is checked on rectangular tables
   
   t2=:i.10 7
   t2
 0  1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48
49 50 51 52 53 54 55
56 57 58 59 60 61 62
63 64 65 66 67 68 69
   
   diag t2
0 8 16 24 32 40 48
   
   t3=:4 11$'abcABCefgEFG'
   t3
abcABCefgEF
GabcABCefgE
FGabcABCefg
EFGabcABCef
   
   diag t3
aaaa
   
   NB. As defined 'di' makes a list of indices from a table. A brick (3-array) has length 3 indices and, in general, a n-array A has length n indices thus 'di' must be redefined to accommodate the diagonals of an n-array.
   
   NB. The construction of this verb is aided by the use of the adverb " (rank). To see where rank comes in we first show a definition which DOES NOT WORK.
   
   c3=:3&# NB. Make 3 copies of right argument
   din=:<@c3@i. NB. Should be "box the result of c3-ing an atom of i."
   
   din 3
+-----------------+
|0 0 0 1 1 1 2 2 2|
+-----------------+
   din 4
+-----------------------+
|0 0 0 1 1 1 2 2 2 3 3 3|
+-----------------------+
   
   NB. Notice that the entire list is boxed rather than each of the indices. To box EACH of the 3-copies of an item of i. we consider the composition <@c3 as a single verb and have it apply to each atom of i. with the adverb "0
   
   
   c3=:3&#
   bc3=:(<@c3)"0 
   di3=:bc3@i.
   
   di3 3
+-----+-----+-----+
|0 0 0|1 1 1|2 2 2|
+-----+-----+-----+
   di3 4
+-----+-----+-----+-----+
|0 0 0|1 1 1|2 2 2|3 3 3|
+-----+-----+-----+-----+
   
   NB. Thus di3 n gives a list of the first n indices of the diagonal atoms in an n by n 3-array
   
   i.3 3 3
 0  1  2
 3  4  5
 6  7  8

 9 10 11
12 13 14
15 16 17

18 19 20
21 22 23
24 25 26
   
   (di3 3){i.3 3 3
0 13 26
   
   3 3 3$'abcDEF'
abc
DEF
abc

DEF
abc
DEF

abc
DEF
abc
   
   (di3 3){3 3 3$'abcDEF'
abc
   
   NB. Using the dyadic form of an atop the left argument to (<@#)"0 determines how many copies to make of each of the items in its right argument (whose result are boxed and joined)
   
   n=:4
   n (<@#)"0 i.n
+-------+-------+-------+-------+
|0 0 0 0|1 1 1 1|2 2 2 2|3 3 3 3|
+-------+-------+-------+-------+
   
   NB. This is a fork.
   (] (<@#)"0 i.@])n
+-------+-------+-------+-------+
|0 0 0 0|1 1 1 1|2 2 2 2|3 3 3 3|
+-------+-------+-------+-------+
   
   NB. Using the fact that @ applies its left verb at the same rank as its right verb we can get rid of the parenthesis around <@#
   (] <@#"0 i.@])n
+-------+-------+-------+-------+
|0 0 0 0|1 1 1 1|2 2 2 2|3 3 3 3|
+-------+-------+-------+-------+
   
   NB. Since n is the length of an index for an item of an n-array A then n=#@$A
   
   di=:(] <@#"0 i.@])@#@$
   
   A=:i.3 3 3
   A
 0  1  2
 3  4  5
 6  7  8

 9 10 11
12 13 14
15 16 17

18 19 20
21 22 23
24 25 26
   di A
+-----+-----+-----+
|0 0 0|1 1 1|2 2 2|
+-----+-----+-----+
   (di A) { A
0 13 26
   
   diag=:di{]
   A=:i.4 4 4 4
   diag A
0 85 170 255
   
   diag i.#~5
0 781 1562 2343 3124
   diag i.#~6
0 9331 18662 27993 37324 46655
   
   NB. Now, to deal with rectangular n-arrays we take the minimum of the lengths of the array's axes <./@$ and copy each atom in i.@(<./@$) a number of times equal to the dimension of the array #@$ using a fork.
   di=:(#@$ <@#"0 i.@(<./@$))
   
   A=: i. 3 4 5 6
   di A
+-------+-------+-------+
|0 0 0 0|1 1 1 1|2 2 2 2|
+-------+-------+-------+
   
   diag=:di{]
   diag A
0 157 314
   
   A=: 18 8 16$'abcdef'
   diag A
abcdefab
   
   
   NB. Note that both the left and right parts of the fork are composed with $ so that an equivalent form is
   di=:(# <@#"0 i.@(<./))@$
   
   diag i. 5 6 4 3
0 88 176
   
   diag=:(#<@#"0 i.@(<./))@${]
   diag i. 5 6 4 3
0 88 176
   
   NB. Finally, by putting a hook inside a fork we can eliminate the use of an atop
   diag=:(#(<@#"0 i.)<./)@${]
   diag i. 5 6 4 3
0 88 176
   
   diag 7 27 17 13$'abCDefGH'
aCeGaCe

3/6/15

Quadratic Function in Vertex Form with J

NB. Quadratic Function in Vertex Form: a h k qv x is (a*(x-h)^2)+k
   qv=:0&{@[*^&2@(]-1&{@[)+2&{@[
   p=:1 2 2&qv
   p i.10
6 3 2 3 6 11 18 27 38 51
   load 'plot'
   plot 0 4 ; 'p'
NB. Here is an alternate form for defining qv that is closer to the expression (a*(x-h)^2)+k
   x=:]
   a=:0&{@[
   h=:1&{@[
   k=:2&{@[

   qv=:a**:@(x-h)+k

   p=:1 2 2&qv
   p i.10

6 3 2 3 6 11 18 27 38 51