Question: TV documentaries invariably show the Big Bang as an exploding ball of fire expanding outwards. Did the Big Bang really explode outwards from a point like this? If not, what did happen?

The simple answer is that no, the Big Bang did not happen at a point. Instead, it happened everywhere in the universe at the same time. Consequences of this include:

The universe doesn't have a centre: the Big Bang didn't happen at a point so there is no central point in the universe that it is expanding from.

The universe isn't expanding into anything: because the universe isn't expanding like a ball of fire, there is no space outside the universe that it is expanding into.

In the next section, I'll sketch out a rough description of how this can be, followed by a more detailed description for the more determined readers.
A simplified description of the Big Bang
Imagine measuring our current universe by drawing out a grid with a spacing of 1 light year. Although obviously, we can't do this, you can easily imagine putting the Earth at (0, 0), Alpha Centauri at (4.37, 0), and plotting out all the stars on this grid. The key thing is that this grid is infinite$^1$ i.e. there is no point where you can't extend the grid any further.
Now wind time back to 7 billion years after the big bang, i.e. about halfway back. Our grid now has a spacing of half a light year, but it's still infinite - there is still no edge to it. The average spacing between objects in the universe has reduced by half and the average density has gone up by a factor of $2^3$.
Now wind back to 0.0000000001 seconds after the big bang. There's no special significance to that number; it's just meant to be extremely small. Our grid now has a very small spacing, but it's still infinite. No matter how close we get to the Big Bang we still have an infinite grid filling all of space. You may have heard pop science programs describing the Big Bang as happening everywhere and this is what they mean. The universe didn't shrink down to a point at the Big Bang, it's just that the spacing between any two randomly selected spacetime points shrank down to zero.
So at the Big Bang, we have a very odd situation where the spacing between every point in the universe is zero, but the universe is still infinite. The total size of the universe is then $0 \times \infty$, which is undefined. You probably think this doesn't make sense, and actually, most physicists agree with you. The Big Bang is a singularity, and most of us don't think singularities occur in the real universe. We expect that some quantum gravity effect will become important as we approach the Big Bang. However, at the moment we have no working theory of quantum gravity to explain exactly what happens.
$^1$ we assume the universe is infinite - more on this in the next section
For determined readers only
To find out how the universe evolved in the past, and what will happen to it in the future, we have to solve Einstein's equations of general relativity for the whole universe. The solution we get is an object called the metric tensor that describes spacetime for the universe.
But Einstein's equations are partial differential equations, and as a result, have a whole family of solutions. To get the solution corresponding to our universe we need to specify some initial conditions. The question is then what initial conditions to use. Well, if we look at the universe around us we note two things:

if we average over large scales the universe looks the same in all directions, that is it is isotropic

if we average over large scales the universe is the same everywhere, that is it is homogeneous

You might reasonably point out that the universe doesn't look very homogeneous since it has galaxies with a high density randomly scattered around in space with a very low density. However, if we average on scales larger than the size of galaxy superclusters we do get a constant average density. Also, if we look back to the time the cosmic microwave background was emitted (380,000 years after the Big Bang and well before galaxies started to form) we find that the universe is homogeneous to about $1$ part in $10^5$, which is pretty homogeneous.
So as the initial conditions let's specify that the universe is homogeneous and isotropic, and with these assumptions, Einstein's equation has a (relatively!) simple solution. Indeed this solution was found soon after Einstein formulated general relativity and has been independently discovered by several different people. As a result the solution glories in the name Friedmann–Lemaître–Robertson–Walker metric, though you'll usually see this shortened to FLRW metric or sometimes FRW metric (why Lemaître misses out I'm not sure).
Recall the grid I described to measure out the universe in the first section of this answer, and how I described the grid shrinking as we went back in time towards the Big Bang? Well the FLRW metric makes this quantitative. If $(x, y, z)$ is some point on our grid then the current distance to that point is just given by Pythagoras' theorem:
$$ d^2 = x^2 + y^2 + z^2 $$
What the FLRW metric tells us is that the distance changes with time according to the equation:
$$ d^2(t) = a^2(t)(x^2 + y^2 + z^2) $$
where $a(t)$ is a function called the [scale factor]. We get the function for the scale factor when we solve Einstein's equations. Sadly it doesn't have a simple analytical form, but it's been calculated in answers to the previous questions What was the density of the universe when it was only the size of our solar system? and How does the Hubble parameter change with the age of the universe?. The result is:

