Wednesday, July 27, 2016

RIPE: Reconstructing Reality and Material Structure

In Plato’s allegory of the cave, he imagines chained prisoners facing a blank wall. A raging fire burns far in the background, behind their backs. The prisoners watch shadows cast by objects passing in front of the fire on the wall ahead of them. They form ideas about the true nature of the objects, from these shadows.

One can only guess the true nature of the objects from these shadows. The 2D shadows that 3D objects cast, project some information, and conceal the rest.

For example, a sphere and a cylinder can both cast a circular shadow.

Perspective is everything (google giraffe or elephant illusion if video below doesn't work).

This problem bedevils characterization of materials as well. A particular measurement or test (chromatography, rheology, thermal tests, scattering, microscopy etc.) gives us but one look at an unknown sample.

If we have a fairly good idea of what the material might be, to begin with, then perhaps this is enough.

More often than not, especially with new materials, each new test narrows the scope of the possible.

The fable of the six blind men and the elephant (which is perhaps a more pedestrian retelling of the Plato's allegory) provides a potential path out. In the story six blind men touch different parts of an elephant and form radically different notions of what an elephant is.

The only way (for the blind men) to come up with a more realistic notion of what an elephant looks like is to find ways of combining their knowledge to come up with a consensus view.

Saturday, July 23, 2016

On Magic, Knowledge, and Wonder

“Its still magic even if you know how it’s done.” Teri Pratchett

The space that Science occupies in popular imagination is not always flattering. By demystifying “magic”, it is often accused of making the world less interesting.

The metaphor is sometimes that of the bully who bursts out the secret of Santa Claus on unsuspecting kids, forever destroying the magic, and ending innocence.

Science is portrayed as cold, logical, disciplined, linear, rational, and precise.

Art, on the other hand, is seen as the antithesis. Art is beautiful, creative, nonlinear, and immersive.

One is a machine; the other has a soul.
One is Vulcan; the other is Human.

This dichotomy between “thinking” and “feeling”, while convenient, is a giant fabrication. In other words, scientists, even when “doing serious science”, are more like Dr. Spock - half Vulcan, and half human.

Consider a discipline like math, which is seen as cold and calculating (pun intended). It relies heavily on leaps of imagination to propose bold conjectures, with order, beauty, and intuition, as the only guide.

Substantial parts of it, in other words, are art.

Yes, it is true that Science occasionally destroys ideas that some people find magical. Often, however, a deeper beauty is revealed.

For example, the evidence-based claim that we came from something like the Big Bang, may superficially resemble the bully destroying the secret of Santa or a divine Creator.

But really, isn’t the implication far more amazing? I don’t know about you, but the notion that we are all made of “star-stuff”, I find totally awesome!

What an incredible Universe, we live in!

Tuesday, July 19, 2016

What I Learned Last Week

1. A single Gypsy moth may not amount to much, but collectively ... [nasa]
The ecological consequences of gypsy moth outbreaks are often cosmetic, but they can become serious. Deciduous trees can normally withstand one or two years of defoliation by caterpillars, but three or more successive years of severe defoliation can result in widespread tree mortality.
2. Orcas are dolphins too! [wnyc]

On the Lennard Lopate show, I learned that killer whales are really dolphins. The label "whale" apparently has no biological meaning - it is an informal term that generally means "big". Thus, we have whale sharks (world's biggest fish), and blue whales (world's biggest mammal).

3. Swordfish and drag reduction [nationalgeographic]
So Videler thinks that the gland is yet another drag-reducing adaptation. Its oil repels water and allows incoming currents to flow smoothly over the surface of the bill. That depends on the oil staying warm, but swordfish have a solution for that, too. They have modified some of their eye muscles into heat-producing organs that warm their blood and sharpen their vision as they hunt. This same heating effect could liquefy the drag-reducing oil, allowing it to ooze out of the glands just as the fish have the greatest need for speed.

Friday, July 15, 2016

Sunday Afternoon Fun

I spent a glorious afternoon playing the "can you sketch this picture without lifting your pencil?" game with my daughter. We started with a few standard ones that you can find with a simple Google Image search like:

click on image to enlarge
Soon enough, we just started making up random pictures for each other.

After a while, I told her the first part of the secret (Euler Paths), which tells you whether a solution exists.
  • identify all the points (nodes)
  • write down the number of lines that meet at each node
  • scratch off nodes with an even number number of lines
  • count the number of (remaining) "odd" nodes
  • if this number is 0 or 2, then it is possible to solve the problem

As an example the following figure,
has 3 even nodes (2, 4, and 2), and 2 odd nodes. Thus, it is possible to sketch this "graph" without lifting your pencil.

Showing existence is only the first part, but the second part is an algorithm to actually solve the problem, once you know it is solvable.

Wikipedia lists two methods (both of which are over a century old): Fleury's and Hierholzer's algorithms. But for "kiddie problems" a simpler rule of thumb works in most cases:

So this is the second secret: start from an odd node! For most cases, there are multiple solutions, and it is hard to go wrong with this simple "suggestion"!

PS: If the number of odd nodes is 0, it doesn't matter where you start, and your start and finish points are exactly the same!

Wednesday, July 13, 2016


1. Defending the Traditional Lecture (NYT)
A lecture is not the declamation of an encyclopedia article. In the humanities, a lecture “places a premium on the connections between individual facts,” Monessa Cummins, the chairwoman of the classics department and a popular lecturer at Grinnell College, told me. “It is not a recitation of facts, but the building of an argument.” 
Absorbing a long, complex argument is hard work, requiring students to synthesize, organize and react as they listen. In our time, when any reading assignment longer than a Facebook post seems ponderous, students have little experience doing this. Some research suggests that minority and low-income students struggle even more. But if we abandon the lecture format because students may find it difficult, we do them a disservice. Moreover, we capitulate to the worst features of the customer-service mentality that has seeped into the university from the business world. The solution, instead, is to teach those students how to gain all a great lecture course has to give them.
2. Gravitational Waves Explained (minutephysics)

3. Kokichi Sugihara's amazing illusions

Wednesday, July 6, 2016

Force from Pairwise Potentials

Consider a pairwise potential, such as the Lennard Jones potential, \[U(r) = 4 \epsilon \left[ \left(\frac{\sigma}{r}\right)^{12} - \left(\frac{\sigma}{r}\right)^{6} \right].\]Question: How can we get the force (magnitude and force) from such a potential?

For simplicity let us assume that we have only two particles A and B. Specifically, what is the force on particle A due to particle B?

We know that the force is the negative gradient of the potential; therefore, \[\begin{align*}
\mathbf{f}_{AB} & = -\dfrac{dU(r_{AB})}{d\mathbf{r}_A} \\
& = -\dfrac{dU(r_{AB})}{dr_{AB}} \color{blue} {\dfrac{dr_{AB}}{d\mathbf{r}_A}}
\end{align*}\] How do we evaluate the term in blue?

Let \(\mathbf{r}_A = x_A \mathbf{e}_x + y_A \mathbf{e}_y + z_A \mathbf{e}_z\), and \(\mathbf{r}_B = x_B \mathbf{e}_x + y_B \mathbf{e}_y + z_B \mathbf{e}_z\) be the positions of the two particles. Let \(\mathbf{r}_{AB} = \mathbf{r}_B - \mathbf{r}_A\) be a vector pointing in a direction from A to B. The distance between the two particles is:
\[r_{AB} = \sqrt{x_{AB}^2 + y_{AB}^2 + z_{AB}^2},\] where \(x_{AB}^2 = (x_B - x_A)^2\), etc.

We can now try to tackle the blue term: \[\begin{align*}
\dfrac{dr_{AB}}{d\mathbf{r}_A} & = \dfrac{dr_{AB}}{dx_A} \mathbf{e}_x + \dfrac{dr_{AB}}{dy_A} \mathbf{e}_y + \dfrac{dr_{AB}}{dz_A} \mathbf{e}_z\\
& = \dfrac{1}{2 r_{AB}} \left(\dfrac{dx_{AB}^2}{dx_A} \mathbf{e}_x + \dfrac{dy_{AB}^2}{dy_A} \mathbf{e}_y + \dfrac{dz_{AB}^2}{dz_A} \mathbf{e}_z \right) \\
& = \dfrac{1}{2 r_{AB}} \left(-2 x_{AB} \dfrac{dx_A}{dx_A} \mathbf{e}_x - 2 y_{AB} \dfrac{dy_{A}}{dy_A} \mathbf{e}_y - 2 z_{AB} \dfrac{dz_{A}}{dz_A} \mathbf{e}_z \right) \\
& = -\dfrac{\mathbf{r}_{AB}}{r_{AB}} \\
& = -\hat{\mathbf{r}}_{AB}
\end{align*}\] Thus, the force is, \[\mathbf{f}_{AB}(r) = \dfrac{dU(r)}{dr} \hat{\mathbf{r}}_{AB}.\] If \(U^{\prime}(r)\) is negative (repulsive regime of LJ, for instance), the direction of the force is along \( -\hat{\mathbf{r}}_{AB} = \hat{\mathbf{r}}_{AB}\); this force points in the direction of A from B, trying to push particle A away from particle B. If \(U^{\prime}(r)\) is positive (attractive part of LJ), the force acts along \(\hat{\mathbf{r}}_{AB}\).

Saturday, July 2, 2016


1. John D. Cook has an interesting take on why student group projects don't work.
The best teams have people with complementary skills, but similar work ethic. Academic assignments are the opposite. There’s not much variation in skills, in part because students haven’t yet developed specialized skills, and in part because students are in the same class because they have similar interests. The biggest variation is likely to be work ethic. [...] The person doing most of the work learns that it’s best to avoid working with teams.
 2. Don't be a Grammar Nazi. A linguist lashes out:
What changed me was realizing that language isn’t some delicate cultural artifact but an integral part of being human. I found this out by reading what scholars of language — linguists, grammarians and cognitive scientists — say about the subject. It fascinated me. Language — which all human societies have in immense grammatical complexity — is far more interesting than pedantry.
3. Academic Administration as a Calling:
To be sure, no one completes a Ph.D. (as opposed to an Ed.D.) in order to enter campus administration. But for some of us, at a certain point in our careers, administrative work is no longer something to dread or to apologize for. For some of us, serving as chair of a department or dean of a college comes unbidden as a second, midcareer calling. Too often, perhaps, it calls us away from the work we were destined to do, and those tend to be the stories we hear. But sometimes, taking on administrative duties is precisely the culmination and fulfillment of that scholarly work, allowing us, for the first time, to recognize our past as prologue.

Friday, July 1, 2016

Numpy: Arrays, Vectors and Matrices

Define numpy arrays of different shapes:

import numpy as np
a = np.array([1, 2])
b = np.array([[1, 2], [3, 4]])

print a.shape, type(a)
print b.shape, type(b)


(2, 2)

Numpy arrays are not exactly row or column vectors or matrices. Of course, we can design proper row/column vectors and matrices using the np.matrix construct. We can even use a simpler Matlab/Octave like method to build matrices, by using ";" to start new rows, and comma or spaces to separate successive row elements.

am = np.matrix([1, 2]).T  # column vector
bm = np.matrix('1, 2; 3, 4')

print am.shape, type(am)
print bm.shape, type(bm)

(2, 1)
(2, 2)

Matrix Operations

The array "a" is not a linear algebra vector. So if I try to take a transpose. It doesn't quite produce the expected result.

print a, a.T
[1 2] [1 2]

But it works for matrices defined as arrays of arrays.

print b, b.T
[[1 2] [3 4]] [[1 3] [2 4]]

To multiply vectors and matrices that ndarrays, use the "dot" command.

[ 5 11]

For actual matrix objects, the * operator is overloaded, and can perform matrix multiplication.

print bm*am
[[ 5] [11]],am)
matrix([[ 5], [11]])

Converting array to row or column vector

It is easy to convert a python array to a linear algebra row or column vector either by using the "reshape" command (a.reshape(2,1)), or alternatively,
a = np.array([1, 2])
a = a[:, np.newaxis] # makes into column vector

print a, a.shape, type(a)
[[1] [2]] (2, 1) 

But you need to be careful with * operation. Don't use it unless all the underlying objects are matrix types.

print b*a
[[1 2] [6 8]]

Each row of b was multiplied by the row of a.


That said, it appears that on array types is faster than other alternatives.

%timeit bm*am
The slowest run took 9.73 times longer than the fastest. This could mean that an intermediate result is being cached
100000 loops, best of 3: 5.76 µs per loop
The slowest run took 7.84 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 1.52 µs per loop
The slowest run took 7.88 times longer than the fastest. This could mean that an intermediate result is being cached
100000 loops, best of 3: 3.3 µs per loop