Friday, November 27, 2015

Math Links

1. Properties of the function \(x^x\) (Post-Doc Ergo Propter Hoc H/T Dave Richeson). Can you prove:
\[\int_{0}^{1} x^{x} = -\sum_{n=1}^{\infty} (-n)^{-n}\]
2. Steve Strogatz on Einstein's boyhood proofs (newyorker).
The style of his Pythagorean proof, elegant and seemingly effortless, also portends something of the later scientist. Einstein draws a single line in Step 1, after which the Pythagorean theorem falls out like a ripe avocado. The same spirit of minimalism characterizes all of Einstein’s adult work. Incredibly, in the part of his special-relativity paper where he revolutionized our notions of space and time, he used no math beyond high-school algebra and geometry.
3. Via Twitter,  Sep 17
A strange derivative: let \[f(x)=x^2 \sin(1/x^2)\] for \(x \ne 0\), and \(f(0)=0\). This function has \(f'(0)=0\) even though \[\lim_{x \rightarrow 0} f'(x),\] does not exist.

Wednesday, November 25, 2015

Logical Indexing in Octave/Matlab and Python/Numpy


Consider the following set of operations in Octave or Matlab.

Make an array.

octave:1> x=1:10
x =
    1    2    3    4    5    6    7    8    9   10

Which elements of "x" are greater than 5? The result is a logical array.

octave:2> c1 = x > 5
c1 =
   0   0   0   0   0   1   1   1   1   1

Which elements are less than 8?

octave:3> c2 = x < 8
c2 =
   1   1   1   1   1   1   1   0   0   0

The logical combination of two logical arrays is interpreted pair-wise.

octave:4> c = c1 & c2
c =
   0   0   0   0   0   1   1   0   0   0

octave:5> x(c)
ans =
   6   7


Now consider doing something similar in numpy.

>>> import numpy as np
>>> x=np.arange(1,11)
>>> x
array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10])
>>> c1 = x > 5
>>> c1
array([False, False, False, False, False,  True,  True,  True,  True,  True], dtype=bool)
>>> c2 = x < 8

So far so good. But when I say,

>>> c = c1 and c2
Traceback (most recent call last):
  File "", line 1, in
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The "and" command is good only to compare two bools, not arrays of bools. Therefore numpy suggests using x.any() or x.all() to collapse the vector of logical arguments to a scalar. For example.

>>> c1.all() # are all elements of c1 True?
>>> c1.any() # are any elements of c1 True?

To do an element-by-element comparison simply use np.logical_and or np.logical_or.

>>> c = np.logical_and(c1, c2)
>>> c
array([False, False, False, False, False,  True,  True, False, False, False], dtype=bool)

>>> x[c]
array([6, 7])

Thursday, November 12, 2015

A Moral Argument for Eating Meat

I promised that I would stop eating meat, the year I turned 35.

I failed.

The main arguments for going vegetarian are convincing:
  • the greenest thing that an average person could do; nothing else comes close
  • the cruelty and inhumanity of factory farming
  • something screwed up about raising sentient life for food
I've scoured for arguments that counter the last point. Even if there was a carbon-neutral, perfectly humane way to raise animals, and slaughter them painlessly, would we be justified in raising and killing animals?

So far, none of the arguments seem compelling. The only narrow exception is when the survival of the individual is at stake.

For now, the story I tell to rationalize my choices is that most of my meals are vegetarian. One can't let the perfect be the enemy of the good.

Abstinence is hard, so moderation will have to do.

In a hundred years, our great-great-grandkids might look at our food choices with disgust. They might view us with the same odd combination of outrage and pity that with which we view historical moral crimes (slavery?).

Tuesday, November 10, 2015

Ramanujan Links

1. Ramanujan and elliptic curves
A box of manuscripts and three notebooks. That's all that's left of the work of Srinivasa Ramanujan, an Indian mathematician who lived his remarkable but short life around the beginning of the twentieth century. Yet, that small stash of mathematical legacy still yields surprises. Two mathematicians of Emory University, Ken Ono and Sarah Trebat-Leder, have recently made a fascinating discovery within its yellowed pages. It shows that Ramanujan was further ahead of his time than anyone had expected, and provides a beautiful link between several milestones in the history of mathematics.

2. Ramanujan and the disappearing number
This is exactly the answer Ramanujan gave in his letter to Hardy. This surprising result showed Hardy that Ramanujan had managed to derive the Riemann zeta function and its functional equation correctly himself. In fact Ramanujan, almost entirely self-taught, had reinvented many other areas of Western mathematics, on his own. He was a mathematical genius with an intuitive connection to mathematics. And Hardy displayed his own mathematical genius by seeing through Ramanujan's idiosyncratic notations to uncover the genius beneath.