The value of the scale factor is conventionally taken to be unity at the current time, so if we go back in time and the universe shrinks we have $a(t) < 1$, and conversely in the future as the universe expands we have $a(t) > 1$. The Big bang happens because if we go back to time to $t = 0$ the scale factor $a(0)$ is zero. This gives us the remarkable result that the distance to any point in the universe $(x, y, z)$ is:
$$ d^2(t) = 0(x^2 + y^2 + z^2) = 0 $$
so the distance between every point in the universe is zero. The density of matter (the density of radiation behaves differently but let's gloss over that) is given by:
$$ \rho(t) = \frac{\rho_0}{a^3(t)} $$
where $\rho_0$ is the density at the current time, so the density at time zero is infinitely large. At the time $t = 0$ the FLRW metric becomes singular.
No one I know thinks the universe did become singular at the Big Bang. This isn't a modern opinion: the first person I know to have objected publically was Fred Hoyle, and he suggested Steady State Theory to avoid the singularity. These days it's commonly believed that some quantum gravity effect will prevent the geometry from becoming singular, though since we have no working theory of quantum gravity no one knows how this might work.
So to conclude: the Big Bang is the zero time limit of the FLRW metric, and it's a time when the spacing between every point in the universe becomes zero and the density goes to infinity. It should be clear that we can't associate the Big Bang with a single spatial point because the distance between all points was zero so the Big Bang happened at all points in space. This is why it's commonly said that the Big Bang happened everywhere.
In the discussion above I've several times casually referred to the universe as infinite, but what I really mean is that it can't have an edge. Remember that our going-in assumption is that the universe is homogeneous i.e. it's the same everywhere. If this is true the universe can't have an edge because points at the edge would be different from points away from the edge. A homogenous universe must either be infinite, or it must be closed i.e. have the spatial topology of a 3-sphere. The recent Planck results show the curvature is zero to within experimental error, so if the universe is closed the scale must be far larger than the observable universe.


Question:
I often hear people talking about parallel computing and distributed computing, but I'm under the impression that there is no clear boundary between the 2, and people tend to confuse that pretty easily, while I believe it is very different:

Parallel computing is more tightly coupled to multi-threading, or how to make full use of a single CPU.
Distributed computing refers to the notion of divide and conquer, executing sub-tasks on different machines and then merging the results.

However, since we stepped into the Big Data era, it seems the distinction is indeed melting, and most systems today use a combination of parallel and distributed computing.
An example I use in my day-to-day job is Hadoop with the Map/Reduce paradigm, a clearly distributed system with workers executing tasks on different machines, but also taking full advantage of each machine with some parallel computing.
I would like to get some advice to understand how exactly to make the distinction in today's world, and if we can still talk about parallel computing or there is no longer a clear distinction. To me it seems distributed computing has grown a lot over the past years, while parallel computing seems to stagnate, which could probably explain why I hear much more talking about distributing computations than parallelizing.

This is partly a matter of terminology, and as such, only requires that you and the person you're talking to clarify it beforehand. However, there are different topics that are more strongly associated with parallelism, concurrency, or distributed systems.
Parallelism is generally concerned with accomplishing a particular computation as fast as possible, exploiting multiple processors. The scale of the processors may range from multiple arithmetical units inside a single processor, to multiple processors sharing memory, to distributing the computation on many computers. On the side of models of computation, parallelism is generally about using multiple simultaneous threads of computation internally, in order to compute a final result. Parallelism is also sometimes used for real-time reactive systems, which contain many processors that share a single master clock; such systems are fully deterministic.
Concurrency is the study of computations with multiple threads of computation. Concurrency tends to come from the architecture of the software rather than from the architecture of the hardware. Software may be written to use concurrency in order to exploit hardware parallelism, but often the need is inherent in the software's behavior, to react to different asynchronous events (e.g. a computation thread that works independently of a user interface thread, or a program that reacts to hardware interrupts by switching to an interrupt handler thread).
Distributed computing studies separate processors connected by communication links. Whereas parallel processing models often (but not always) assume shared memory, distributed systems rely fundamentally on message passing. Distributed systems are inherently concurrent. Like concurrency, distribution is often part of the goal, not solely part of the solution: if resources are in geographically distinct locations, the system is inherently distributed. Systems in which partial failures (of processor nodes or of communication links) are possible fall under this domain.


Question:
Searching an array of $N$ elements using binary search takes, in the worst case $\log_2 N$ iterations because, at each step we trim half of our search space.
If, instead, we used 'ternary search', we'd cut away two-thirds of our search space at each iteration, so the worst case should take $\log_3 N < \log_2 N$ iterations...
It seems that ternary search is faster, so why do we use binary search?

If you apply binary search, you have $$\log_2(n)+O(1)$$ many comparisons. If you apply ternary search, you have $$ 2 \cdot \log_3(n) + O(1)$$ many comparisons, as in each step, you need to perform 2 comparisons to cut the search space into three parts. Now if you do the math, you can observe that:
 $$ 2 \cdot \log_3(n) + O(1) = 2 \cdot \frac{\log(2)}{\log(3)} \log_2(n)+ O(1) $$ Since we know that $2 \cdot \frac{\log(2)}{\log(3)} > 1$, we actually get more comparisons with ternary search.
By the way: $n$-ary search may make a lot of sense in case if comparisons are quite costly and can be parallelized, as then, parallel computers can be applied.
Note that argument can be generalized to $n$-ary search quite easily. You just need to show that the function $f(k) = (k-1) \cdot \frac{\log(2)}{\log(k)}$ is strictly monotone increasing for integer values of $k$.


Question:
In a galvanic (voltaic) cell, the anode is considered negative and the cathode is considered positive. This seems reasonable as the anode is the source of electrons and cathode is where the electrons flow.
However, in an electrolytic cell, the anode is taken to be positive while the cathode is now negative. However, the reaction is still similar, whereby electrons from the anode flow to the positive terminal of the battery, and electrons from the battery flow to the cathode.
So why does the sign of the cathode and anode switch when considering an electrolytic cell?

The anode is the electrode where the oxidation reaction
\begin{align}
 \ce{Red -> Ox + e-}
\end{align}
takes place while the cathode is the electrode where the reduction reaction
\begin{align}
 \ce{Ox + e- -> Red}
\end{align}
takes place. That's how cathode and anode are defined.
Galvanic cell
Now, in a galvanic cell the reaction proceeds without an external potential helping it along. Since at the anode you have the oxidation reaction which produces electrons you get a build-up of negative charge in the course of the reaction until electrochemical equilibrium is reached. Thus the anode is negative.
At the cathode, on the other hand, you have the reduction reaction which consumes electrons (leaving behind positive (metal) ions at the electrode) and thus leads to a build-up of positive charge in the course of the reaction until electrochemical equilibrium is reached. Thus the cathode is positive.
Electrolytic cell
In an electrolytic cell, you apply an external potential to enforce the reaction to go in the opposite direction. Now the reasoning is reversed. At the negative electrode where you have produced a high electron potential via an external voltage source electrons are "pushed out" of the electrode, thereby reducing the oxidized species $\ce{Ox}$, because the electron energy level inside the electrode (Fermi Level) is higher than the energy level of the LUMO of $\ce{Ox}$ and the electrons can lower their energy by occupying this orbital - you have very reactive electrons so to speak. So the negative electrode will be the one where the reduction reaction will take place and thus it's the cathode.
At the positive electrode where you have produced a low electron potential via an external voltage source electrons are "sucked into" the electrode leaving behind the the reduced species $\ce{Red}$ because the electron energy level inside the electrode (Fermi Level) is lower than the energy level of the HOMO of $\ce{Red}$. So the positive electrode will be the one where the oxidation reaction will take place and thus it's the anode.
A tale of electrons and waterfalls
Since there is some confusion concerning the principles on which an electrolysis works, I'll try a metaphor to explain it. Electrons flow from a region of high potential to a region of low potential much like water falls down a waterfall or flows down an inclined plane. The reason is the same: water and electrons can lower their energy this way. Now the external voltage source acts like two big rivers connected to waterfalls: one at a high altitude that leads towards a waterfall - that would be the minus pole - and one at a low altitude that leads away from a waterfall - that would be the plus pole. The electrodes would be like the points of the river shortly before or after the waterfalls in this picture: the cathode is like the edge of a waterfall where the water drops down and the anode is like the point where the water drops into.
Ok, what happens at the electrolysis reaction? At the cathode, you have the high altitude situation. So the electrons flow to the "edge of their waterfall". They want to "fall down" because behind them the river is pushing towards the edge exerting some kind of "pressure". But where can they fall down to? The other electrode is separated from them by the solution and usually a diaphragm. But there are $\ce{Ox}$ molecules that have empty states that lie energetically below that of the electrode. Those empty states are like small ponds lying at a lower altitude where a little bit of the water from the river can fall into. So every time such an $\ce{Ox}$ molecule comes near the electrode an electron takes the opportunity to jump to it and reduce it to $\ce{Red}$. But that does not mean that the electrode is suddenly missing an electron because the river is replacing the "pushed out" electron immediately. And the voltage source (the source of the river) can't run dry of electrons because it gets its electrons from the power socket.
Now the anode: At the anode, you have the low altitude situation. So here the river lies lower than everything else. Now you can imagine the HOMO-states of the $\ce{Red}$ molecules as small barrier lakes lying at a higher altitude than our river. When a $\ce{Red}$ molecule comes close to the electrode it is like someone opening the floodgates of the barrier lake's dam. The electrons flow from the HOMO into the electrode thus creating an $\ce{Ox}$ molecule. But the electrons don't stay in the electrode, so to speak, they are carried away by the river. And since the river is such a vast entity (lots of water) and usually flows into an ocean, the little "water" that is added to it doesn't change the river much. It stays the same, unaltered so that everytime a floodgate gets opened the water from the barrier lake will drop the same distance.


Question:
After reading a dataset:
dataset <- read.csv("forR.csv")

How can I get R to give me the number of cases it contains?
Also, will the returned value include of exclude cases omitted with na.omit(dataset)?

dataset will be a data frame. As I don't have forR.csv, I'll make up a small data frame for illustration:
set.seed(1)
dataset <- data.frame(A = sample(c(NA, 1:100), 1000, rep = TRUE),
                      B = rnorm(1000))

> head(dataset)
   A           B
1 26  0.07730312
2 37 -0.29686864
3 57 -1.18324224
4 91  0.01129269
5 20  0.99160104
6 90  1.59396745

To get the number of cases, count the number of rows using nrow() or NROW():
> nrow(dataset)
[1] 1000
> NROW(dataset)
[1] 1000

To count the data after omitting the NA, use the same tools, but wrap dataset in na.omit():
> NROW(na.omit(dataset))
[1] 993

The difference between NROW() and NCOL() and their lowercase variants (ncol() and nrow()) is that the lowercase versions will only work for objects that have dimensions (arrays, matrices, data frames). The uppercase versions will work with vectors, which are treated as if they were a 1 column matrix, and are robust if you end up subsetting your data such that R drops an empty dimension.
Alternatively, use complete.cases() and sum it (complete.cases() returns a logical vector [TRUE or FALSE] indicating if any observations are NA for any rows.
> sum(complete.cases(dataset))
[1] 993


Question:
This question is an extension of two discussions that came up recently in the replies to "C++ vs Fortran for HPC". And it is a bit more of a challenge than a question...
One of the most often-heard arguments in favor of Fortran is that the compilers are just better. Since most C/Fortran compilers share the same back end, the code generated for semantically equivalent programs in both languages should be identical. One could argue, however, that C/Fortran is more/less easier for the compiler to optimize.
So I decided to try a simple test: I got a copy of daxpy.f and daxpy.c and compiled them with gfortran/gcc.
Now daxpy.c is just an f2c translation of daxpy.f (automatically generated code, ugly as heck), so I took that code and cleaned it up a bit (meet daxpy_c), which basically meant re-writing the innermost loop as
for ( i = 0 ; i < n ; i++ )
    dy[i] += da * dx[i];

Finally, I re-wrote it (enter daxpy_cvec) using gcc's vector syntax:
#define vector(elcount, type)  __attribute__((vector_size((elcount)*sizeof(type)))) type
vector(2,double) va = { da , da }, *vx, *vy;

vx = (void *)dx; vy = (void *)dy;
for ( i = 0 ; i < (n/2 & ~1) ; i += 2 ) {
    vy[i] += va * vx[i];
    vy[i+1] += va * vx[i+1];
    }
for ( i = n & ~3 ; i < n ; i++ )
    dy[i] += da * dx[i];

Note that I use vectors of length 2 (that's all SSE2 allows) and that I process two vectors at a time. This is because on many architectures, we may have more multiplication units than we have vector elements.
All codes were compiled using gfortran/gcc version 4.5 with the flags "-O3 -Wall -msse2 -march=native -ffast-math -fomit-frame-pointer -malign-double -fstrict-aliasing". On my laptop (Intel Core i5 CPU, M560, 2.67GHz) I got the following output:
pedro@laika:~/work/fvsc$ ./test 1000000 10000
timing 1000000 runs with a vector of length 10000.
daxpy_f took 8156.7 ms.
daxpy_f2c took 10568.1 ms.
daxpy_c took 7912.8 ms.
daxpy_cvec took 5670.8 ms.

So the original Fortran code takes a bit more than 8.1 seconds, the automatic translation thereof takes 10.5 seconds, the naive C implementation does it in 7.9 and the explicitly vectorized code does it in 5.6, marginally less.
That's Fortran being slightly slower than the naive C implementation and 50% slower than the vectorized C implementation.
So here's the question: I'm a native C programmer and so I'm quite confident that I did a good job on that code, but the Fortran code was last touched in 1993 and might therefore be a bit out of date. Since I don't feel as comfortable coding in Fortran as others here may, can anyone do a better job, i.e. more competitive compared to any of the two C versions?
Also, can anybody try this test with icc/ifort? The vector syntax probably won't work, but I would be curious to see how the naive C version behaves there. Same goes for anybody with xlc/xlf lying around.
I've uploaded the sources and a Makefile here. To get accurate timings, set CPU_TPS in test.c to the number of Hz on your CPU. If you find any improvements to any of the versions, please do post them here!
Update:
I've added stali's test code to the files online and supplemented it with a C version. I modified the programs to do 1'000'000 loops on vectors of length 10'000 to be consistent with the previous test (and because my machine couldn't allocate vectors of length 1'000'000'000, as in stali's original code). Since the numbers are now a bit smaller, I used the option -par-threshold:50 to make the compiler more likely to parallelize. The icc/ifort version used is 12.1.2 20111128 and the results are as follows
pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=1 time ./icctest_c
3.27user 0.00system 0:03.27elapsed 99%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=1 time ./icctest_f
3.29user 0.00system 0:03.29elapsed 99%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=2 time ./icctest_c
4.89user 0.00system 0:02.60elapsed 188%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=2 time ./icctest_f
4.91user 0.00system 0:02.60elapsed 188%CPU

In summary, the results are, for all practical purposes, identical for both the C and Fortran versions, and both codes parallelize automagically. Note that the fast times compared to the previous test are due to the use of single-precision floating point arithmetic!
Update:
Although I don't really like where the burden of proof is going here, I've re-coded stali's matrix multiplication example in C and added it to the files on the web. Here are the results of the tripple loop for one and two CPUs:
pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=1 time ./mm_test_f 2500
 triple do time   3.46421700000000
3.63user 0.06system 0:03.70elapsed 99%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=1 time ./mm_test_c 2500
triple do time 3.431997791385768
3.58user 0.10system 0:03.69elapsed 99%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=2 time ./mm_test_f 2500
 triple do time   5.09631900000000
5.26user 0.06system 0:02.81elapsed 189%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=2 time ./mm_test_c 2500
triple do time 2.298916975280899
4.78user 0.08system 0:02.62elapsed 184%CPU

Note that cpu_time in Fortran measuers the CPU time and not the wall-clock time, so I wrapped the calls in time to compare them for 2 CPUs. There is no real difference between the results, except that the C version does a bit better on two cores.
Now for the matmul command, of course only in Fortran as this intrinsic is not available in C:
pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=1 time ./mm_test_f 2500
 matmul    time   23.6494780000000
23.80user 0.08system 0:23.91elapsed 99%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=2 time ./mm_test_f 2500
 matmul    time   26.6176640000000
26.75user 0.10system 0:13.62elapsed 197%CPU

Wow. That's absolutely terrible. Can anyone either find out what I'm doing wrong, or explain why this intrinsic is still somehow a good thing?
I didn't add the dgemm calls to the benchmark as they are library calls to the same function in the Intel MKL.
For future tests, can anyone suggest an example known to be slower in C than in Fortran?
Update
To verify stali's claim that the matmul intrinsic is "an order of magnitue" faster than the explicit matrix product on smaller matrices, I modified his own code to multiply matrices of size 100x100 using both methods, 10'000 times each. The results, on one and two CPUs, are as follows:
pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=1 time ./mm_test_f 10000 100
 matmul    time   3.61222500000000
 triple do time   3.54022200000000
7.15user 0.00system 0:07.16elapsed 99%CPU

pedro@laika:~/work/fvsc$ OMP_NUM_THREADS=2 time ./mm_test_f 10000 100
 matmul    time   4.54428400000000
 triple do time   4.31626900000000
8.86user 0.00system 0:04.60elapsed 192%CPU

Update
Grisu is correct in pointing out that, without optimizations, gcc converts operations on complex numbers to library function calls while gfortran inlines them in a few instructions.
The C compiler will generate the same, compact code if the option -fcx-limited-range is set, i.e. the compiler is instructed to ignore potential over/under-flows in the intermediate values. This option is somehow set by default in gfortran and may lead to incorrect results. Forcing -fno-cx-limited-range in gfortran didn't change anything.
So this is actually an argument against using gfortran for numerical calculations: Operations on complex values may over/under-flow even if the correct results are within the floating-point range. This is actually a Fortran standard. In gcc, or in C99 in general, the default is to do things strictly (read IEEE-754 compliant) unless otherwise specified.
Reminder: Please keep in mind that the main question was whether Fortran compilers produce better code than C compilers. This is not the place for discussions as to the general merits of one language over another. What I would be really interested in is if anybody can find a way of coaxing gfortran to produce a daxpy as efficient as the one in C using explicit vectorization as this exemplifies the problems of having to rely on the compiler exclusively for SIMD optimization, or a case in which a Fortran compiler out-does its C counterpart.

The difference in your timings seems to be due to the manual unrolling of the unit-stride Fortran daxpy. The following timings are on a 2.67 GHz Xeon X5650, using the command
./test 1000000 10000

Intel 11.1 compilers
Fortran with manual unrolling: 8.7 sec
Fortran w/o manual unrolling: 5.8 sec
C w/o manual unrolling: 5.8 sec
GNU 4.1.2 compilers
Fortran with manual unrolling: 8.3 sec
Fortran w/o manual unrolling: 13.5 sec
C w/o manual unrolling: 13.6 sec
C with vector attributes: 5.8 sec
GNU 4.4.5 compilers
Fortran with manual unrolling: 8.1 sec
Fortran w/o manual unrolling: 7.4 sec
C w/o manual unrolling: 8.5 sec
C with vector atrributes: 5.8 sec
Conclusions

Manual unrolling helped the GNU 4.1.2 Fortran compilers on this architecture, but hurts the newer version (4.4.5) and the Intel Fortran compiler.
The GNU 4.4.5 C compiler is much more competitive with Fortran than for version 4.2.1.
Vector intrinsics allow the GCC performance to match the Intel compilers.

Time to test more complicated routines like dgemv and dgemm?


Question:
Here is a question for image processing experts.
I am working on a difficult computer vision problem. The task is to count the stomata (marked below) in DIC microscopy images.  These images are resistant to most superficial image processing techniques like morphological operations and edge detection. It is also different from other cell counting tasks.
I am  using OpenCV. My plan is to review potentially useful features for stomata discrimination.

Texture classifiers

DCT (Discrete cosine transform/frequency-domain analysis)
LBP (Local binary patterns)

HOG (Histogram of oriented gradients)
Robust feature detectors (I am skeptical)

Harris corners
SIFT, SURF, STAR, etc.

Haar cascade classifier/Viola-Jones features

And possibly design a novel feature descriptor. I am leaving out the selection of a classifier for now.
What have I missed?  How would you solve this? Solutions for similar object detection problems would be very helpful.
Sample images here.

After bandpass filter:

Canny edge detection is not promising. Some image areas are out of focus:

Sorry I don't know OpenCV, and this is more a pre-processing step than a complete answer:
First, you don't want an edge detector.  An edge detector converts transitions (like this dark-to-light):

into ridges (bright lines on dark) like this:

It performs a differentiation, in other words.
But in your images, there is a light shining down from one direction, which shows us the relief of the 3D surface.  We perceive this as lines and edges, because we're used to seeing things in 3D, but they aren't really, which is why edge detectors aren't working, and template matching won't work easily with rotated images (a perfect match at 0 degrees rotation would actually cancel out completely at 180 degrees, because light and dark would line up with each other).
If the height of one of these mazy lines looks like this from the side:

then the brightness function when illuminated from one side will look like this:

This is what you see in your images.  The facing surface becomes brighter and the trailing surface becomes darker.  So you don't want to differentiate.  You need to integrate the image along the direction of illumination, and it will give you the original height map of the surface (approximately).  Then it will be easier to match things, whether through Hough transform or template matching or whatever.
I'm not sure how to automate finding the direction of illumination.  If it's the same for all your images, great.  Otherwise you'd have to find the biggest contrast line and assume the light is perpendicular to it or something.  For my example, I rotated the image manually to what I thought was the right direction, with light coming from the left:

You also need to remove all the low-frequency changes in the image, though, to highlight only the quickly-changing line-like features.  To avoid ringing artifacts, I used 2D Gaussian blur and then subtracted that from the original:

The integration (cumulative sum) can runaway easily, which produces horizontal streaks.  I removed these with another Gaussian high-pass, but only in the horizontal direction this time:

Now the stomata are white ellipses all the way around, instead of white in some places and black in others.
Original:

Integrated:

from pylab import *
import Image
from scipy.ndimage import gaussian_filter, gaussian_filter1d

filename = 'rotated_sample.jpg'
I = Image.open(filename).convert('L')
I = asarray(I)

# Remove DC offset
I = I - average(I)

close('all')
figure()
imshow(I)
gray()
show()
title('Original')

# Remove slowly-varying features
sigma_2d = 2
I = I - gaussian_filter(I, sigma_2d)

figure()
imshow(I)
title('2D filtered with %s' % sigma_2d)

# Integrate
summed = cumsum(I, 1)

# Remove slowly-changing streaks in horizontal direction
sigma_1d = 5
output = summed - gaussian_filter1d(summed, sigma_1d, axis=1)

figure()
imshow(output)
title('1D filtered with %s' % sigma_1d)

The Hough transform can be used to detect ridge ellipses like this, made of "edge pixels", though it's really expensive in computation and memory, and they are not perfect ellipses so it would have to be a bit of a "sloppy" detector.  I've never done it, but there are a lot of Google results for "hough ellipse detection".  I'd say if you detect one ellipse inside the other, within a certain size search space, it should be counted as a stoma.
Also see:

OpenCV: How to detect a ellipse in the binary image
Python and OpenCV. How do I detect all (filled)circles/round objects in an image?
Detection of coins (and fit ellipses) on an image


Question: I am a bit confused. What is the difference between a linear and affine function? Any suggestions will be appreciated.

A linear function fixes the origin, whereas an affine function need not do so. An affine function is the composition of a linear function with a translation, so while the linear part fixes the origin, the translation can map it somewhere else.
Linear functions between vector spaces preserve the vector space structure (so in particular they must fix the origin). While affine functions don't preserve the origin, they do preserve some of the other geometry of the space, such as the collection of straight lines.
If you choose bases for vector spaces $V$ and $W$ of dimensions $m$ and $n$ respectively, and consider functions $f\colon V\to W$, then $f$ is linear if $f(v)=Av$ for some $n\times m$ matrix $A$ and $f$ is affine if $f(v)=Av+b$ for some matrix $A$ and vector $b$, where coordinate representations are used with respect to the bases chosen.


Question:
Many times, when I've inherited or encountered scientific code written by other people (or occasionally, even my own work), I've noticed that documentation is either sparse or nonexistent. If I'm lucky, I see informative comments. If I'm very lucky, there's even Doxygen comments and a Doxyfile so that I have function interfaces and some formatted HTML to consult. If I'm extremely lucky, there's a PDF manual and examples in addition to the Doxygen and source file comments, and I'm ecstatic, because it makes my life much, much easier.
What information and tools are useful in documenting source code? For that matter, what information and tools are useful to document the data and results that accompany that source code, in the case of scientific software?

I think that documentation for scientific software can be divided into three categories, all of which are necessary for full understanding. The easiest and most common is individual method documentation. There are many systems for this. You mention doxygen, Python has pydoc, and in PETSc we have our own package sowing which generates the following.
However, for any piece of software which goes beyond a simple utility, you need a manual. This provides a high-level view of the purpose of the package, and how its different functionalities integrate to achieve this purpose. It helps a new user structure their code, often through the use of examples. In PETSc, we just use LaTeX for the manual, but the PyClaw package uses the Sphinx framework which I am very impressed with. One thing that we have implemented in the sowing package that I find very useful is the link between example code and function documentation. For example, this example solves the Bratu equation. Notice how you can follow the links for any custom type or function call and get to the low-level documentation, and how those pages link back to examples using them. This is how I learn about new functionality which other people in the project contribute.
A frequently overlooked part of documentation, I think, is developer documentation. It is not uncommon to publish a coding-style document, and instructions for interacting with the repository. However, it is very rare to explain the design decisions made before implementation. These decisions always involve tradeoffs, and the situation with respect to hardware and algorithms will necessarily change over time. Without a discussion of the tradeoffs reviewed and rationale for particular design decisions, later programmers are left to recreate the entire process on their own. I think this is a major impediment to successful maintenance and improvement of old codes when the original developers are no longer in charge.


Question:
There have been various explanations posited for the α-effect. The α-effect refers to a phenomenon wherein nucleophiles with lone pairs on atoms adjacent (i.e., in the α- position) to the atom bearing the reacting lone pair sometimes exhibit dramatically higher reactivity than similar nucleophiles without α-electrons. This effect is especially adduced when no associated increase in Brønsted basicity occurs. For example, hydroperoxide ($\ce{HOO-}$) experimental reaction rate constants are orders of magnitude greater[1] those of hydroxide ($\ce{HO-}$) with various electrophilic substrates, despite the former exhibiting lower Brønsted basicity. There is also a thermodynamic α-effect, in which equilibrium constants are enhanced[2]. It is currently on the list of unsolved problems in chemistry on Wikipedia, but, due to a lack of references to that effect, I'm not entirely convinced it really should be listed there. Here's the summary of my research on the topic thus far:

I read Ren, Y. & Yamataka, H.[3], "The alpha-effect in gas-phase SN2 reactions revisited". In it, they claim that explanations based on ground-state destabilization (presumably due to repulsion between the electrons of the nucleophilic atom and the α-electrons) are not correct. Their reasoning is that this would result in a difference in the $\Delta G$ between reactants and products, leading to thermodynamic equilibrium effects. They argue that a correct explanation should be one exclusively involving stabilization of the transition state (i.e., minimization of $\Delta G^{\ddagger}$), and go on to offer some explanation for how this may occur (along with experimental data). Intuitively, their conclusion seems reasonable to me, and it also (at least to my naive comprehension) seems eminently testable. I don't know whether equilibrium effects consistent with ground-state destabilization have actually been observed or not; however, if they haven't, shouldn't that put the nail in the coffin of that theory? Or is it simply that the authors are searching for a purely kinetic α-effect, so that a distinction between a thermodynamic one needs to be made?
Fleming devotes a section to the effect in his book, Molecular Orbitals and Organic Chemical Reactions. He notes that the presence of the α-lone pair should raise the energy of the HOMO of the nucleophile, but also points that experimental results don't correlate sufficiently well with the HOMO energies of various α-nucleophiles. In particular, certain soft electrophiles (per HSAB theory), such as alkyl halides, apparently show an anomalous low preference for α-nucleophiles. In the context of SET mechanisms, Fleming says that the higher energy of the HOMO and the availability of α-electrons (which can stabilize a radical intermediate) ought to have a highly favorable effect on the rate of reaction, and notes that experimental results have borne this out. My interpretation of this is that, while the picture is perhaps murky for anionic mechanisms, transition-state stabilization clearly seems to be operative in SET mechanisms.

I've also read the original 1962 paper by Pearson and Edwards[4], which also largely argued for transition-state stabilization as the primary explanatory mechanism.
Overall, from my reading thus far, it seems that transition-state stabilization has been most consistently invoked and has the largest wealth of evidence and the most plausible arguments supporting it. What I'd like to ask is, (a) are there flaws in my reasoning or understanding of the material, and (b) is this truly a fundamentally unsolved problem, or is there actually some emerging consensus among experts?

Notes and References

Fleming provides a small table with relative rates ($k_\mathrm{rel} = k_{\ce{HOO-}}/k_{\ce{HO-}}$) in his book. For example, he gives $k_\mathrm{rel} \approx 10^5$ for reaction with $\ce{PhCN}$ and $k_\mathrm{rel} \approx 50$ for $\ce{PhCH2Br}$, while $k_\mathrm{rel} \approx 10^{-4}$ for reaction with $\ce{H3O+}$. The rate of reaction correlates in the expected way with Brønsted basicity only in the case of proton transfer.
Again, citing Fleming, he gives the example of the reaction of N-acetylimidazole with hydroxylamines, in which both rate and equilibrium constants are positively affected. Qualitatively, he explains this by noting that the α-electrons raise the energy of the lone pair conjugated to the π-system, making overlap of said lone pair with the π* LUMO more effective. Additionally, he claims both ground-state stabilization and transition-state destabilization as being factors in the reduced electrophilicity of oximes and hydrazones relative to (most) other standard imines.
Ren, Y.; Yamataka, H. The α-Effect in Gas-Phase SN2 Reactions Revisited. Org. Lett. 2006, 8 (1), 119–121. DOI: 10.1021/ol0526930.
Edwards, J. O.; Pearson, R. G. The Factors Determining Nucleophilic Reactivities. J. Am. Chem. Soc. 1962, 84 (1), 16–24. DOI: 10.1021/ja00860a005.

I am not a kineticist, and my quantum chemistry is long, long out of date, but what I was about to say was that I'd guess the reason the "effect" is "unsolved" is that it's not real.
That is, it is not a property of a single reactant while disregarding its environment (gas phase, solvent interactions). Then I saw that the two recent articles both were about solvation, so my comment is redundant (and certainly only a partially/inadequately educated guess). I'd also comment that comparing $\ce{HO-}$ with $\ce{HOO-}$ is apples and oranges. You should compare it with a species with an alpha atom which is electronegative but doesn't have a lone pair.
If it doesn't really have a published DFT model, then it might be good for an MS student to work on. I suspect answering it is like "curing cancer", it doesn't have just one  'reason', rather the cures depend on the exact nature of the reaction (including solvation).


Question:
I recently purchased a Weller WES51 soldering iron as my first temperature controlled iron and I'm looking for recommendations on the best default temperature to use when soldering.
I'm using mainly .031 inch 60/40 solder on through-hole components.

What’s the proper soldering iron temperature for standard .031" 60/40 solder?

There is no proper soldering iron temperature just for a given type of solder - the iron temperature should be set for both the component and the solder.
When soldering surface mount components, a small tip and 600F (315C) should be sufficient to quickly solder the joint well without overheating the component.
When soldering through hole components, 700F (370C) is useful to pump more heat into the wire and plated hole to solder it quickly.
A negative capacitor lead to a heatsinking solid pour ground plane is going to need a big fat tip at a much higher temperature.
However, I don't micromanage my soldering temperature, and simply keep mine at 700F (370C).  I'll change the tips according to what I'm soldering, and the tip size really ends up determining how much heat gets into the joint in a given period of contact.
I think you'll find that very few soldering jobs will really require you to change your tip temperature.
Keep in mind that the ideal situation is that the soldering iron heats up the joint enough that the joint melts the solder - not the iron.  So the iron is expected to be hotter than the melting point of the solder so that the entire joint comes up to the melting point of the solder quickly.
The more quickly you bring the joint temperature up and solder it, the less time the soldering iron is on the joint, and thus the less heat gets transferred to the component.  It's not a big deal for many passive or small components, but it turns out that overall a higher tip temperature results in faster soldering and less likely damage to the component being soldered.
So if you do use higher tip temperatures, don't leave them on components any longer than necessary.  Apply the iron, apply the solder, and remove both - it should take just a second or maybe two for surface mount, and 1-3 seconds for a through hole part.
Please note that I'm talking about prototyping, hobbyist, and one-off projects.  If you are planning on doing final assembly with the iron, repair work for critical projects, etc, then you'll need to consider what you're doing more carefully than this general rule of thumb.


Question: I know how to downsample a BAM file to lower coverage. I know I can randomly select lines in SAM, but this procedure can't guarantee two reads in a pair are always sampled the same time. Is there a way to downsample BAM while keeping pairing information intact?

samtools has a subsampling option:

-s FLOAT:
  Integer part is used to seed the random number generator [0]. Part after the decimal point sets the fraction of templates/pairs to subsample [no subsampling]

samtools view -bs 42.1 in.bam > subsampled.bam

will subsample 10 percent mapped reads with 42 as the seed for the random number generator.


Question:
I have become a bit confused about these topics. They've all started looking the same to me. They seem to have the same properties such as linearity, shifting and scaling associated with them. I can't seem to put them separately and identify the purpose of each transform. Also, which one of these is used for frequency analysis?
I couldn't find (with Google) a complete answer that addresses this specific issue. I wish to see them compared on the same page so that I can have some clarity.

The Laplace and Fourier transforms are continuous (integral) transforms of continuous functions.
The Laplace transform maps a function \$f(t)\$ to a function \$F(s)\$ of the complex variable s, where \$s = \sigma + j\omega\$.
Since the derivative \$\dot f(t) = \frac{df(t)}{dt} \$ maps to \$sF(s)\$, the Laplace transform of a linear differential equation is an algebraic equation.  Thus, the Laplace transform is useful for, among other things, solving linear differential equations.
If we set the real part of the complex variable s to zero, \$ \sigma = 0\$, the result is the Fourier transform \$F(j\omega)\$ which is essentially the frequency domain representation of \$f(t)\$ (note that this is true only if for that value of \$ \sigma\$ the formula to obtain the Laplace transform of \$f(t)\$ exists, i.e., it does not go to infinity).
The Z transform is essentially a discrete version of the Laplace transform and, thus, can be useful in solving difference equations, the discrete version of differential equations.  The Z transform maps a sequence \$f[n]\$ to a continuous function \$F(z)\$ of the complex variable \$z = re^{j\Omega}\$.
If we set the magnitude of z to unity, \$r = 1\$, the result is the Discrete Time Fourier Transform (DTFT) \$ F(j\Omega)\$ which is essentially the frequency domain representation of \$f[n]\$.


Question: Well, we've got favourite statistics quotes. What about statistics jokes?

A guy is flying in a hot air balloon and he's lost. So he lowers himself over a field and shouts to a guy on the ground:
"Can you tell me where I am, and which way I'm headed?"
"Sure!  You're at 43 degrees, 12 minutes, 21.2 seconds north; 123 degrees, 8 minutes, 12.8 seconds west. You're at 212 meters above sea level. Right now, you're hovering, but on your way in here you were at a speed of 1.83 meters per second at 1.929 radians"
"Thanks! By the way, are you a statistician?"
"I am! But how did you know?"
"Everything you've told me is completely accurate; you gave me more detail than I needed, and you  told me in such a way that it's no use to me at all!"
"Dang! By the way, are you a principal investigator?"
"Geeze!  How'd you know that????"
"You don't know where you are, you don't know where you're going. You got where you are by blowing hot air, you start asking questions after you get into trouble, and you're in exactly the same spot you were a few minutes ago, but now, somehow, it's my fault!


Question: Most books refer to a steep rise in pH when a titration reaches the equivalence point. However, I do not understand why … I mean I am adding the same drops of acid to the alkali but just as I near the correct volume (i.e. the volume required to neutralize the alkali), the pH just suddenly increases quickly.

I've decided to tackle this question in a somewhat different manner. Instead of giving the chemical intuition behind it, I wanted to check for myself if the mathematics actually work out. As far as I understand, this isn't done often, so that's why I wanted to try it, even though it may not make the clearest answer. It turns out to be a bit complicated, and I haven't done much math in a while, so I'm kinda rusty. Hopefully, everything is correct. I would love to have someone check my results.
My approach here is to explicitly find the equation of a general titration curve and figure out from that why the pH varies quickly near the equivalence point. For simplicity, I shall consider the titration to be between a monoprotic acid and base. Explicitly, we have the following equilibria in solution
$$\ce{HA <=> H^+ + A^-} \ \ \ → \ \ \ K_\text{a} = \ce{\frac{[H^+][A^-]}{[HA]}}$$
$$\ce{BOH <=> B^+ + OH^-} \ \ \ → \ \ \ K_\text{b} = \ce{\frac{[OH^-][B^+]}{[BOH]}}$$
$$\ce{H2O <=> H^+ + OH^-} \ \ \ → \ \ \ K_\text{w} = \ce{[H^+][OH^-]}$$
Let us imagine adding two solutions, one of the acid $\ce{HA}$ with volume $V_\text{A}$ and concentration $C_\text{A}$, and another of the base $\ce{BOH}$ with volume $V_\text{B}$ and concentration $C_\text{B}$. Notice that after mixing the solutions, the number of moles of species containing $\ce{A}$ ($\ce{HA}$ or $\ce{A^-}$) is simply $n_\text{A} = C_\text{A} V_\text{A}$, while the number of moles of species containing $\ce{B}$ ($\ce{BOH}$ or $\ce{B^+}$) is $n_\text{B} = C_\text{B} V_\text{B}$. Notice that at the equivalence point, $n_\text{A} = n_\text{B}$ and therefore $C_\text{A} V_\text{A} = C_\text{B} V_\text{B}$; this will be important later. We will assume that volumes are additive (total volume $V_\text{T} = V_\text{A} + V_\text{B}$), which is close to true for relatively dilute solutions.
In search of an equation
To solve the problem of finding the final equilibrium after adding the solutions, we write out the charge balance and matter balance equations:
Charge balance: $\ce{[H^+] + [B^+] = [A^-] + [OH^-]}$
Matter balance for $\ce{A}$: $\displaystyle \ce{[HA] + [A^-]} = \frac{C_\text{A} V_\text{A}}{V_\text{A} + V_\text{B}}$
Matter balance for $\ce{B}$: $\displaystyle \ce{[BOH] + [B^+]} = \frac{C_\text{B} V_\text{B}} {V_\text{A} + V_\text{B}}$
A titration curve is given by the pH on the $y$-axis and the volume of added acid/base on the $x$-axis. So what we need is to find an equation where the only variables are $\ce{[H^+]}$ and $V_\text{A}$ or $V_\text{B}$. By manipulating the dissociation constant equations and the mass balance equations, we can find the following:
$$\ce{[HA]} = \frac{\ce{[H^+][A^-]}}{K_\text{a}}$$ $$\ce{[BOH]} = \frac{\ce{[B^+]}K_\text{w}}{K_\text{b}\ce{[H^+]}}$$ $$\ce{[A^-]} = \frac{C_\text{A} V_\text{A}}{V_\text{A} + V_\text{B}} \left(\frac{K_\text{a}}{K_\text{a} + \ce{[H^+]}}\right)$$ $$\ce{[B^+]} = \frac{C_\text{B} V_\text{B}}{V_\text{A} + V_\text{B}} \left(\frac{K_\text{b}\ce{[H^+]}}{K_\text{b}\ce{[H^+]} + K_\text{w}}\right)$$
Replacing those identities in the charge balance equation, after a decent bit of algebra, yields:
$$\ce{[H^+]^4} + \left(K_\text{a} + \frac{K_\text{w}}{K_\text{b}} + \frac{C_\text{B} V_\text{B}}{V_\text{A} + V_\text{B}}\right) \ce{[H^+]^3} + \left(\frac{K_\text{a}}{K_\text{b}}K_\text{w} + \frac{C_\text{B} V_\text{B}}{V_\text{A} + V_\text{B}} K_\text{a} - \frac{C_\text{A} V_\text{A}}{V_\text{A} + V_\text{B}}K_\text{a} - K_\text{w}\right) \ce{[H^+]^2} - \left(K_\text{a} K_\text{w} + \frac{C_\text{A} V_\text{A}}{V_\text{A} + V_\text{B}}\frac{K_\text{a}}{K_\text{b}} K_\text{w} + \frac{K^2_\text{w}}{K_\text{b}}\right) \ce{[H^+]} - \frac{K_\text{a}}{K_\text{b}} K^2_\text{w} = 0$$
Now, this equation sure looks intimidating, but it is very interesting. For one, this single equation will exactly solve any equilibrium problem involving the mixture of any monoprotic acid and any monoprotic base, in any concentration (as long as they're not much higher than about $1~\mathrm{\small M}$) and any volume. Though it doesn't seem to be possible to separate the variables $\ce{[H^+]}$ and $V_\text{A}$ or $V_\text{B}$, the graph of this equation represents any titration curve (as long as it obeys the previous considerations). Though in its full form it is quite daunting, we can obtain some simpler versions. For example, consider that the mixture is of a weak acid and a strong base. This means that $K_\text{b} \gg 1$, and so every term containing $K_\text{b}$ in the denominator is approximately zero and gets cancelled out. The equation then becomes:
Weak acid and strong base:
$$\ce{[H^+]^3} + \left(K_\text{a} + \frac{C_\text{B} V_\text{B}}{V_\text{A} + V_\text{B}}\right) \ce{[H^+]^2} + \left(\frac{C_\text{B} V_\text{B}}{V_\ce{A} + V_\ce{B}} K_\ce{a} - \frac{C_\ce{A} V_\ce{A}}{V_\ce{A} + V_\ce{B}}K_\ce{a} - K_\ce{w}\right) \ce{[H^+]} - K_\ce{a} K_\ce{w} = 0$$
For a strong acid and weak base ($K_\text{a} \gg 1$), you can divide both sides of the equation by $K_\text{a}$, and now all terms with $K_\text{a}$ in the denominator get cancelled out, leaving:
Strong acid and weak base:
$$\ce{[H^+]^3} + \left(\frac{K_\ce{w}}{K_\ce{b}}+\frac{C_\ce{B}V_\ce{B}}{V_\ce{A} + V_\ce{B}} - \frac{C_\ce{A} V_\ce{A}}{V_\ce{A} + V_\ce{B}}\right) \ce{[H^+]^2} - \left(K_\ce{w} + \frac{C_\text{A} V_\ce{A}}{V_\ce{A} + V_\ce{B}} \frac{K_\ce{w}}{K_\ce{b}}\right) \ce{[H^+]} - \frac{K^2_\ce{w}}{K_\ce{b}} = 0$$
The simplest case happens when adding a strong acid to a strong base ($K_\ce{a} \gg 1$ and $K_\ce{b} \gg 1$), in which case all terms containing either in the denominator get cancelled out. The result is simply:
Strong acid and strong base:
$$\ce{[H^+]^2} + \left(\frac{C_\text{B} V_\text{B}}{V_\text{A} + V_\text{B}} - \frac{C_\text{A} V_\text{A}}{V_\text{A} + V_\text{B}}\right) \ce{[H^+]} - K_\ce{w} = 0$$
It would be enlightening to draw some example graphs for each equation, but Wolfram Alpha only seems to be able to handle the last one, as the others require more than the standard computation time to display. Still, considering the titration of $1~\text{L}$ of a $1~\ce{\small M}$ solution of a strong acid with a $1~\ce{\small M}$ solution of a strong base, you get this graph. The $x$-axis is the volume of base added, in litres, while the $y$-axis is the pH. Notice that the graph is exactly as what you'll find in a textbook!
Now what?
With the equations figured out, let's study how they work. We want to know why the pH changes quickly near the equivalence point, so a good idea is to analyze the derivative of the equation and figure out where they have a very positive or very negative value, indicating a region where $\ce{[H^+]}$ changes quickly with a slight addition of an acid/base.
Suppose we want to study the titration of an acid with a base. What we need then is the derivative $\displaystyle \frac{\ce{d[H^+]}}{\ce{d}V_\ce{B}}$. We will obtain this by implicit differentiation of both sides of the equations by $\displaystyle \frac{\ce{d}}{\ce{d}V_\ce{B}}$. Starting with the easiest case, the mixture of a strong acid and strong base, we obtain:
$$\frac{\ce{d[H^+]}}{\ce{d} V_\ce{B}}=  \frac{K_\ce{w} - C_\ce{B} \ce{[H^+] - [H^+]^2}}{2(V_\ce{A} + V_\ce{B}\left) \ce{[H^+]} + (C_\ce{B} V_\ce{B} - C_\ce{A} V_\ce{A}\right)}$$
Once again a complicated looking fraction, but with very interesting properties. The numerator is not too important, it's the denominator where the magic happens. Notice that we have a sum of two terms ($2(V_\ce{A} + V_\ce{B})\ce{[H^+]}$ and $(C_\ce{B} V_\ce{B} - C_\ce{A} V_\ce{A})$). The lower this sum is, the higher $\displaystyle \frac{\mathrm{d}\ce{[H^+]}}{\mathrm{d} V_\ce{B}}$ is and the quicker the pH will change with a small addition of the base. Notice also that, if the solutions aren't very dilute, then the second term quickly dominates the denominator because while adding base, the value of $[H^+]$ will become quite small compared to $C_\ce{A}$ and $C_\ce{B}$. Now we have a very interesting situation; a fraction where the major component of the denominator has a subtraction. Here's an example of how this sort of function behaves. When the subtraction ends up giving a result close to zero, the function explodes. This means that the speed at which $\ce{[H^+]}$ changes becomes very sensitive to small variations of $V_\ce{B}$ near the critical region. And where does this critical region happen? Well, close to the region where $C_\ce{B} V_\ce{B} - C_\ce{A} V_\ce{A}$ is zero. If you remember the start of the answer, this is the equivalence point!. So there, this proves mathematically that the speed at which the pH changes is maximum at the equivalence point.
This was only the simplest case though. Let's try something a little harder. Taking the titration equation for a weak acid with strong base, and implicitly differentiating both sides by $\displaystyle \frac{\ce{d}}{\ce{d} V_\ce{B}}$ again, we get the significantly more fearsome:
$$\displaystyle \frac{\ce{d[H^+]}}{\ce{d}V_\ce{B}} = \frac{ -\frac{V_\ce{A}}{(V_\ce{A} + V_\ce{B})^2} \ce{[H^+]} (C_\ce{B}\ce{[H^+]} - C_\ce{B} K_\ce{a} + C_\ce{A} K_\ce{a})}{3\ce{[H^+]^2 + 2[H^+]}\left(K_\ce{a} + \frac{C_\ce{B} V_\ce{B}}{V_\ce{A} + V_\ce{B}}\right) + \frac{K_\ce{a}}{V_\ce{A} + V_\ce{B}} (C_\ce{B} V_\ce{B} - C_\ce{A} V_\ce{A}) -K_\ce{w}}$$
Once again, the term that dominates the behaviour of the complicated denominator is the part containing $C_\ce{B} V_\ce{B} - C_\ce{A} V_\ce{A}$, and once again the derivative explodes at the equivalence point.


Question:
For a project I am working on (in hyperbolic PDEs) I would like to get some rough handle on the behavior by looking at some numerics. I am, however, not a very good programmer.
Can you recommend some resources for learning how to effectively code finite difference schemes in Scientific Python (other languages with small learning curve also welcome)?
To give you an idea of the audience (me) for this recommendation:

I am a pure mathematician by training, and am somewhat familiar with the theoretical aspects of finite difference schemes
What I need help with is how to make the computer compute what I want it to compute, especially in a way that I don't duplicate too much of the effort already put in by others (so as to not re-invent the wheel when a package is already available). (Another thing I would like to avoid is to stupidly code something by hand when there are established data structures fitting the purpose.)
I have had some coding experience; but I have had none in Python (hence I don't mind if there are good resources for learning a different language [say, Octave for example]).
Books, documentation would both be useful, as would collections of example code.

Here is a 97-line example of solving a simple multivariate PDE using finite difference methods, contributed by Prof. David Ketcheson, from the py4sci repository I maintain.  For more complicated problems where you need to handle shocks or conservation in a finite-volume discretization, I recommend looking at pyclaw, a software package that I help develop.
"""Pattern formation code

    Solves the pair of PDEs:
       u_t = D_1 \nabla^2 u + f(u,v)
       v_t = D_2 \nabla^2 v + g(u,v)
"""

import matplotlib
matplotlib.use('TkAgg')
import numpy as np
import matplotlib.pyplot as plt
from scipy.sparse import spdiags,linalg,eye
from time import sleep

#Parameter values
Du=0.500; Dv=1;
delta=0.0045; tau1=0.02; tau2=0.2; alpha=0.899; beta=-0.91; gamma=-alpha;
#delta=0.0045; tau1=0.02; tau2=0.2; alpha=1.9; beta=-0.91; gamma=-alpha;
#delta=0.0045; tau1=2.02; tau2=0.; alpha=2.0; beta=-0.91; gamma=-alpha;
#delta=0.0021; tau1=3.5; tau2=0; alpha=0.899; beta=-0.91; gamma=-alpha;
#delta=0.0045; tau1=0.02; tau2=0.2; alpha=1.9; beta=-0.85; gamma=-alpha;
#delta=0.0001; tau1=0.02; tau2=0.2; alpha=0.899; beta=-0.91; gamma=-alpha;
#delta=0.0005; tau1=2.02; tau2=0.; alpha=2.0; beta=-0.91; gamma=-alpha; nx=150;

#Define the reaction functions
def f(u,v):
    return alpha*u*(1-tau1*v**2) + v*(1-tau2*u);

def g(u,v):
    return beta*v*(1+alpha*tau1/beta*u*v) + u*(gamma+tau2*v);

def five_pt_laplacian(m,a,b):
    """Construct a matrix that applies the 5-point laplacian discretization"""
    e=np.ones(m**2)
    e2=([0]+[1]*(m-1))*m
    h=(b-a)/(m+1)
    A=np.diag(-4*e,0)+np.diag(e2[1:],-1)+np.diag(e2[1:],1)+np.diag(e[m:],m)+np.diag(e[m:],-m)
    A/=h**2
    return A

def five_pt_laplacian_sparse(m,a,b):
    """Construct a sparse matrix that applies the 5-point laplacian discretization"""
    e=np.ones(m**2)
    e2=([1]*(m-1)+[0])*m
    e3=([0]+[1]*(m-1))*m
    h=(b-a)/(m+1)
    A=spdiags([-4*e,e2,e3,e,e],[0,-1,1,-m,m],m**2,m**2)
    A/=h**2
    return A

# Set up the grid
a=-1.; b=1.
m=100; h=(b-a)/m;
x = np.linspace(-1,1,m)
y = np.linspace(-1,1,m)
Y,X = np.meshgrid(y,x)

# Initial data
u=np.random.randn(m,m)/2.;
v=np.random.randn(m,m)/2.;
plt.hold(False)
plt.pcolormesh(x,y,u)
plt.colorbar; plt.axis('image');
plt.draw()
u=u.reshape(-1)
v=v.reshape(-1)

A=five_pt_laplacian_sparse(m,-1.,1.);
II=eye(m*m,m*m)

t=0.
dt=h/delta/5.;
plt.ion()

#Now step forward in time
for k in range(120):
    #Simple (1st-order) operator splitting:
    u = linalg.spsolve(II-dt*delta*Du*A,u)
    v = linalg.spsolve(II-dt*delta*Dv*A,v)

    unew=u+dt*f(u,v);
    v   =v+dt*g(u,v);
    u=unew;
    t=t+dt;

    #Plot every 3rd frame
    if k/3==float(k)/3:
        U=u.reshape((m,m))
        plt.pcolormesh(x,y,U)
        plt.colorbar
        plt.axis('image')
        plt.title(str(t))
        plt.draw()

plt.ioff()


Question:
What tradeoffs should I consider when deciding to use an SPI or I2C interface?
This accelerometer/gyro breakout board is available in two models, one for each interface.  Would either one be easier to integrate into an Arduino project?

Summary

SPI is faster.
I2C is more complex and not as easy to use if your microcontroller doesn't have an I2C controller.
I2C only requires 2 lines.

I2C is a bus system with bidirectional data on the SDA line. SPI is a point-to-point connection with data in and data out on separate lines (MOSI and MISO).
Essentially SPI consists of a pair of shift registers, where you clock data in to one shift register while you clock data out of the other. Usually data is written in bytes by having each time 8 clock pulses in succession, but that's not an SPI requirement. You can also have word lengths of 16 bit or even 13 bit, if you like. While in I2C synchronization is done by the start sequence in SPI it's done by SS going high (SS is active low). You decide yourself after how many clock pulses this is. If you use 13 bit words the SS will latch the last clocked in bits after 13 clock pulses.
Since the bidirectional data is on two separate lines it's easy to interface.
SPI in standard mode needs at least four lines: SCLK (serial clock), MOSI (Master Out Slave In), MISO (Master In Slave Out) and SS (Slave Select).
In bideroctional mode needs at least three lines: SCLK (serial clock), MIMO (Master In Master Out) which is one of the MOSI or MISO lines and SS (Slave Select).
In systems with more than one slave you need a SS line for each slave, so that for \$N\$ slaves you have \$N+3\$ lines in standard mode and \$N+2\$ lines in bidirectional mode. If you don't want that, in standard mode you can daisy-chain the slaves by connecting the MOSI signal of one slave to the MISO of the next. This will slow down communication since you have to cycle through all slaves data.
Like tcrosley says SPI can operate at a much higher frequency than I2C.
I2C is a bit more complex. Since it's a bus you need a way to address devices. Your communication starts with a unique start sequence: the data line (SDA) is pulled low while the clock (SCL) is high, for the rest of the communication data is only allowed to change when the clock is low. This start sequence synchronizes each communication.
Since the communication includes the addressing only two lines are required for any number of devices (up to 127).

edit
  It's obvious that the data line is bidirectional, but it's worth noting that this is also true for the clock line. Slaves may stretch the clock to control bus speed. This makes I2C less convenient for level-shifting or buffering. (SPI lines in standard mode are all unidirectional.)

After each byte (address or data) is sent the receiver has to acknowledge the receipt by placing an acknowledge pulse on SDA. If your microcontroller has an I2C interface this will automatically be taken care of. You can still bit-bang it if your microcontroller doesn't support it, but you'll have to switch the I/O pin from output to input for each acknowledge or read data, unless you use an I/O pin for reading and one for writing.
At 400kHz standard I2C is much slower than SPI. There are high-speed I2C devices which operate at 1MHz, still much slower than 20MHz SPI.


Question:
I would like to select a random record from a large set of n unaligned sequencing reads in log(n) time complexity (big O notation) or less. A record is defined as the equivalent of four lines in FASTQ format. The records do not fit in RAM and would need to be stored on disk. Ideally, I would like to store the reads in a compressed format.
I would prefer a solution that does not require any extra files such as for example a reference genome.
The title of this question mentions a FASTQ only because FASTQ is a common format for storing unaligned reads on disk. I am happy with answers that require a single limited transformation of the data to another file format in time complexity order n.
Update
A clarification: I want the random record to be selected with probability 1/n.

Arbitrary record access in constant time
To get a random record in constant time, it is sufficient to get an arbitrary record in constant time.
I have two solutions here: One with tabix and one with grabix. I think the grabix solution is more elegant, but I am keeping the tabix solution below because tabix is a more mature tool than grabix.
Thanks to user172818 for suggesting grabix.
Update
This answer previously stated that tabix and grabix perform lookups in log(n) time. After taking a closer look at the grabix source code and the tabix paper I am now convinced that lookups are independent of n in complexity. However, both tools use an index that scales in size proportionally to n. So, the loading of the index is order n. However, if we consider the loading of the index as "...a single limited transformation of the data to another file format...", then I think this answer is still a valid one. If more than one record is to be retrieved, then the index needs to be stored in memory, perhaps with a framework such as pysam or htslib.
Using grabix

Compress with bgzip.
Index the file and perform lookups with grabix

In bash:
gzip -dc input.fastq.gz | bgzip -c > output.fastq.gz

grabix index output.fastq.gz

# retrieve 5-th record (1-based) in log(n) time
# requires some math to convert indices (4*4 + 1, 4*4 + 4) = (17, 20)
grabix grab output.fastq.gz 17 20

# Count the number of records for part two of this question
export N_LINES=$(gzip -dc output.fastq.gz | wc -l)

Using tabix
The tabix code is more complicated and relies on the iffy assumption that \t is an acceptable character for replacement of \n in a FASTQ record.  If you are happy with a file format that is close to but not exactly FASTQ, then you could do the following:

Paste each record into a single line.
Add a dummy chromosome and line number as the first and second column.
Compress with bgzip.
Index the file and perform lookups with tabix

Note that we need to remove leading spaces introduced by nl and we need to introduce a dummy chromosome column to keep tabix happy:
gzip -dc input.fastq.gz | paste - - - - | nl | sed 's/^ *//' | sed 's/^/dummy\t/' | bgzip -c > output.fastq.gz
tabix -s 1 -b 2 -e 2 output.fastq.gz

# now retrieve the 5th record (1-based) in log(n) time
tabix output.fastq.gz dummy:5-5

# This command will retrieve the 5th record and convert it record back into FASTQ format
tabix output.fastq.gz dummy:5-5 | perl -pe 's/^dummy\t\d+\t//' | tr '\t' '\n'

# Count the number of records for part two of this question
export N_RECORDS=$(gzip -dc output.fastq.gz | wc -l)

Random record in constant time
Now that we have a way of retrieving an arbitrary record in log(n) time, retrieving a random record is simply a matter of getting a good random number generator and sampling. Here is some example code to do this in python:
Using grabix
# random_read.py
import os
import random

n_records = int(os.environ["N_LINES"]) // 4
rand_record_start = random.randrange(0, n_records) * 4 + 1
rand_record_end = rand_record_start + 3
os.system("grabix grab output.fastq.gz {0} {1}".format(rand_record_start, rand_record_end))

Using tabix
# random_read.py
import os
import random

n_records = int(os.environ["N_RECORDS"])
rand_record_index = random.randrange(0, n_records) + 1
# super ugly, but works...
os.system(
    "tabix output.fastq.gz dummy:{0}-{0} | perl -pe 's/^dummy\t\d+\t//' | tr '\t' '\n'".format(
        rand_record_index)
)

And this works for me:
python3.5 random_read.py

Disclaimer
Please note that os.system calls a system shell and is vulnerable to shell injection vulnerabilities. If you are writing production code, then you probably want to take extra precautions.
Thanks to Chris_Rands for raising this issue.


Question:
I am looking for fun, interesting mathematics textbooks which would make good studious holiday gifts for advanced mathematics undergraduates or beginning graduate students.  They should be serious but also readable.
In particular, I am looking for readable books on more obscure topics not covered in a standard undergraduate curriculum which students may not have previously heard of or thought to study.
Some examples of suggestions I've liked so far:

On Numbers and Games, by John Conway.
Groups, Graphs and Trees: An Introduction to the Geometry of Infinite Groups, by John Meier.
Ramsey Theory on the Integers, by Bruce Landman.

I am not looking for pop math books, Gödel, Escher, Bach, or anything of that nature.
I am also not looking for books on 'core' subjects unless the content is restricted to a subdiscipline which is not commonly studied by undergrads  (e.g., Finite Group Theory by Isaacs would be good, but Abstract Algebra by Dummit and Foote would not).

Check into Generatingfunctionology by Herbert Wilf. From the linked (author's) site, the second edition is available for downloading as a pdf. There is also a link to the third edition, available for purchase. It's a very helpful, useful, readable, fun, (and short!) book that a student could conceivably cover over winter break.

Another promising book by John Conway (et. al.) is The Symmetries of Things, which may very well be of interest to students.

One additional suggestion, as it is a classic well worth being placed on any serious student's bookshelf: How to Solve It by George Polya.


Question: My teacher told me about resonance and explained it as different structures which are flipping back and forth and that we only observe a sort of average structure. How does this work? Why do the different structures not exist on their own?

This answer is intended to clear up some misconceptions about resonance which have come up many times on this site.
Resonance is a part of valence bond theory which is used to describe delocalised electron systems in terms of contributing structures, each only involving 2-centre-2-electron bonds. It is a concept that is very often taught badly and misinterpreted by students. The usual explanation is that it is as if the molecule is flipping back and forth between different structures very rapidly and that what is observed is an average of these structures. This is wrong!  (There are molecules that do this (e.g bullvalene), but the rapidly interconverting structures are not called resonance forms or resonance structures.)
Individual resonance structures do not exist on their own. They are not in some sort of rapid equilibrium. There is only a single structure for a molecule such as benzene, which can be described by resonance. The difference between an equilibrium situation and a resonance situation can be seen on a potential energy diagram.

This diagram shows two possible structures of the 2-norbornyl cation. Structure (a) shows the single delocalised structure, described by resonance whereas structures (b) show the equilibrium option, with the delocalised structure (a) as a transition state. The key point is that resonance hybrids are a single potential energy minimum, whereas equilibrating structures are two energy minima separated by a barrier. In 2013 an X-ray diffraction structure was finally obtained and the correct structure was shown to be (a).
Resonance describes delocalised bonding in terms of contributing structures that give some of their character to the single overall structure. These structures do not have to be equally weighted in their contribution. For example, amides can be described by the following resonance structures:

The left structure is the major contributor but the right structure also contributes and so the structure of an amide has some double bond character in the C-N bond (ie. the bond order is >1) and less double bond character in the C-O bond (bond order <2).
The alternative to valence bond theory and the resonance description of molecules is molecular orbital theory. This explains delocalised bonding as electrons occupying molecular orbitals which extend over more than two atoms.


Question:
I saw in a SO thread a suggestion to use filtfilt which performs backwards/forwards filtering instead of lfilter.
What is the motivation for using one against the other technique?

filtfilt is zero-phase filtering, which doesn't shift the signal as it filters.  Since the phase is zero at all frequencies, it is also linear-phase.  Filtering backwards in time requires you to predict the future, so it can't be used in "online" real-life applications, only for offline processing of recordings of signals.
lfilter is causal forward-in-time filtering only, similar to a real-life electronic filter.  It can't be zero-phase.  It can be linear-phase (symmetrical FIR), but usually isn't.  Usually it adds different amounts of delay at different frequencies.

An example and image should make it obvious.  Although the magnitude of the frequency response of the filters is identical (top left and top right), the zero-phase lowpass lines up with the original signal, just without high frequency content, while the minimum phase filtering delays the signal in a causal way:

from __future__ import division, print_function
import numpy as np
from numpy.random import randn
from numpy.fft import rfft
from scipy import signal
import matplotlib.pyplot as plt

b, a = signal.butter(4, 0.03, analog=False)

# Show that frequency response is the same
impulse = np.zeros(1000)
impulse[500] = 1

# Applies filter forward and backward in time
imp_ff = signal.filtfilt(b, a, impulse)

# Applies filter forward in time twice (for same frequency response)
imp_lf = signal.lfilter(b, a, signal.lfilter(b, a, impulse))

plt.subplot(2, 2, 1)
plt.semilogx(20*np.log10(np.abs(rfft(imp_lf))))
plt.ylim(-100, 20)
plt.grid(True, which='both')
plt.title('lfilter')

plt.subplot(2, 2, 2)
plt.semilogx(20*np.log10(np.abs(rfft(imp_ff))))
plt.ylim(-100, 20)
plt.grid(True, which='both')
plt.title('filtfilt')

sig = np.cumsum(randn(800))  # Brownian noise
sig_ff = signal.filtfilt(b, a, sig)
sig_lf = signal.lfilter(b, a, signal.lfilter(b, a, sig))
plt.subplot(2, 1, 2)
plt.plot(sig, color='silver', label='Original')
plt.plot(sig_ff, color='#3465a4', label='filtfilt')
plt.plot(sig_lf, color='#cc0000', label='lfilter')
plt.grid(True, which='both')
plt.legend(loc="best")


Question:
I used to work with publicly available genomic references, where basic statistics are usually available and if they are not, you have to compute them only once so there is no reason to worry about performance.
Recently I started sequencing project of couple of different species with mid-sized genomes (~Gbp) and during testing of different assembly pipelines I had compute number of unknown nucleotides many times in both raw reads (in fastq) and assembly scaffolds (in fasta), therefore I thought that I would like to optimize the computation.

For me it is reasonable to expect 4-line formatted fastq files, but general solution is still prefered
It would be nice if solution would work on gzipped files as well

Q : What is the fastest way (performance-wise) to compute the number of unknown nucleotides (Ns) in fasta and fastq files?

For FASTQ:
seqtk fqchk in.fq | head -2

It gives you percentage of "N" bases, not the exact count, though.
For FASTA:
seqtk comp in.fa | awk '{x+=$9}END{print x}'

This command line also works with FASTQ, but it will be slower as awk is slow.
EDIT: ok, based on @BaCH's reminder, here we go (you need kseq.h to compile):
// to compile: gcc -O2 -o count-N this-prog.c -lz
#include <zlib.h>
#include <stdio.h>
#include <stdint.h>
#include "kseq.h"
KSEQ_INIT(gzFile, gzread)

unsigned char dna5tbl[256] = {
    0, 1, 2, 3,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 5, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 0, 4, 1,  4, 4, 4, 2,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  3, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 0, 4, 1,  4, 4, 4, 2,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  3, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4
};

int main(int argc, char *argv[]) {
    long i, n_n = 0, n_acgt = 0, n_gap = 0;
    gzFile fp;
    kseq_t *seq;
    if (argc == 1) {
        fprintf(stderr, "Usage: count-N <in.fa>\n");
        return 1;
    }
    if ((fp = gzopen(argv[1], "r")) == 0) {
        fprintf(stderr, "ERROR: fail to open the input file\n");
        return 1;
    }
    seq = kseq_init(fp);
    while (kseq_read(seq) >= 0) {
        for (i = 0; i < seq->seq.l; ++i) {
            int c = dna5tbl[(unsigned char)seq->seq.s[i]];
            if (c < 4) ++n_acgt;
            else if (c == 4) ++n_n;
            else ++n_gap;
        }
    }
    kseq_destroy(seq);
    gzclose(fp);
    printf("%ld\t%ld\t%ld\n", n_acgt, n_n, n_gap);
    return 0;
}

It works for both FASTA/Q and gzip'ed FASTA/Q. The following uses SeqAn:
#include <seqan/seq_io.h>

using namespace seqan;

int main(int argc, char *argv[]) {
    if (argc == 1) {
        std::cerr << "Usage: count-N <in.fastq>" << std::endl;
        return 1;
    }
    std::ios::sync_with_stdio(false);
    CharString id;
    Dna5String seq;
    SeqFileIn seqFileIn(argv[1]);
    long i, n_n = 0, n_acgt = 0;
    while (!atEnd(seqFileIn)) {
        readRecord(id, seq, seqFileIn);
        for (i = beginPosition(seq); i < endPosition(seq); ++i)
            if (seq[i] < 4) ++n_acgt;
            else ++n_n;
    }
    std::cout << n_acgt << '\t' << n_n << std::endl;
    return 0;
}

On a FASTQ with 4-million 150bp reads:

The C version: ~0.74 sec
The C++ version: ~2.15 sec
An older C version without a lookup table (see the previous edit): ~2.65 sec


Question: We've learnt that the electropositive element is written first. Then why is ammonia written as $\ce{NH3}$ ?

According to current nomenclature rules, $\ce{H3N}$ would be correct and acceptable.  However some chemical formulas, like $\ce{NH3}$ for ammonia, that were in use long before the rules came out, are still accepted today.


Question:
Are there any tools in Python that are like Matlab's parfor? I found this thread, but it's four years old. I thought maybe someone here might have more recent experience.
Here's an example of the type of thing I'd like to parallelize:
X = np.random.normal(size=(10, 3))
F = np.zeros((10, ))
for i in range(10):
    F[i] = my_function(X[i,:])

where my_function takes an ndarray of size (1,3) and returns a scalar.
At the least, I'd like to use multiple cores simultaneously---like parfor. In other words, assume a shared memory system with 8-to-16 cores.

Joblib does what you want.
The basic usage pattern is:
from joblib import Parallel, delayed

def myfun(arg):
     do_stuff
     return result

results = Parallel(n_jobs=-1, verbose=verbosity_level, backend="threading")(
             map(delayed(myfun), arg_instances))

where arg_instances is list of values for which myfun is computed in parallel.
The main restriction is that myfun must be a toplevel function.
The backend parameter can be either "threading" or "multiprocessing".
You can pass additional common parameters to the parallelized function. The body of myfun can also refer to initialized global variables, the values which will be available to the children.
Args and results can be pretty much anything with the threading backend but results need to be serializable with the multiprocessing backend.

Dask also offers similar functionality. It might be preferable if you are working with out of core data or you are trying to parallelize more complex computations.


Question:
It seems that everywhere I look, data structures are being implemented using red-black trees (std::set in C++, SortedDictionary in C#, etc.)
Having just covered (a,b), red-black & AVL trees in my algorithms class, here's what I got out (also from asking around professors, looking through a few books and googling a bit):

AVL trees have smaller average depth than red-black trees, and thus searching for a value in AVL tree is consistently faster.
Red-black trees make less structural changes to balance themselves than AVL trees, which could make them potentially faster for insert/delete. I'm saying potentially, because this would depend on the cost of the structural change to the tree, as this will depend a lot on the runtime and implemntation (might also be completely different in a functional language when the tree is immutable?)

There are many benchmarks online that compare AVL and Red-black trees, but what struck me is that my professor basically said, that usually you'd do one of two things:

Either you don't really care that much about performance, in which case the 10-20% difference of AVL vs Red-black in most cases won't matter at all.
Or you really care about performance, in which you case you'd ditch both AVL and Red-black trees, and go with B-trees, which can be tweaked to work much better (or (a,b)-trees, I'm gonna put all of those in one basket.)

The reason for that is because a B-tree stores data more compactly in memory (one node contains many values) there will be much fewer cache misses. You could also tweak the implementation based on the use case, and make the order of the B-tree depend on the CPU cache size, etc.
The problem is that I can't find almost any source that would analyze real life usage of different implementations of search trees on real modern hardware. I've looked through many books on algorithms and haven't found anything that would compare different tree variants together, other than showing that one has smaller average depth than the other one (which doesn't really say much of how the tree will behave in real programs.)
That being said, is there a particular reason why Red-black trees are being used everywhere, when based on what is said above, B-trees should be outperforming them? (as the only benchmark I could find also shows  but it might just be a matter of the specific implementation). Or is the reason why everyone uses Red-black trees because they're rather easy to implement, or to put it in different words, hard to implement poorly?
Also, how does this change when one moves to the realm of functional languages? It seems that both Clojure and Scala use Hash array mapped tries, where Clojure uses a branching factor of 32.

To quote from the answer to “Traversals from the root in AVL trees and Red Black Trees” question

For some kinds of binary search trees, including red-black trees but
  not AVL trees, the "fixes" to the tree can fairly easily be predicted
  on the way down and performed during a single top-down pass, making
  the second pass unnecessary. Such insertion algorithms are typically
  implemented with a loop rather than recursion, and often run slightly
  faster in practice than their two-pass counterparts.

So a RedBlack tree insert can be implemented without recursion, on some CPUs recursion is very expensive if you overrun the function call cache  (e.g SPARC due to is use of Register window)
(I have seen software run over 10 times as fast on the Sparc by removing one function call, that resulted in a often called code path being too deep for the register window.   As you don't know how deep the register window will be on your customer's system, and you don't know how far down the call stack you are in the "hot code path", not using recursion make like more predictable.)
Also not risking running out of stack is a benefit.


Question:
I agree that a Turing Machine can do "all possible mathematical problems". But that is because it is just a machine representation of an algorithm: first do this, then do that, finally output that.
I mean anything that is solvable can be represented by an algorithm (because that is precisely the definition of 'solvable'). It is just a tautology. I said nothing new here.
And by creating a machine representation of an algorithm, that it will also solve all possible problems is also nothing new. This is also mere tautology. So basically when it is said that a Turing Machine is the most powerful machine, what it effectively means is that the most powerful machine is the most powerful machine!

Definition of "most powerful": That which can accept any language.
  Definition of "Algorithm": Process for doing anything.
  Machine representation of "Algorithm": A machine that can do anything.

Therefore it is only logical that the machine representation of an algorithm will be the most powerful machine. What's the new thing Alan Turing gave us?

I agree that a Turing Machine can do "all the possible mathematical problems".

Well, you shouldn't, because it's not true. For example, Turing machines cannot determine if polynomials with integer coefficients have integer solutions (Hilbert's tenth problem).

Is Turing Machine “by definition” the most powerful machine?

No. We can dream up an infinite hierarchy of more powerful machines. However, the Turing machine is the most powerful machine that we know, at least in principle, how to build.  That's not a definition, though: it is just that we do not have any clue how to build anything more powerful, or if it is even possible.

What's the new thing Alan Turing gave us?

A formal definition of algorithm. Without such a definition (e.g., the Turing machine), we have only informal definitions of algorithm, along the lines of "A finitely specified procedure for solving something." OK, great. But what individual steps are these procedures allowed to take?
Are basic arithmetic operations steps? Is finding the gradient of a curve a step? Is finding roots of polynomials a step? Is finding integer roots of polynomials a step? Each of those seems about as natural. However, if you allow all of them, your "finitely specified procedures" are more powerful than Turing machines, which means that they can solve things that can't be solved by algorithms. If you allow all but the last one, you're still within the realms of Turing computation.
If we didn't have a formal definition of algorithm, we wouldn't even be able to ask these questions. We wouldn't be able to discuss what algorithms can do, because we wouldn't know what an algorithm is.


Question: Standard finite difference formulas are usable to numerically compute a derivative under the expectation that you have function values $f(x_k)$ at evenly spaced points, so that $h \equiv x_{k+1} - x_k$ is a constant. What if I have unevenly spaced points, so that $h$ now varies from one pair of adjacent points to the next? Obviously I can still compute a first derivative as $f'(x) \approx \frac{1}{h_k}[f(x_{k+1}) - f(x_k)]$, but are there numerical differentiation formulas at higher orders and accuracies that can adapt to variation in the grid size?

J.M's comment is right: you can find an interpolating polynomial and differentiate it.  There are other ways of deriving such formulas; typically, they all lead to solving a van der Monde system for the coefficients.  This approach is problematic when the finite difference stencil includes a large number of points, because the Vandermonde matrices become ill-conditioned.  A more numerically stable approach was devised by Fornberg, and is explained more clearly and generally in a second paper of his.
Here is a simple MATLAB script that implements Fornberg's method to compute the coefficients of a finite difference approximation for any order derivative with any set of points.  For a nice explanation, see Chapter 1 of LeVeque's text on finite difference methods.
A bit more on FD formulas:  Suppose you have a 1D grid.  If you use the whole set of grid points to determine a set of FD formulas, the resulting method is equivalent to finding an interpolating polynomial through the whole grid and differentiating that.  This approach is referred to as spectral collocation.  Alternatively, for each grid point you could determine a FD formula using just a few neighboring points.  This is what is done in traditional finite difference methods.
As mentioned in the comments below, using finite differences of very high order can lead to oscillations (the Runge phenomenon) if the points are not chosen carefully.


Question:
I think I remember reading somewhere that the Baire Category Theorem is supposedly quite powerful. Whether that is true or not, it's my favourite theorem (so far) and I'd love to see some applications that confirm its neatness and/or power.
Here's the theorem (with proof) and two applications:

(Baire) A non-empty complete metric space $X$ is not a countable union of nowhere dense sets.
Proof: Let $X = \bigcup U_i$ where $\mathring{\overline{U_i}} = \varnothing$. We construct a Cauchy sequence as follows: Let $x_1$ be any point in $(\overline{U_1})^c$. We can find such a point because $(\overline{U_1})^c \subset X$ and $X$ contains at least one non-empty open set (if nothing else, itself) but $\mathring{\overline{U_1}} = \varnothing$ which is the same as saying that $\overline{U_1}$ does not contain any open sets hence the open set contained in $X$ is contained in $\overline{U_1}^c$. Hence we can pick $x_1$ and $\varepsilon_1 > 0$ such that $B(x_1, \varepsilon_1) \subset (\overline{U_1})^c \subset U_1^c$.
Next we make a similar observation about $U_2$ so that we can find $x_2$ and $\varepsilon_2 > 0$ such that $B(x_2, \varepsilon_2) \subset \overline{U_2}^c \cap B(x_1, \frac{\varepsilon_1}{2})$. We repeat this process to get a sequence of balls such that $B_{k+1} \subset B_k$ and a sequence $(x_k)$ that is Cauchy. By completeness of $X$, $\lim x_k =: x$ is in $X$. But $x$ is in $B_k$ for every $k$ hence not in any of the $U_i$ and hence not in $\bigcup U_i = X$. Contradiction. $\Box$

Here is one application (taken from here):
Claim: $[0,1]$ contains uncountably many elements.
Proof: Assume that it contains countably many. Then $[0,1] = \bigcup_{x \in (0,1)} \{x\}$ and since $\{x\}$ are nowhere dense sets, $X$ is a countable union of nowhere dense sets. But $[0,1]$ is complete, so we have a contradiction. Hence $X$ has to be uncountable.

And here is another one (taken from here):
Claim: The linear space of all polynomials in one variable is not a Banach space in any norm.
Proof: "The subspace of polynomials of degree $\leq n$ is closed in any norm because it is finite-dimensional. Hence the space of all polynomials can be written as countable union of closed nowhere dense sets. If there were a complete norm this would contradict the Baire Category Theorem."

If $P$ is an infinitely differentiable function  such that for each $x$, there is an $n$ with $P^{(n)}(x)=0$, then $P$ is a polynomial. (Note $n$ depends on $x$.) See the discussion in Math Overflow.


Question:
I am a CS undergraduate. I understand how Turing came up with his abstract machine (modeling a person doing a computation), but it seems to me to be an awkward, inelegant abstraction. Why do we consider a "tape", and a machine head writing symbols, changing state, shifting the tape back and forth?
What is the underlying significance? A DFA is elegant - it seems to capture precisely what is necessary to recognize the regular languages. But the Turing machine, to my novice judgement, is just a clunky abstract contraption.
After thinking about it, I think the most idealized model of computation would be to say that some physical system corresponding to the input string, after being set into motion, would reach a static equilibrium which, upon interpretation equivalent to the the one used to form the system from the original string, would correspond to the correct output string. This captures the notion of "automation", since the system would change deterministically based solely on the original state.
Edit:
After reading a few responses, I've realized that what confuses me about the Turing machine is that it does not seem minimal. Shouldn't the canonical model of computation obviously convey the essence of computability?
Also, in case it wasn't clear I know that DFAs are not complete models of computation.
Thank you for the replies.

Well, a DFA is just a Turing machine that's only allowed to move to the right and that must accept or reject as soon as it runs out of input characters. So I'm not sure one can really say that a DFA is natural but a Turing machine isn't.
Critique of the question aside, remember that Turing was working before computers existed. As such, he wasn't trying to codify what electronic computers do but, rather, computation in general. My parents have a dictionary from the 1930s that defines computer as "someone who computes" and this is basically where Turing was coming from: for him, at that time, computation was about slide rules, log tables, pencils and pieces of paper.  In that mind-set, rewriting symbols on a paper tape doesn't seem like a bad abstraction.
OK, fine, you're saying (I hope!) but we're not in the 1930s any more so why do we still use this? Here, I don't think there's any one specific reason. The advantage of Turing machines is that they're reasonably simple and we're decently good at proving things about them. Although formally specifying a Turing machine program to do some particular task is very tedious, once you've done it a few times, you have a reasonable intuition about what they can do and you don't need to write the formal specifications any more. The model is also easily extended to include other natural features, such as random access to the tape.  So they're a pretty useful model that we understand well and we also have a pretty good understanding of how they relate to actual computers.
One could use other models but one would then have to do a huge amount of translation between results for the new model and the vast body of existing work on what Turing machines can do. Nobody has come up with a replacement for Turing machines that have had big enough advantages to make that look like a good idea.


Question:
I am seeking help understanding Floyd's cycle detection algorithm. I have gone through the explanation on wikipedia (
I can see how the algorithm detects cycle in O(n) time. However, I am unable to visualise the fact that once the tortoise and hare pointers meet for the first time, the start of the cycle can be determined by moving tortoise pointer back to start and then moving both tortoise and hare one step at a time. The point where they first meet is the start of the cycle.
Can someone help by providing an explanation, hopefully different from the one on wikipedia, as I am unable to understand/visualise it?

You can refer to "Detecting start of a loop in singly linked list", here's an excerpt:

Distance travelled by slowPointer before meeting $= x+y$
Distance travelled by fastPointer before meeting $=(x + y + z) + y = x + 2y + z$
Since fastPointer travels with double the speed of slowPointer, and time is constant for both when both pointers reach the meeting point. So by using simple speed, time and distance relation (slowPointer traveled half the distance):
\begin{align*}
2*\operatorname{dist}(\text{slowPointer}) &= \operatorname{dist}(\text{fastPointer})\\
2(x+y) &= x+2y+z\\
2x+2y &= x+2y+z\\
x &= z
\end{align*}
Hence by moving slowPointer to start of linked list, and making both slowPointer and fastPointer to move one node at a time, they both have same distance to cover.
They will reach at the point where the loop starts in the linked list.