Question:
I'm in a course about computing and complexity, and am unable to understand what these terms mean.
All I know is that NP is a subset of NP-complete, which is a subset of NP-hard, but I have no idea what they actually mean. Wikipedia isn't much help either, as the explanations are still a bit too high level.

I think the Wikipedia articles
$\mathsf{P}$, $\mathsf{NP}$, and $\mathsf{P}$ vs. $\mathsf{NP}$ are quite good.
Still here is what I would say: Part I, Part II
[I will use remarks inside brackets to discuss some technical details which
you can skip if you want.]

Part I
Decision Problems
There are various kinds of computational problems.
However in an introduction to computational complexity theory course
it is easier to focus on decision problem,
i.e. problems where the answer is either YES or NO.
There are other kinds of computational problems but
most of the time questions about them can be reduced to
similar questions about decision problems.
Moreover decision problems are very simple.
Therefore in an introduction to computational complexity theory course
we focus our attention to the study of decision problems.
We can identify a decision problem with the subset of inputs that
have answer YES.
This simplifies notation and allows us to write
$x\in Q$ in place of $Q(x)=YES$ and
$x \notin Q$ in place of $Q(x)=NO$.
Another perspective is that
we are talking about membership queries in a set.
Here is an example:
Decision Problem:

Input: A natural number $x$,
Question: Is $x$ an even number?

Membership Problem:

Input: A natural number $x$,
Question: Is $x$ in $Even = \{0,2,4,6,\cdots\}$?

We refer to the YES answer on an input as accepting the input and
to the NO answer on an input as rejecting the input.
We will look at algorithms for decision problems and
discuss how efficient those algorithms are in their usage of computable resources.
I will rely on your intuition from programming in a language like C
in place of formally defining what we mean by an algorithm and computational resources.
[Remarks:

If we wanted to do everything formally and precisely
we would need to fix a model of computation like the standard Turing machine model
to precisely define what we mean by an algorithm and
its usage of computational resources.
If we want to talk about computation over objects that
the model cannot directly handle,
we would need to encode them as objects that the machine model can handle,
e.g. if we are using Turing machines
we need to encode objects like natural numbers and graphs
as binary strings.]

$\mathsf{P}$ = Problems with Efficient Algorithms for Finding Solutions
Assume that efficient algorithms means algorithms that
use at most polynomial amount of computational resources.
The main resource we care about is
the worst-case running time of algorithms with respect to the input size,
i.e. the number of basic steps an algorithm takes on an input of size $n$.
The size of an input $x$ is $n$ if it takes $n$-bits of computer memory to store $x$,
in which case we write $|x| = n$.
So by efficient algorithms we mean algorithms that
have polynomial worst-case running time.
The assumption that polynomial-time algorithms capture
the intuitive notion of efficient algorithms is known as Cobham's thesis.
I will not discuss at this point
whether $\mathsf{P}$ is the right model for efficiently solvable problems and
whether $\mathsf{P}$ does or does not capture
what can be computed efficiently in practice and related issues.
For now there are good reasons to make this assumption
so for our purpose we assume this is the case.
If you do not accept Cobham's thesis
it does not make what I write below incorrect,
the only thing we will lose is
the intuition about efficient computation in practice.
I think it is a helpful assumption for someone
who is starting to learn about complexity theory.

$\mathsf{P}$ is the class of decision problems that can be solved efficiently,
i.e. decision problems which have polynomial-time algorithms.

More formally, we say a decision problem $Q$ is in $\mathsf{P}$ iff

there is an efficient algorithm $A$ such that
for all inputs $x$,

if $Q(x)=YES$ then $A(x)=YES$,
if $Q(x)=NO$ then $A(x)=NO$.

I can simply write $A(x)=Q(x)$ but
I write it this way so we can compare it to the definition of $\mathsf{NP}$.

$\mathsf{NP}$ = Problems with Efficient Algorithms for Verifying Proofs/Certificates/Witnesses
Sometimes we do not know any efficient way of finding the answer to a decision problem,
however if someone tells us the answer and gives us a proof
we can efficiently verify that the answer is correct
by checking the proof to see if it is a valid proof.
This is the idea behind the complexity class $\mathsf{NP}$.
If the proof is too long it is not really useful,
it can take too long to just read the proof
let alone check if it is valid.
We want the time required for verification to be reasonable
in the size of the original input,
not the size of the given proof!
This means what we really want is not arbitrary long proofs but short proofs.
Note that if the verifier's running time is polynomial
in the size of the original input
then it can only read a polynomial part of the proof.
So by short we mean of polynomial size.
From this point on whenever I use the word "proof" I mean "short proof".
Here is an example of a problem which
we do not know how to solve efficiently but
we can efficiently verify proofs:

Partition
Input: a finite set of natural numbers $S$,
Question: is it possible to partition $S$ into two sets $A$ and $B$
($A \cup B = S$ and $A \cap B = \emptyset$)
such that the sum of the numbers in $A$ is equal to the sum of number in $B$ ($\sum_{x\in A}x=\sum_{x\in B}x$)?

If I give you $S$ and
ask you if we can partition it into two sets such that
their sums are equal,
you do not know any efficient algorithm to solve it.
You will probably try all possible ways of
partitioning the numbers into two sets
until you find a partition where the sums are equal or
until you have tried all possible partitions and none has worked.
If any of them worked you would say YES, otherwise you would say NO.
But there are exponentially many possible partitions so
it will take a lot of time to enumerate all the possibilities.
However if I give you two sets $A$ and $B$,
you can easily check if the sums are equal and
if $A$ and $B$ is a partition of $S$.
Note that we can compute sums efficiently.
Here the pair of $A$ and $B$ that I give you is a proof for a YES answer.
You can efficiently verify my claim by looking at my proof and
checking if it is a valid proof.
If the answer is YES then there is a valid proof, and
I can give it to you and you can verify it efficiently.
If the answer is NO then there is no valid proof.
So whatever I give you you can check and see it is not a valid proof.
I cannot trick you by an invalid proof that the answer is YES.
Recall that if the proof is too big
it will take a lot of time to verify it,
we do not want this to happen,
so we only care about efficient proofs,
i.e. proofs which have polynomial size.
Sometimes people use "certificate" or "witness" in place of "proof".
Note I am giving you enough information about the answer for a given input $x$
so that you can find and verify the answer efficiently.
For example, in our partition example
I do not tell you the answer,
I just give you a partition,
and you can check if it is valid or not.
Note that you have to verify the answer yourself,
you cannot trust me about what I say.
Moreover you can only check the correctness of my proof.
If my proof is valid it means the answer is YES.
But if my proof is invalid it does not mean the answer is NO.
You have seen that one proof was invalid,
not that there are no valid proofs.
We are talking about proofs for YES.
We are not talking about proofs for NO.
Let us look at an example:
$A=\{2,4\}$ and $B=\{1,5\}$ is a proof that
$S=\{1,2,4,5\}$ can be partitioned into two sets with equal sums.
We just need to sum up the numbers in $A$ and the numbers in $B$ and
see if the results are equal, and check if $A$, $B$ is partition of $S$.
If I gave you $A=\{2,5\}$ and $B=\{1,4\}$,
you will check and see that my proof is invalid.
It does not mean the answer is NO,
it just means that this particular proof was invalid.
Your task here is not to find the answer,
but only to check if the proof you are given is valid.
It is like a student solving a question in an exam and
a professor checking if the answer is correct. :)
(unfortunately often students do not give enough information
to verify the correctness of their answer and
the professors have to guess the rest of their partial answer and
decide how much mark they should give to the students for their partial answers,
indeed a quite difficult task).
The amazing thing is that
the same situation applies to many other natural problems that we want to solve:
we can efficiently verify if a given short proof is valid,
but we do not know any efficient way of finding the answer.
This is the motivation why
the complexity class $\mathsf{NP}$ is extremely interesting
(though this was not the original motivation for defining it).
Whatever you do
(not just in CS, but also in
math, biology, physics, chemistry, economics, management, sociology, business,
...)
you will face computational problems that fall in this class.
To get an idea of how many problems turn out to be in $\mathsf{NP}$ check out
a compendium of NP optimization problems.
Indeed you will have hard time finding natural problems
which are not in $\mathsf{NP}$.
It is simply amazing.

$\mathsf{NP}$ is the class of problems which have efficient verifiers,
i.e.
there is a polynomial time algorithm that can verify
if a given solution is correct.

More formally, we say a decision problem $Q$ is in $\mathsf{NP}$ iff

there is an efficient algorithm $V$ called verifier such that
for all inputs $x$,

if $Q(x)=YES$ then there is a proof $y$ such that $V(x,y)=YES$,
if $Q(x)=NO$ then for all proofs $y$, $V(x,y)=NO$.

We say a verifier is sound
if it does not accept any proof when the answer is NO.
In other words, a sound verifier cannot be tricked
to accept a proof if the answer is really NO.
No false positives.
Similarly, we say a verifier is complete
if it accepts at least one proof when the answer is YES.
In other words, a complete verifier can be convinced of the answer being YES.
The terminology comes from logic and proof systems.
We cannot use a sound proof system to prove any false statements.
We can use a complete proof system to prove all true statements.
The verifier $V$ gets two inputs,

$x$ : the original input for $Q$, and
$y$ : a suggested proof for $Q(x)=YES$.

Note that we want $V$ to be efficient in the size of $x$.
If $y$ is a big proof
the verifier will be able to read only a polynomial part of $y$.
That is why we require the proofs to be short.
If $y$ is short saying that $V$ is efficient in $x$
is the same as saying that $V$ is efficient in $x$ and $y$
(because the size of $y$ is bounded by a fixed polynomial in the size of $x$).
In summary, to show that a decision problem $Q$ is in $\mathsf{NP}$
we have to give an efficient verifier algorithm
which is sound and complete.
Historical Note:
historically this is not the original definition of $\mathsf{NP}$.
The original definition uses what is called non-deterministic Turing machines.
These machines do not correspond to any actual machine model and
are difficult to get used to
(at least when you are starting to learn about complexity theory).
I have read that many experts think that
they would have used the verifier definition as the main definition and
even would have named the class $\mathsf{VP}$
(for verifiable in polynomial-time) in place of $\mathsf{NP}$
if they go back to the dawn of the computational complexity theory.
The verifier definition is more natural,
easier to understand conceptually, and
easier to use to show problems are in $\mathsf{NP}$.

$\mathsf{P}\subseteq \mathsf{NP}$
Therefore we have
$\mathsf{P}$=efficient solvable and $\mathsf{NP}$=efficiently verifiable.
So $\mathsf{P}=\mathsf{NP}$ iff
the problems that can be efficiently verified are
the same as the problems that can be efficiently solved.
Note that any problem in $\mathsf{P}$ is also in $\mathsf{NP}$,
i.e. if you can solve the problem
you can also verify if a given proof is correct:
the verifier will just ignore the proof!
That is because we do not need it,
the verifier can compute the answer by itself,
it can decide if the answer is YES or NO without any help.
If the answer is NO we know there should be no proofs and
our verifier will just reject every suggested proof.
If the answer is YES, there should be a proof, and
in fact we will just accept anything as a proof.
[We could have made our verifier accept only some of them,
that is also fine,
as long as our verifier accept at least one proof
the verifier works correctly for the problem.]
Here is an example:

Sum
Input: a list of $n+1$ natural numbers $a_1,\cdots,a_n$, and $s$,
Question: is $\Sigma_{i=1}^n a_i = s$?

The problem is in $\mathsf{P}$ because
we can sum up the numbers and then compare it with $s$,
we return YES if they are equal, and NO if they are not.
The problem is also in $\mathsf{NP}$.
Consider a verifier $V$ that gets a proof plus the input for Sum.
It acts the same way as the algorithm in $\mathsf{P}$ that we described above.
This is an efficient verifier for Sum.
Note that there are other efficient verifiers for Sum, and
some of them might use the proof given to them.
However the one we designed does not and that is also fine.
Since we gave an efficient verifier for Sum the problem is in $\mathsf{NP}$.
The same trick works for all other problems in $\mathsf{P}$ so
$\mathsf{P} \subseteq \mathsf{NP}$.

Brute-Force/Exhaustive-Search Algorithms for $\mathsf{NP}$ and $\mathsf{NP}\subseteq \mathsf{ExpTime}$
The best algorithms we know of for solving an arbitrary problem in $\mathsf{NP}$ are
brute-force/exhaustive-search algorithms.
Pick an efficient verifier for the problem
(it has an efficient verifier by our assumption that it is in $\mathsf{NP}$) and
check all possible proofs one by one.
If the verifier accepts one of them then the answer is YES.
Otherwise the answer is NO.
In our partition example,
we try all possible partitions and
check if the sums are equal in any of them.
Note that the brute-force algorithm runs in worst-case exponential time.
The size of the proofs is polynomial in the size of input.
If the size of the proofs is $m$ then there are $2^m$ possible proofs.
Checking each of them will take polynomial time by the verifier.
So in total the brute-force algorithm takes exponential time.
This shows that any $\mathsf{NP}$ problem
can be solved in exponential time, i.e.
$\mathsf{NP}\subseteq \mathsf{ExpTime}$.
(Moreover the brute-force algorithm will use
only a polynomial amount of space, i.e.
$\mathsf{NP}\subseteq \mathsf{PSpace}$
but that is a story for another day).
A problem in $\mathsf{NP}$ can have much faster algorithms,
for example any problem in $\mathsf{P}$ has a polynomial-time algorithm.
However for an arbitrary problem in $\mathsf{NP}$
we do not know algorithms that can do much better.
In other words, if you just tell me that
your problem is in $\mathsf{NP}$
(and nothing else about the problem)
then the fastest algorithm that
we know of for solving it takes exponential time.
However it does not mean that there are not any better algorithms,
we do not know that.
As far as we know it is still possible
(though thought to be very unlikely by almost all complexity theorists) that
$\mathsf{NP}=\mathsf{P}$ and
all $\mathsf{NP}$ problems can be solved in polynomial time.
Furthermore, some experts conjecture that
we cannot do much better, i.e.
there are problems in $\mathsf{NP}$ that
cannot be solved much more efficiently than brute-force search algorithms
which take exponential amount of time.
See the Exponential Time Hypothesis
for more information.
But this is not proven, it is only a conjecture.
It just shows how far we are from
finding polynomial time algorithms for arbitrary $\mathsf{NP}$ problems.
This association with exponential time confuses some people:
they think incorrectly that
$\mathsf{NP}$ problems require exponential-time to solve
(or even worse there are no algorithm for them at all).
Stating that a problem is in $\mathsf{NP}$
does not mean a problem is difficult to solve,
it just means that it is easy to verify,
it is an upper bound on the difficulty of solving the problem, and
many $\mathsf{NP}$ problems are easy to solve since $\mathsf{P}\subseteq\mathsf{NP}$.
Nevertheless, there are $\mathsf{NP}$ problems which seem to be
hard to solve.
I will return to this in when we discuss $\mathsf{NP}$-hardness.

Lower Bounds Seem Difficult to Prove
OK, so we now know that there are
many natural problems that are in $\mathsf{NP}$ and
we do not know any efficient way of solving them and
we suspect that they really require exponential time to solve.
Can we prove this?
Unfortunately the task of proving lower bounds is very difficult.
We cannot even prove that these problems require more than linear time!
Let alone requiring exponential time.
Proving linear-time lower bounds is rather easy:
the algorithm needs to read the input after all.
Proving super-linear lower bounds is a completely different story.
We can prove super-linear lower bounds
with more restrictions about the kind of algorithms we are considering,
e.g. sorting algorithms using comparison,
but we do not know lower-bounds without those restrictions.
To prove an upper bound for a problem
we just need to design a good enough algorithm.
It often needs knowledge, creative thinking, and
even ingenuity to come up with such an algorithm.
However the task is considerably simpler compared to proving a lower bound.
We have to show that there are no good algorithms.
Not that we do not know of any good enough algorithms right now, but
that there does not exist any good algorithms,
that no one will ever come up with a good algorithm.
Think about it for a minute if you have not before,
how can we show such an impossibility result?
This is another place where people get confused.
Here "impossibility" is a mathematical impossibility, i.e.
it is not a short coming on our part that
some genius can fix in future.
When we say impossible
we mean it is absolutely impossible,
as impossible as $1=0$.
No scientific advance can make it possible.
That is what we are doing when we are proving lower bounds.
To prove a lower bound, i.e.
to show that a problem requires some amount of time to solve,
means that we have to prove that any algorithm,
even very ingenuous ones that do not know yet,
cannot solve the problem faster.
There are many intelligent ideas that we know of
(greedy, matching, dynamic programming, linear programming, semidefinite programming, sum-of-squares programming, and
many other intelligent ideas) and
there are many many more that we do not know of yet.
Ruling out one algorithm or one particular idea of designing algorithms
is not sufficient,
we need to rule out all of them,
even those we do not know about yet,
even those may not ever know about!
And one can combine all of these in an algorithm,
so we need to rule out their combinations also.
There has been some progress towards showing that
some ideas cannot solve difficult $\mathsf{NP}$ problems,
e.g. greedy and its extensions cannot work,
and there are some work related to dynamic programming algorithms,
and there are some work on particular ways of using linear programming.
But these are not even close to ruling out the intelligent ideas that
we know of
(search for lower-bounds in restricted models of computation
if you are interested).

Barriers: Lower Bounds Are Difficult to Prove
On the other hand we have mathematical results called
barriers
that say that a lower-bound proof cannot be such and such,
and such and such almost covers all techniques that
we have used to prove lower bounds!
In fact many researchers gave up working on proving lower bounds after
Alexander Razbarov and Steven Rudich's
natural proofs barrier result.
It turns out that the existence of particular kind of lower-bound proofs
would imply the insecurity of cryptographic pseudorandom number generators and
many other cryptographic tools.
I say almost because
in recent years there has been some progress mainly by Ryan Williams
that has been able to intelligently circumvent the barrier results,
still the results so far are for very weak models of computation and
quite far from ruling out general polynomial-time algorithms.
But I am diverging.
The main point I wanted to make was that
proving lower bounds is difficult and
we do not have strong lower bounds for general algorithms
solving $\mathsf{NP}$ problems.
[On the other hand,
Ryan Williams' work shows that
there are close connections between proving lower bounds and proving upper bounds.
See his talk at ICM 2014 if you are interested.]

Reductions: Solving a Problem Using Another Problem as a Subroutine/Oracle/Black Box
The idea of a reduction is very simple:
to solve a problem, use an algorithm for another problem.
Here is simple example:
assume we want to compute the sum of a list of $n$ natural numbers and
we have an algorithm $\operatorname{Sum}$ that returns the sum of two given numbers.
Can we use $\operatorname{Sum}$ to add up the numbers in the list?
Of course!
Problem:

Input: a list of $n$ natural numbers $x_1,\ldots,x_n$,
Output: return $\sum_{i=1}^{n} x_i$.

Reduction Algorithm:

$s = 0$
for $i$ from $1$ to $n$
2.1.  $s = \operatorname{Sum}(s,x_i)$
return $s$

Here we are using $\operatorname{Sum}$ in our algorithm as a subroutine.
Note that we do not care about how $\operatorname{Sum}$ works,
it acts like black box for us,
we do not care what is going on inside $\operatorname{Sum}$.
We often refer to the subroutine $\operatorname{Sum}$ as oracle.
It is like the oracle of Delphi in Greek mythology,
we ask questions and the oracle answers them and
we use the answers.
This is essentially what a reduction is:
assume that we have algorithm for a problem and
use it as an oracle to solve another problem.
Here efficient means efficient assuming that
the oracle answers in a unit of time, i.e.
we count each execution of the oracle a single step.
If the oracle returns a large answer
we need to read it and
that can take some time,
so we should count the time it takes us to read the answer that
oracle has given to us.
Similarly for writing/asking the question from the oracle.
But oracle works instantly, i.e.
as soon as we ask the question from the oracle
the oracle writes the answer for us in a single unit of time.
All the work that oracle does is counted a single step,
but this excludes the time it takes us to
write the question and read the answer.
Because we do not care how oracle works but only about the answers it returns
we can make a simplification and consider the oracle to be
the problem itself in place of an algorithm for it.
In other words,
we do not care if the oracle is not an algorithm,
we do not care how oracles comes up with its replies.
For example,
$\operatorname{Sum}$ in the question above is the addition function itself
(not an algorithm for computing addition).
We can ask multiple questions from an oracle, and
the questions does not need to be predetermined:
we can ask a question and
based on the answer that oracle returns
we perform some computations by ourselves and then
ask another question based on the answer we got for the previous question.
Another way of looking at this is
thinking about it as an interactive computation.
Interactive computation in itself is large topic so
I will not get into it here, but
I think mentioning this perspective of reductions can be helpful.
An algorithm $A$ that uses a oracle/black box $O$ is usually denoted as $A^O$.
The reduction we discussed above is the most general form of a reduction and
is known as black-box reduction
(a.k.a. oracle reduction, Turing reduction).
More formally:

We say that problem $Q$ is black-box reducible to problem $O$ and
write $Q \leq_T O$ iff
there is an algorithm $A$ such that for all inputs $x$,
$Q(x) = A^O(x)$.

In other words if there is an algorithm $A$ which
uses the oracle $O$ as a subroutine and solves problem $Q$.
If our reduction algorithm $A$ runs in polynomial time
we call it a polynomial-time black-box reduction or
simply a Cook reduction
(in honor of
Stephen A. Cook) and
write $Q\leq^\mathsf{P}_T O$.
(The subscript $T$ stands for "Turing" in the honor of
Alan Turing).
However we may want to put some restrictions
on the way the reduction algorithm interacts with the oracle.
There are several restrictions that are studied but
the most useful restriction is the one called many-one reductions
(a.k.a. mapping reductions).
The idea here is that on a given input $x$,
we perform some polynomial-time computation and generate a $y$
that is an instance of the problem the oracle solves.
We then ask the oracle and return the answer it returns to us.
We are allowed to ask a single question from the oracle and
the oracle's answers is what will be returned.
More formally,

We say that problem $Q$ is many-one reducible to problem $O$ and
write $Q \leq_m O$ iff
there is an algorithm $A$ such that for all inputs $x$,
$Q(x) = O(A(x))$.

When the reduction algorithm is polynomial time we call it
polynomial-time many-one reduction or
simply Karp reduction (in honor of
Richard M. Karp) and
denote it by $Q \leq_m^\mathsf{P} O$.
The main reason for the interest in
this particular non-interactive reduction is that
it preserves $\mathsf{NP}$ problems:
if there is a polynomial-time many-one reduction from
a problem $A$ to an $\mathsf{NP}$ problem $B$,
then $A$ is also in $\mathsf{NP}$.
The simple notion of reduction is
one of the most fundamental notions in complexity theory
along with $\mathsf{P}$, $\mathsf{NP}$, and $\mathsf{NP}$-complete
(which we will discuss below).

The post has become too long and exceeds the limit of an answer (30000 characters).
I will continue the answer in Part II.


Question:
I was skimming through some lecture notes by Cosma Shalizi (in particular, section 2.1.1 of the second lecture), and was reminded that you can get very low $R^2$ even when you have a completely linear model.
To paraphrase Shalizi's example: suppose you have a model $Y = aX + \epsilon$, where $a$ is known. Then $\newcommand{\Var}{\mathrm{Var}}\Var[Y] = a^2 \Var[x] + \Var[\epsilon]$ and the amount of explained variance is $a^2 \Var[X]$, so $R^2 = \frac{a^2 \Var[x]}{a^2 \Var[X] + \Var[\epsilon]}$. This goes to 0 as $\Var[X] \rightarrow 0$ and to 1 as $\Var[X] \rightarrow \infty$.
Conversely, you can get high $R^2$ even when your model is noticeably non-linear. (Anyone have a good example offhand?)
So when is $R^2$ a useful statistic, and when should it be ignored?

To address the first question, consider the model
$$Y = X + \sin(X) + \varepsilon$$
with iid $\varepsilon$ of mean zero and finite variance.  As the range of $X$ (thought of as fixed or random) increases, $R^2$ goes to 1.  Nevertheless, if the variance of $\varepsilon$ is small (around 1 or less), the data are "noticeably non-linear."  In the plots, $var(\varepsilon)=1$.

Incidentally, an easy way to get a small $R^2$ is to slice the independent variables into narrow ranges.  The regression (using exactly the same model) within each range will have a low $R^2$ even when the full regression based on all the data has a high $R^2$.  Contemplating this situation is an informative exercise and good preparation for the second question.
Both the following plots use the same data.  The $R^2$ for the full regression is 0.86.  The $R^2$ for the slices (of width 1/2 from -5/2 to 5/2) are .16, .18, .07, .14, .08, .17, .20, .12, .01, .00, reading left to right.  If anything, the fits get better in the sliced situation because the 10 separate lines can more closely conform to the data within their narrow ranges.  Although the $R^2$ for all the slices are far below the full $R^2$, neither the strength of the relationship, the linearity, nor indeed any aspect of the data (except the range of $X$ used for the regression) has changed.

(One might object that this slicing procedure changes the distribution of $X$.  That is true, but it nevertheless corresponds with the most common use of $R^2$ in fixed-effects modeling and reveals the degree to which $R^2$ is telling us about the variance of $X$ in the random-effects situation.  In particular, when $X$ is constrained to vary within a smaller interval of its natural range, $R^2$ will usually drop.)
The basic problem with $R^2$ is that it depends on too many things (even when adjusted in multiple regression), but most especially on the variance of the independent variables and the variance of the residuals.  Normally it tells us nothing about "linearity" or "strength of relationship" or even "goodness of fit" for comparing a sequence of models.
Most of the time you can find a better statistic than $R^2$.  For model selection you can look to AIC and BIC; for expressing the adequacy of a model, look at the variance of the residuals.
This brings us finally to the second question.  One situation in which $R^2$ might have some use is when the independent variables are set to standard values, essentially controlling for the effect of their variance.  Then $1 - R^2$ is really a proxy for the variance of the residuals, suitably standardized.


Question:
In this comment I wrote:

...default SciPy integrator, which I'm assuming only uses symplectic methods.

in which I am refering to SciPy's odeint, which uses either a "non-stiff (Adams) method" or a "stiff (BDF) method". According to the source:
def odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0,
           ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0,
           hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12,
           mxords=5, printmessg=0):
    """
    Integrate a system of ordinary differential equations.

    Solve a system of ordinary differential equations using lsoda from the
    FORTRAN library odepack.

    Solves the initial value problem for stiff or non-stiff systems
    of first order ode-s::
        dy/dt = func(y, t0, ...)
    where y can be a vector.
    """

Here is an example where I propagate a satellite's orbit around the earth for three months just to show that it precesses as expected.
I believe that non-symplectic integrators have the undesirable property that they will tend not to conserve energy (or other quantities) and so are undesirable in orbital mechanics for example. But I'm not exactly sure what it is that makes a symplectic integrator symplectic.
Is it possible to explain what the property is (that makes a symplectic integrator symplectic) in a straightforward and (fairly) easy to understand but not inaccurate way? I'm asking from the point of view of how the integrator functions internally, rather than how it performs in testing.
And is my suspicion correct that odeint does use only symplectic integrators?

Let me start off with corrections. No, odeint doesn't have any symplectic integrators. No, symplectic integration doesn't mean conservation of energy.
What does symplectic mean and when should you use it?
First of all, what does symplectic mean? Symplectic means that the solution exists on a symplectic manifold. A symplectic manifold is a solution set which is defined by a 2-form. The details of symplectic manifolds probably sound like mathematical nonsense, so instead the gist of it is there is a direct relation between two sets of variables on such a manifold. The reason why this is important for physics is because Hamiltonian's equations naturally have that the solutions reside on a symplectic manifold in phase space, with the natural splitting being the position and momentum components. For the true Hamiltonian solution, that phase space path is constant energy.
A symplectic integrator is an integrator whose solution resides on a symplectic manifold. Because of discretization error, when it is solving a Hamiltonian system it doesn't get exactly the correct trajectory on the manifold. Instead, that trajectory itself is perturbed $\mathcal{O}(\Delta t^n)$ for the order $n$ from the true trajectory. Then there's a linear drift due to numerical error of this trajectory over time. Normal integrators tend to have a quadratic (or more) drift, and do not have any good global guarantees about this phase space path (just local).
What this tends to mean is that symplectic integrators tend to capture the long-time patterns better than normal integrators because of this lack of drift and this almost guarantee of periodicity. This notebook displays those properties well on the Kepler problem. The first image shows what I'm talking about with the periodic nature of the solution.

This was solved using the 6th order symplectic integrator from Kahan and Li from DifferentialEquations.jl. You can see that the energy isn't exactly conserved, but its variation is dependent on how far the perturbed solution manifold is from the true manifold. But since the numerical solution itself resides on a symplectic manifold, it tends to be almost exactly periodic (with some linear numerical drift that you can see), making it do very nicely for long term integration. If you do the same with RK4, you can get disaster:

You can see that the issue is that there's no true periodicity in the numerical solution and therefore overtime it tends to drift.
This highlights the true reason to choose symplectic integrators: symplectic integrators are good on long-time integrations on problems that have the symplectic property (Hamiltonian systems). So let's walk through a few things. Note that you don't always need symplectic integrators even on a symplectic problem. For this case, an adaptive 5th order Runge-Kutta method can do fine. Here's Tsit5:

Notice two things. One, it gets a good enough accuracy that you cannot see the actual drift in the phase space plot. However, on the right side you can see that there is this energy drift, and so if you are doing a long enough integration this method will not do as well as the solution method with the periodic properties. But that raises the question, how does it fare efficiency-wise vs just integrating extremely accurately? Well, this is a bit less certain. In SciMLBenchmarks.jl you can find some benchmarks investigating this question. For example, this notebook looks at the energy error vs runtime on a Hamiltonian equation system from a quadruple Boson model and shows that if you want really high accuracy, then even for quite long integration times it's more efficient to just use a high order RK or Runge-Kutta Nystrom (RKN) method. This makes sense because to satisfy the symplectic property the integrators give up some efficiency and pretty much have to be fixed time step (there is some research making headway into the latter but it's not very far along).
In addition, notice from both of these notebooks that you can also just take a standard method and project it back to the solution manifold each step (or every few steps). This is what the examples using the DifferentialEquations.jl ManifoldProjection callback are doing. You see that guarantees conservation laws are upheld but with an added cost of solving an implicit system each step. You can also use a fully-implicit ODE solver or singular mass matrices to add on conservation equations, but the end result is that these methods are more computationally-costly as a tradeoff.
So to summarize, the class of problems where you want to reach for a symplectic integrator are those that have a solution on a symplectic manifold (Hamiltonian systems) where you don't want to invest the computational resources to have a very exact (tolerance <1e-12) solution and don't need exact energy/etc. conservation. This highlights that it's all about long-term integration properties, so you shouldn't just flock to them all willy-nilly like some of the literature suggests. But they are still a very important tool in many fields like Astrophysics where you do have long time integrations that you need to solve sufficiently fast without having absurd accuracy.
Where do I find symplectic integrators? What kind of symplectic integrators exist?
There are generally two classes of symplectic integrators. There are the symplectic Runge-Kutta integrators (which are the ones shown in the above examples) and there are implicit Runge-Kutta methods which have the symplectic property. As @origimbo mentions, the symplectic Runge-Kutta integrators require that you provide them with a partitioned structure so they can handle the position and momentum parts separately. However, counter to the comment, the implicit Runge-Kutta methods are symplectic without requiring this, but instead require solving a nonlinear system. This isn't too bad because if the system is non-stiff this nonlinear system can be solved with functional iteration or Anderson acceleration, but the symplectic RK methods should still probably be preferred for efficiency (it's a general rule that the more information you provide to an integrator, the more efficient it is).
That said, odeint does not have methods from either of these families, so it is not a good choice if you're looking for symplectic integrators. In Fortran, Hairer's site has a small set you can use. Mathematica has a few built in. The GSL ODE solvers have implicit RK Gaussian point integrators which IIRC are symplectic, but that's about the only reason to use the GSL methods.
But the most comprehensive set of symplectic integrators can be found in DifferentialEquations.jl in Julia (recall this was used for the notebooks above). The list of available symplectic Runge-Kutta methods is found on this page and you'll notice that the implicit midpoint method is also symplectic (the implicit Runge-Kutta Trapezoid method is considered "almost symplectic" because it's reversible). Not only does it have the largest set of methods, but it's also open-source (you can see the code and its tests in a high-level language) and has a lot of benchmarks. A good introductory notebook for using it to solve physical problems is this tutorial notebook. But of course it's recommended you get started with the package through the first ODE tutorial.
In general you can find a detailed analysis of numerical differential equation suites at this blog post. It's quite detailed but since it has to cover a lot of topics it does each at less detail than this, so feel free to ask for it to be expanded in any way.


Question:
I need help with this integral:
$$I=\int_{-1}^1\frac1x\sqrt{\frac{1+x}{1-x}}\ln\left(\frac{2\,x^2+2\,x+1}{2\,x^2-2\,x+1}\right)\ \mathrm dx.$$
The integrand graph looks like this:
$\hspace{1in}$
The approximate numeric value of the integral:
$$I\approx8.372211626601275661625747121...$$
Neither Mathematica nor Maple could find a closed form for this integral, and lookups of the approximate numeric value in WolframAlpha and ISC+ did not return plausible closed form candidates either. But I still hope there might be a closed form for it.
I am also interested in cases when only numerator or only denominator is present under the logarithm.

I will transform the integral via a substitution, break it up into two pieces and recombine, perform an integration by parts, and perform another substitution to get an integral to which I know a closed form exists.  From there, I use a method I know to attack the integral, but in an unusual way because of the 8th degree polynomial in the denominator of the integrand.
First sub $t=(1-x)/(1+x)$, $dt=-2/(1+x)^2 dx$ to get
$$2 \int_0^{\infty} dt \frac{t^{-1/2}}{1-t^2} \log{\left (\frac{5-2 t+t^2}{1-2 t +5 t^2} \right )} $$
Now use the symmetry from the map $t \mapsto 1/t$.  Break the integral up into two as follows:
\begin{align}
& 2 \int_0^{1} dt \frac{t^{-1/2}}{1-t^2} \log{\left (\frac{5-2 t+t^2}{1-2 t +5 t^2} \right )} + 2 \int_1^{\infty} dt \frac{t^{-1/2}}{1-t^2} \log{\left (\frac{5-2 t+t^2}{1-2 t +5 t^2} \right )} \\
&= 2 \int_0^{1} dt \frac{t^{-1/2}}{1-t^2} \log{\left (\frac{5-2 t+t^2}{1-2 t +5 t^2} \right )} + 2 \int_0^{1} dt \frac{t^{1/2}}{1-t^2} \log{\left (\frac{5-2 t+t^2}{1-2 t +5 t^2} \right )} \\
&= 2 \int_0^{1} dt \frac{t^{-1/2}}{1-t} \log{\left (\frac{5-2 t+t^2}{1-2 t +5 t^2} \right )}
\end{align}
Sub $t=u^2$ to get
$$4 \int_0^{1} \frac{du}{1-u^2} \log{\left (\frac{5-2 u^2+u^4}{1-2 u^2 +5 u^4} \right )}$$
Integrate by parts:
$$\left [2 \log{\left (\frac{1+u}{1-u} \right )} \log{\left (\frac{5-2 u^2+u^4}{1-2 u^2 +5 u^4} \right )}\right ]_0^1 \\- 32 \int_0^1 du \frac{\left(u^5-6 u^3+u\right)}{\left(u^4-2 u^2+5\right) \left(5 u^4-2 u^2+1\right)} \log{\left (\frac{1+u}{1-u} \right )}$$
One last sub: $u=(v-1)/(v+1)$ $du=2/(v+1)^2 dv$, and finally get
$$8 \int_0^{\infty} dv \frac{(v^2-1)(v^4-6 v^2+1)}{v^8+4 v^6+70v^4+4 v^2+1} \log{v}$$
With this form, we may finally conclude that a closed form exists and apply the residue theorem to obtain it.  To wit, consider the following contour integral:
$$\oint_C dz \frac{8 (z^2-1)(z^4-6 z^2+1)}{z^8+4 z^6+70z^4+4 z^2+1} \log^2{z}$$
where $C$ is a keyhole contour about the positive real axis.  This contour integral is equal to (I omit the steps where I show the integral vanishes about the circular arcs)
$$-i 4 \pi \int_0^{\infty} dv \frac{8 (v^2-1)(v^4-6 v^2+1)}{v^8+4 v^6+70v^4+4 v^2+1} \log{v} + 4 \pi^2 \int_0^{\infty} dv \frac{8 (v^2-1)(v^4-6 v^2+1)}{v^8+4 v^6+70v^4+4 v^2+1}$$
It should be noted that the second integral vanishes; this may be easily seen by exploiting the symmetry about $v \mapsto 1/v$.
On the other hand, the contour integral is $i 2 \pi$ times the sum of the residues about the poles of the integrand.  In general, this requires us to find the zeroes of the eight degree polynomial, which may not be possible analytically.  Here, on the other hand, we have many symmetries to exploit, e.g., if $a$ is a root, then $1/a$ is a root, $-a$ is a root, and $\bar{a}$ is a root.  For example, we may deduce that
$$z^8+4 z^6+70z^4+4 z^2+1 = (z^4+4 z^3+10 z^2+4 z+1)  (z^4-4 z^3+10 z^2-4 z+1)$$
which exploits the $a \mapsto -a$ symmetry.  Now write
$$z^4+4 z^3+10 z^2+4 z+1 = (z-a)(z-\bar{a})\left (z-\frac{1}{a}\right )\left (z-\frac{1}{\bar{a}}\right )$$
Write $a=r e^{i \theta}$ and get the following equations:
$$\left ( r+\frac{1}{r}\right ) \cos{\theta}=-2$$
$$\left (r^2+\frac{1}{r^2}\right) + 4 \cos^2{\theta}=10$$
From these equations, one may deduce that a solution is $r=\phi+\sqrt{\phi}$ and $\cos{\theta}=1/\phi$, where $\phi=(1+\sqrt{5})/2$ is the golden ratio.  Thus the poles take the form
$$z_k = \pm \left (\phi\pm\sqrt{\phi}\right) e^{\pm i \arctan{\sqrt{\phi}}}$$
Now we have to find the residues of the integrand at these 8 poles.  We can break this task up by computing:
$$\sum_{k=1}^8 \operatorname*{Res}_{z=z_k} \left [\frac{8 (z^2-1)(z^4-6 z^2+1)  \log^2{z}}{z^8+4 z^6+70z^4+4 z^2+1}\right ]=\sum_{k=1}^8 \operatorname*{Res}_{z=z_k} \left [\frac{8 (z^2-1)(z^4-6 z^2+1)}{z^8+4 z^6+70z^4+4 z^2+1}\right ] \log^2{z_k}$$
Here things got very messy, but the result is rather unbelievably simple:
$$\operatorname*{Res}_{z=z_k} \left [\frac{8 (z^2-1)(z^4-6 z^2+1)}{z^8+4 z^6+70z^4+4 z^2+1}\right ] = \text{sgn}[\cos{(\arg{z_k})}]$$
EDIT
Actually, this is a very simple computation.  Inspired by @sos440, one may express the rational function of $z$ in a very simple form:
$$\frac{8 (z^2-1)(z^4-6 z^2+1)}{z^8+4 z^6+70z^4+4 z^2+1} = -\left [\frac{p'(z)}{p(z)} + \frac{p'(-z)}{p(-z)} \right ]$$
where
$$p(z)=z^4+4 z^3+10 z^2+4 z+1$$
The residue of this function at the poles are then easily seen to be $\pm 1$ according to whether the pole is a zero of $p(z)$ or $p(-z)$.
END EDIT
That is, if the pole has a positive real part, the residue of the fraction is $+1$; if it has a negative real part, the residue is $-1$.
Now consider the log piece.  Expanding the square, we get 3 terms:
$$\log^2{|z_k|} - (\arg{z_k})^2 + i 2 \log{|z_k|} \arg{z_k}$$
Summing over the residues, we find that because of the $\pm1$ contributions above, that the first and third terms sum to zero.  This leaves the second term.  For this, it is crucial that we get the arguments right, as $\arg{z_k} \in [0,2 \pi)$.  Thus, we have
$$\begin{align}I= \int_0^{\infty} dv \frac{8 (v^2-1)(v^4-6 v^2+1)}{v^8+4 v^6+70v^4+4 v^2+1} \log{v} &= \frac12 \sum_{k=1}^8 \text{sgn}[\cos{(\arg{z_k})}] (\arg{z_k})^2 \\ &= \frac12 [2 (\arctan{\sqrt{\phi}})^2 + 2 (2 \pi - \arctan{\sqrt{\phi}})^2 \\ &- 2 (\pi - \arctan{\sqrt{\phi}})^2 - 2 (\pi + \arctan{\sqrt{\phi}})^2]\\ &= 2 \pi^2 -4 \pi \arctan{\sqrt{\phi}} \\ &= 4 \pi \, \text{arccot}{\sqrt{\phi}}\\\end{align}$$


Question: This may be a ridiculous question, but is it possible to have a problem that actually gets easier as the inputs grow in size?  I doubt any practical problems are like this, but maybe we can invent a degenerate problem that has this property.  For instance, perhaps it begins to "solve itself" as it gets larger, or behaves in some other bizarre way.

No, it's not possible: at least, not in an asymptotic sense, where you require the problem to keep getting strictly easier, forever, as $n \to \infty$.
Let $T(n)$ be the best possible running time for solving such a problem, where $n$ is the size of the input.  Note that the running time is a count of the number of instructions executed by the algorithm, so it has to be a non-negative integer.  In other words, $T(n) \in \mathbb{N}$ for all $n$.  Now if we consider a function $T: \mathbb{N} \to \mathbb{N}$, we see there is no such function that is strictly monotonically decreasing.  (Whatever $T(0)$ is, it has to be finite, say $T(0)=c$; but then since $T$ is monotonically strictly decreasing, $T(c) \le 0$ and $T(c+1) \le -1$, which is impossible.)  For similar reasons, there is no function that is asymptotically strictly decreasing: we can similarly prove that there's no running time function $T(n)$ where there exists $n_0$ such that for all $n \ge n_0$, $T(n)$ is monotonically strictly decreasing (any such function would have to become eventually negative).
So, such a problem cannot exist, for the simple reason that running times have to be non-negative integers.

Note that this answer covers only deterministic algorithms (i.e., worst-case running time).  It doesn't rule out the possibility of randomized algorithms whose expected running time is strictly monotonically decreasing, forever.  I don't know whether it's possible for such an algorithm to exist.  I thank Beni Cherniavsky-Paskin for this observation.


Question:
General relativity says that spacetime is a Lorentzian 4-manifold $M$ whose metric satisfies Einstein's field equations.  I have two questions:

What topological restrictions do Einstein's equations put on the manifold?  For instance, the existence of a Lorentz metric implies some topological things, like the Euler characteristic vanishing.
Are there any experiments being done or even any hypothetical experiments that can give information on the topology?  E.g. is there a group of graduate students out there trying to contract loops to discover the fundamental group of the universe?

That's a great question! What you are asking about is one of the missing links between classical and quantum gravity.
On their own, the Einstein equations, $ G_{\mu\nu} = 8 \pi G T_{\mu\nu}$, are local field equations and do not contain any topological information. At the level of the action principle,
$$ S_{\mathrm{eh}} = \int_\mathcal{M} d^4 x \, \sqrt{-g} \, \mathbf{R} $$
the term we generally include is the Ricci scalar $ \mathbf{R} = \mathrm{Tr}[ R_{\mu\nu} ] $, which depends only on the first and second derivatives of the metric and is, again, a local quantity. So the action does not tell us about topology either, unless you're in two dimensions, where the Euler characteristic is given by the integral of the ricci scalar:
$$ \int d^2 x \, \mathcal{R} = \chi $$
(modulo some numerical factors). So gravity in 2 dimensions is entirely topological. This is in contrast to the 4D case where the Einstein-Hilbert action appears to contain no topological information.
This should cover your first question.
All is not lost, however. One can add topological degrees of freedom to 4D gravity by the addition of terms corresponding to various topological invariants (Chern-Simons, Nieh-Yan and Pontryagin). For instance, the Chern-Simons contribution to the action looks like:
$$ S_{cs} = \int d^4 x \frac{1}{2} \left(\epsilon_{ab} {}^{ij}R_{cdij}\right)R_{abcd} $$
Here is a very nice paper by Jackiw and Pi for the details of this construction.
There's plenty more to be said about topology and general relativity. Your question only scratches the surface. But there's a goldmine underneath ! I'll let someone else tackle your second question. Short answer is "yes".


Question:
I would like to implement an algorithm for automatic model selection.
I am thinking of doing stepwise regression but anything will do (it has to be based on linear regressions though).
My problem is that I am unable to find a methodology, or an open source implementation (I am woking in java). The methodology I have in mind would be something like:

calculate the correlation matrix of all the factors
pick the factors that have a low correlation to each other
remove the factors that have a low t-stat
add other factors (still based on the low correlation factor found in 2.).
reiterate several times until some criterion (e.g AIC) is over a certain threshold or cannot or we can't find a larger value.

I realize there is an R implementation for this (stepAIC), but I find the code quite hard to understand. Also I have not been able to find articles describing the stepwise regression.

I think this approach is mistaken, but perhaps it will be more helpful if I explain why.  Wanting to know the best model given some information about a large number of variables is quite understandable.  Moreover, it is a situation in which people seem to find themselves regularly.  In addition, many textbooks (and courses) on regression cover stepwise selection methods, which implies that they must be legitimate.  Unfortunately, however, they are not, and the pairing of this situation and goal is quite difficult to successfully navigate.  The following is a list of problems with automated stepwise model selection procedures (attributed to Frank Harrell, and copied from here):

It yields R-squared values that are badly biased to be high.

The F and chi-squared tests quoted next to each variable on the  printout do not have the claimed distribution.

The method yields confidence intervals for effects and predicted values that are falsely narrow; see Altman and Andersen (1989).

It yields p-values that do not have the proper meaning, and the proper correction for them is a difficult problem.

It gives biased regression coefficients that need shrinkage (the coefficients for remaining variables are too large; see Tibshirani
[1996]).

It has severe problems in the presence of collinearity.

It is based on methods (e.g., F tests for nested models) that were intended to be used to test prespecified hypotheses.

Increasing the sample size does not help very much; see Derksen and Keselman (1992).

It allows us to not think about the problem.

It uses a lot of paper.

The question is, what's so bad about these procedures / why do these problems occur?  Most people who have taken a basic regression course are familiar with the concept of regression to the mean, so this is what I use to explain these issues.  (Although this may seem off-topic at first, bear with me, I promise it's relevant.)
Imagine a high school track coach on the first day of tryouts.  Thirty kids show up.  These kids have some underlying level of intrinsic ability to which neither the coach nor anyone else, has direct access.  As a result, the coach does the only thing he can do, which is have them all run a 100m dash.  The times are presumably a measure of their intrinsic ability and are taken as such.  However, they are probabilistic; some proportion of how well someone does is based on their actual ability, and some proportion is random.  Imagine that the true situation is the following:
set.seed(59)
intrinsic_ability = runif(30, min=9, max=10)
time = 31 - 2*intrinsic_ability + rnorm(30, mean=0, sd=.5)

The results of the first race are displayed in the following figure along with the coach's comments to the kids.

Note that partitioning the kids by their race times leaves overlaps on their intrinsic ability--this fact is crucial.  After praising some, and yelling at some others (as coaches tend to do), he has them run again.  Here are the results of the second race with the coach's reactions (simulated from the same model above):

Notice that their intrinsic ability is identical, but the times bounced around relative to the first race.  From the coach's point of view, those he yelled at tended to improve, and those he praised tended to do worse (I adapted this concrete example from the Kahneman quote listed on the wiki page), although actually regression to the mean is a simple mathematical consequence of the fact that the coach is selecting athletes for the team based on a measurement that is partly random.
Now, what does this have to do with automated (e.g., stepwise) model selection techniques?  Developing and confirming a model based on the same dataset is sometimes called data dredging.  Although there is some underlying relationship amongst the variables, and stronger relationships are expected to yield stronger scores (e.g., higher t-statistics), these are random variables, and the realized values contain error.  Thus, when you select variables based on having higher (or lower) realized values, they may be such because of their underlying true value, error, or both.  If you proceed in this manner, you will be as surprised as the coach was after the second race.  This is true whether you select variables based on having high t-statistics, or low intercorrelations.  True, using the AIC is better than using p-values, because it penalizes the model for complexity, but the AIC is itself a random variable (if you run a study several times and fit the same model, the AIC will bounce around just like everything else).  Unfortunately, this is just a problem intrinsic to the epistemic nature of reality itself.
I hope this is helpful.


Question:
At the Renaissance fair a few years back I was watching a smith forge metal into shapes. During this time a very odd question came to me. I was wondering what the furnace was made of. My logic stated that whatever the furnace was made of must have a higher melting point than the materials he was melting. This quickly turned into an elemental arms race resulting in an odd question of how do we melt stuff like refractory metals (more specifically the one with the highest melting point) so we can melt other things inside of it.
Now I know that (for some odd reason I don't understand) rapid cooling can manipulate the strength of an item. Is there a similar property to manipulate the melting point?
Note: My current best guess (like can be done to make weapons harder) is that we take two elements, melt them, and the resulting compound has a higher melting point.

Tungsten's melting point of 3422 °C is the highest of all metals and second only to carbon's, for which melting occurs only at high pressure (there's no standard melting point). This is why tungsten is used in rocket nozzles and reactor linings.  There are refractory ceramics and alloys that have higher melting points, notably $\ce{Ta4HfC5}$ with a melting point of 4215 °C, hafnium carbide at 3900 °C and tantalum carbide at 3800 °C.
Carbon cannot be used to hold molten tungsten because they will react to form tungsten carbide.  Sometimes ladles and crucibles used to prepare or transport high melting point materials like tungsten are lined with the various higher melting ceramics or alloys.  More typically tungsten and other refractory materials are fabricated in a non-molten state.  A process known as powder metallurgy is used.  This process uses 4 basic steps:

powder manufacture - a variety of techniques are available to generate small particles of the material being worked
powder blending - routine procedures are used to blend the constituent particles into a uniform mixture
compacting - the blended powder is placed in a mold and subjected to high pressure
sintering - the compacted material is subjected to high temperature and some level of bonding occurs between particles.


Question:
I remember coming across the following question about a language that supposedly is context-free, but I was unable to find a proof of the fact. Have I perhaps misremembered the question?
Anyway, here's the question:

Show that the language $L = \{xy \mid |x| = |y|, x\neq y\}$ is context free.

Claim: $L$ is context-free.
Proof Idea: There has to be at least one difference between the first and second half; we give a grammar that makes sure to generate one and leaves the rest arbitrary.
Proof: For sake of simplicity, assume a binary alphabet $\Sigma = \{a,b\}$. The proof readily extends to other sizes. Consider the grammar $G$:
$\qquad\begin{align}
  S &\to AB \mid BA \\
  A &\to a \mid aAa \mid aAb \mid bAa \mid bAb \\
  B &\to b \mid aBa \mid aBb \mid bBa \mid bBb
\end{align}$
It is quite clear that it generates
$\qquad \mathcal{L}(G) = \{ \underbrace{w_1}_k x \underbrace{w_2v_1}_{k+l}y\underbrace{v_2}_l \mid |w_1|=|w_2|=k, |v_1|=|v_2|=l, x\neq y \} \subseteq \Sigma^*;$
the suspicious may perform a nested induction over $k$ and $l$ with case distinction over pairs $(x,y)$.
The length of a word in $\mathcal{L}(G)$ is $2(k+l+1)$. The letters $x$ and $y$ occur on positions $k+1$ and $2k+l+2$, respectively. When we split the word in half, i.e. after $(k+l+1)$ letters, then the first half contains the letter $x$ on position $k+1$ and the second half has the letter $y$ on position $k+1$.
Therefore, $x$ and $y$ have the same position (in their respective half), which implies $\mathcal{L}(G) = L$ because $G$ imposes no other restrictions on its language.

The interested reader may enjoy two follow-up problems:
Exercise 1: Come up with a PDA for $L$!
Exercise 2: What about $\{xyz \mid |x|=|y|=|z|, x\neq y \lor y \neq z \lor x \neq z\}$?


Question:
How do you write a .gz (or .bgz) fastq file using Biopython?
I'd rather avoid a separate system call.
The typical way to write an ASCII .fastq is done as follows:
for record in SeqIO.parse(fasta, "fasta"):
    SeqIO.write(record, fastq, "fastq")

The record is a SeqRecord object, fastq is the file handle, and "fastq" is the requested file format. The file format may be fastq, fasta, etc., but I do not see an option for .gz.
Here is the SeqIO API.

I'm not sure I'm doing it the best way, but here is an example where I read a compressed gzip fastq file and write the records in block gzip fastq:
from Bio import SeqIO, bgzf
# Used to convert the fastq stream into a file handle
from io import StringIO
from gzip import open as gzopen

records = SeqIO.parse(
    # There is actually simpler (thanks @peterjc)
    # StringIO(gzopen("random_10.fastq.gz").read().decode("utf-8")),
    gzopen("random_10.fastq.gz", "rt"),
    format="fastq")

with bgzf.BgzfWriter("test.fastq.bgz", "wb") as outgz:
    SeqIO.write(sequences=records, handle=outgz, format="fastq")


Question:
I was just learning about the frequency domain in images.
I can understand the frequency spectrum in case of waves. It denotes what frequencies are present in a wave. If we draw the frequency spectrum of $\cos(2\pi f t)$, we get an impulse signal at $-f$ and $+f$. And we can use corresponding filters to extract particular information.
But what does frequency spectrum means in case of images? When we take the FFT of a image in OpenCV, we get a weird picture. What does this image denote? And what is its application?
I read some books, but they give a lot of mathematical equations rather than the physical implication. So can anyone provide a simple explanation of the frequency domain in images with a simple application of it in image processing?

But what does frequency spectrum means in case of images?

The "mathematical equations" are important, so don't skip them entirely. But the 2d FFT has an intuitive interpretation, too. For illustration, I've calculated the inverse FFT of a few sample images:

As you can see, only one pixel is set in the frequency domain. The result in the image domain (I've only displayed the real part) is a "rotated cosine pattern" (the imaginary part would be the corresponding sine).
If I set a different pixel in the frequency domain (at the left border):

I get a different 2d frequency pattern.
If I set more than one pixel in the frequency domain:

you get the sum of two cosines.
So like a 1d wave, that can be represented as a sum of sines and cosines, any 2d image can be represented (loosely speaking) as a sum of "rotated sines and cosines", as shown above.

when we take fft of a image in opencv, we get weird picture. What does this image denote?

It denotes the amplitudes and frequencies of the sines/cosines that, when added up, will give you the original image.

And what is its application?

There are really too many to name them all. Correlation and convolution can be calculated very efficiently using an FFT, but that's more of an optimization, you don't "look" at the FFT result for that. It's used for image compression, because the high frequency components are usually just noise.


Question:
In an 8-bit microprocessor its data bus consists of 8 data lines.  In a 16-bit microprocessor its data bus consists of 16 data lines and so on.
Why is there neither a 256-bit microprocessor nor a 512-bit microprocessor?  Why don't they simply increase the number of the data lines and create a 256-bit microprocessor or a 512-bit microprocessor?
What is the obstacle that prevents creating a 256-bit microprocessor or a 512-bit microprocessor?

Think about it.  What exactly do you envision a "256 bit" processor being?  What makes the bit-ness of a processor in the first place?
I think if no further qualifications are made, the bit-ness of a processor refers to its ALU width.  This is the width of the binary number that it can handle natively in a single operation.  A "32 bit" processor can therefore operate directly on values up to 32 bits wide in single instructions.  Your 256 bit processor would therefore contain a very large ALU capable of adding, subtracting, ORing, ANDing, etc, 256 bit numbers in single operations.  Why do you want that?  What problem makes the large and expensive ALU worth having and paying for, even for those cases where the processor is only counting 100 iterations of a loop and the like?
The point is, you have to pay for the wide ALU whether you then use it a lot or only a small fraction of its capabilities.  To justify a 256 bit ALU, you'd have to find an important enough problem that can really benefit from manipulating 256 bit words in single instructions.  While you can probably contrive a few examples, there aren't enough of such problems that make the manufacturers feel they will ever get a return on the significant investment required to produce such a chip.  If it there are niche but important (well-funded) problems that can really benefit from a wide ALU, then we would see very expensive highly targeted processors for that application.  Their price, however, would prevent wide usage outside the narrow application that it was designed for.  For example, if 256 bits made certain cryptography applications possible for the military, specialized 256 bit processors costing 100s to 1000s of dollars each would probably emerge.  You wouldn't put one of these in a toaster, a power supply, or even a car though.
I should also be clear that the wide ALU doesn't just make the ALU more expensive, but other parts of the chip too.  A 256 bit wide ALU also means there have to be 256 bit wide data paths.  That alone would take a lot of silicon area.  That data has to come from somewhere and go somewhere, so there would need to be registers, cache, other memory, etc, for the wide ALU to be used effectively.
Another point is that you can do any width arithmetic on any width processor.  You can add a 32 bit memory word into another 32 bit memory word on a PIC 18 in 8 instructions, whereas you could do it on the same architecture scaled to 32 bits in only 2 instructions.  The point is that a narrow ALU doesn't keep you from performing wide computations, only that the wide computations will take longer.  It is therefore a question of speed, not capability.  If you look at the spectrum of applications that need to use particular width numbers, you will see very very few require 256 bit words.  The expense of accelerating just those few applications with hardware that won't help the others just isn't worth it and doesn't make a good investment for product development.


Question:
A number of countries are using test kits for detecting new cases of nCoV (2019-Coronavirus) and apparently China is running low.
What exactly is in a nCoV "Test Kit" — How does it work?
(Surely they also differ, so in which way do they differ?)

The CDC has made available online its nCoV test kit. Briefly,the kit contains primers and probes for real-time reverse-transcriptase PCR, as well as instructions for appropriate use and (critically) controls and guidelines to avoid false positives and negatives. Kits from different countries may use slightly different primers and probes, though since they are all working from the same sequences and the same principles they should be broadly quite similar.
Explaining how quantitative PCR works and the details of the primers and probes is out of the scope of this SE. A layman's introduction was written by John Timmer at Ars Technica.


Question:
Interstitial fluid is the fluid between cells in tissues - forming the medium between cells and capillaries. From what I gather, the typical human has 5L of blood and 11L of interstitial fluid. This raises an interesting question. If I get cut, why do I not bleed interstitial fluid?
When humans are cut, generally their capillaries open and blood comes out. But this should also allow the interstitial fluid to come out - so why don't we see it?

For fluid to flow from a wound there needs to be a significant pressure gradient between where it is now and the outside of the body. Your skin generally does not have a strong compressive effect, which is why a deep cut exposing fat will not lead to the fatty tissue being expulsed from the body any more than the interstitial fluid is.
Blood, however, flows. For it to circulate there needs to be a pressure gradient between where it is now and where it is going. Since veins (including the vena cava, which channels blood back into the heart) do not have vascular walls strong enough to create a suction effect (i.e. lower pressure than the surrounding tissue), you can conclude that the pressure of blood vessels is always higher than that of surrounding tissues, and thus higher than the pressure outside of your body. This is why all blood vessels, including veins, will bleed, whereas less pressurized systems such as interstitial fluid will not.


Question: The ghostly passage of one body through another is obviously out of the question if the continuum assumption were valid, but we know that at the micro, nano, pico levels (and beyond) this is not even remotely the case. My understanding is that the volume of the average atom actually occupied by matter is a vanishingly small fraction of the atom's volume as a whole. If this is the case, why can't matter simply pass through other matter? Are the atom's electrons so nearly omnipresent that they can simultaneously prevent collisions/intersections from all possible directions?

Things are not empty space. Our classical intuition fails at the quantum level.
Matter does not pass through other matter mainly due to the Pauli exclusion principle and due to the electromagnetic repulsion of the electrons. The closer you bring two atoms, i.e. the more the areas of non-zero expectation for their electrons overlap, the stronger will the repulsion due to the Pauli principle be, since it can never happen that two electrons possess exactly the same spin and the same probability to be found in an extent of space.
The idea that atoms are mostly "empty space" is, from a quantum viewpoint, nonsense. The volume of an atom is filled by the wavefunctions of its electrons, or, from a QFT viewpoint, there is a localized excitation of the electron field in that region of space, which are both very different from the "empty" vacuum state.
The concept of empty space is actually quite tricky, since our intuition "Space is empty when there is no particle in it" differs from the formal "Empty space is the unexcited vacuum state of the theory" quite a lot. The space around the atom is definitely not in the vacuum state, it is filled with electron states. But if you go and look, chances are, you will find at least some "empty" space in the sense of "no particles during measurement". Yet you are not justified in saying that there is "mostly empty space" around the atom, since the electrons are not that sharply localized unless some interaction (like measurements) takes place that actually forces them to. When not interacting, their states are "smeared out" over the atom in something sometimes called the electron cloud, where the cloud or orbital represents the probability of finding a particle in any given spot.
This weirdness is one of the reasons why quantum mechanics is so fundamentally different from classical mechanics – suddenly, a lot of the world becomes wholly different from what we are used to at our macroscopic level, and especially our intuitions about "empty space" and such fail us completely at microscopic levels.
Since it has been asked in the comments, I should probably say a few more words about the role of the exclusion principle:
First, as has been said, without the exclusion principle, the whole idea of chemistry collapses: All electrons fall to the lowest 1s orbital and stay there, there are no "outer" electrons, and the world as we know it would not work.
Second, consider the situation of two equally charged classical particles: If you only invest enough energy/work, you can bring them arbitrarily close. The Pauli exclusion principle prohibits this for the atoms – you might be able to push them a little bit into each other, but at some point, when the states of the electrons become too similar, it just won't go any further. When you hit that point, you have degenerate matter, a state of matter which is extremely difficult to compress, and where the exclusion principle is the sole reason for its incompressibility. This is not due to Coulomb repulsion, it is that that we also need to invest the energy to catapult the electrons into higher energy levels since the number of electrons in a volume of space increases under compression, while the number of available energy levels does not. (If you read the article, you will find that the electrons at some point will indeed prefer to combine with the protons and form neutrons, which then exhibit the same kind of behaviour. Then, again, you have something almost incompressible, until the pressure is high enough to break the neutrons down into quarks (that is merely theoretical). No one knows what happens when you increase the pressure on these quarks indefinitely, but we probably cannot know that anyway, since a black hole will form sooner or later)
Third, the kind of force you need to create such degenerate matter is extraordinarily high. Even metallic hydrogen, the probably simplest kind of such matter, has not been reliably produced in experiments. However, as Mark A has pointed out  in the comments (and as is very briefly mentioned in the Wikipedia article, too), a very good model for the free electrons in a metal is that of a degenerate gas, so one could take metal as a room-temperature example of the importance of the Pauli principle.
So, in conclusion, one might say that at the levels of our everyday experience, it would probably enough to know about the Coulomb repulsion of the electrons (if you don't look at metals too closely). But without quantum mechanics, you would still wonder why these electrons do not simply go closer to their nuclei, i.e. reduce their orbital radius/drop to a lower energy state, and thus reduce the effective radius of the atom. Therefore, Coulomb repulsion already falls short at this scale to explain why matter seems "solid" at all – only the exclusion principle can explain why the electrons behave the way they do.


Question:
I'd like to take pictures of labels on a jar of food, and be able to transform them so the label is flat, with the right and left side resized to be even with the center of the image.
Ideally, I'd like to use the contrast between the label and the background in order to find the edges and apply the correction.  Otherwise, I can ask the user to somehow identify the corners and sides of the image.

I'm looking for general techniques and algorithms to take an image that is skewed spherically (cylindrically in my case) and can flatten the image.  Currently the image of a label that is wrapped around a jar or bottle, will have features and text that shrinks as it recedes to the right or left of the image.  Also the lines that denote the edge of the label, will only be parallel in the center of the image, and will skew towards each-other on the right and left extreme of the label.
After manipulating the image, I would like to be left with an almost perfect rectangle where the text and features are uniformly sized, as if I took a picture of the label when it was not on the jar or bottle.
Also, I would like it if the technique could automatically detect the edges of the label, in order to apply the suitable correction.  Otherwise I would have to ask my user to indicate the label boundaries.
I've already Googled and found articles like this one:  flattening curved documents, but I am looking for something a bit simpler, as my needs are for labels with a simple curve.

A similar question was asked on Mathematica.Stackexchange. My answer over there evolved and got quite long in the end, so I'll summarize the algorithm here.
Abstract
The basic idea is:

Find the label.
Find the borders of the label
Find a mapping that maps image coordinates to cylinder coordinates so that it maps the pixels along the top border of the label to ([anything] / 0), the pixels along the right border to (1 / [anything]) and so on.
Transform the image using this mapping

The algorithm only works for images where:

the label is brighter than the background (this is needed for the label detection)
the label is rectangular (this is used to measure the quality of a mapping)
the jar is (almost) vertical (this is used to keep the mapping function simple)
the jar is cylindrical (this is used to keep the mapping function simple)

However, the algorithm is modular. At least in principle, you could write your own label detection that does not require a dark background, or you could write your own quality measurement function that can cope with elliptical or octagonal labels.
Results
These images were processed fully automatically, i.e. the algorithm takes the source image, works for a few seconds, then shows the mapping (left) and the un-distorted image (right):

The next images were processed with a modified version of the algorithm, were the user selects the left and right borders of the jar (not the label), because the curvature of the label cannot be estimated from the image in a frontal shot (i.e. the fully automatic algorithm would return images that are slightly distorted):

Implementation:
1. Find the label
The label is bright in front of a dark background, so I can find it easily using binarization:
src = Import["
binary = FillingTransform[DeleteBorderComponents[Binarize[src]]]

I simply pick the largest connected component and assume that's the label:
labelMask = Image[SortBy[ComponentMeasurements[binary, {"Area", "Mask"}][[All, 2]], First][[-1, 2]]]

2. Find the borders of the label
Next step: find the top/bottom/left/right borders using simple derivative convolution masks:
topBorder = DeleteSmallComponents[ImageConvolve[labelMask, {{1}, {-1}}]];
bottomBorder = DeleteSmallComponents[ImageConvolve[labelMask, {{-1}, {1}}]];
leftBorder = DeleteSmallComponents[ImageConvolve[labelMask, {{1, -1}}]];
rightBorder = DeleteSmallComponents[ImageConvolve[labelMask, {{-1, 1}}]];

This is a little helper function that finds all white pixels in one of these four images and converts the indices to coordinates (Position returns indices, and indices are 1-based {y,x}-tuples, where y=1 is at the top of the image. But all the image processing functions expect coordinates, which are 0-based {x,y}-tuples, where y=0 is the bottom of the image):
{w, h} = ImageDimensions[topBorder];
maskToPoints = Function[mask, {#[[2]]-1, h - #[[1]]+1} & /@ Position[ImageData[mask], 1.]];

3. Find a mapping from image to cylinder coordinates
Now I have four separate lists of coordinates of the top, bottom, left, right borders of the label. I define a mapping from image coordinates to cylinder coordinates:
arcSinSeries = Normal[Series[ArcSin[\[Alpha]], {\[Alpha], 0, 10}]]
Clear[mapping];
mapping[{x_, y_}] :=
   {
    c1 + c2*(arcSinSeries /. \[Alpha] -> (x - cx)/r) + c3*y + c4*x*y,
    top + y*height + tilt1*Sqrt[Clip[r^2 - (x - cx)^2, {0.01, \[Infinity]}]] + tilt2*y*Sqrt[Clip[r^2 - (x - cx)^2, {0.01, \[Infinity]}]]
   }

This is a cylindrical mapping, that maps X/Y-coordinates in the source image to cylindrical coordinates. The mapping has 10 degrees of freedom for height/radius/center/perspective/tilt. I used the Taylor series to approximate the arc sine, because I couldn't get the optimization working with ArcSin directly. The Clip calls are my ad-hoc attempt to prevent complex numbers during the optimization. There's a trade-off here: On the one hand, the function should be as close to an exact cylindrical mapping as possible, to give the lowest possible distortion. On the other hand, if it's to complicated, it gets much harder to find optimal values for the degrees of freedom automatically. (The nice thing about doing image processing with Mathematica is that you can play around with mathematical models like this very easily, introduce additional terms for different distortions and use the same optimization functions to get final results. I've never been able to do anything like that using OpenCV or Matlab. But I never tried the symbolic toolbox for Matlab, maybe that makes it more useful.)
Next I define an "error function" that measures the quality of a image -> cylinder coordinate mapping. It's just the sum of squared errors for the border pixels:
errorFunction =
  Flatten[{
    (mapping[#][[1]])^2 & /@ maskToPoints[leftBorder],
    (mapping[#][[1]] - 1)^2 & /@ maskToPoints[rightBorder],
    (mapping[#][[2]] - 1)^2 & /@ maskToPoints[topBorder],
    (mapping[#][[2]])^2 & /@ maskToPoints[bottomBorder]
    }];

This error function measures the "quality" of a mapping: It's lowest if the points on the left border are mapped to (0 / [anything]), pixels on the top border are mapped to ([anything] / 0) and so on.
Now I can tell Mathematica to find coefficients that minimize this error function. I can make "educated guesses" about some of the coefficients (e.g. the radius and center of the jar in the image). I use these as starting points of the optimization:
leftMean = Mean[maskToPoints[leftBorder]][[1]];
rightMean = Mean[maskToPoints[rightBorder]][[1]];
topMean = Mean[maskToPoints[topBorder]][[2]];
bottomMean = Mean[maskToPoints[bottomBorder]][[2]];
solution =
 FindMinimum[
   Total[errorFunction],
    {{c1, 0}, {c2, rightMean - leftMean}, {c3, 0}, {c4, 0},
     {cx, (leftMean + rightMean)/2},
     {top, topMean},
     {r, rightMean - leftMean},
     {height, bottomMean - topMean},
     {tilt1, 0}, {tilt2, 0}}][[2]]

FindMinimum finds values for the 10 degrees of freedom of my mapping function that minimize the error function. Combine the generic mapping and this solution and I get a mapping from X/Y image coordinates, that fits the label area. I can visualize this mapping using Mathematica's ContourPlot function:
Show[src,
 ContourPlot[mapping[{x, y}][[1]] /. solution, {x, 0, w}, {y, 0, h},
  ContourShading -> None, ContourStyle -> Red,
  Contours -> Range[0, 1, 0.1],
  RegionFunction -> Function[{x, y}, 0 <= (mapping[{x, y}][[2]] /. solution) <= 1]],
 ContourPlot[mapping[{x, y}][[2]] /. solution, {x, 0, w}, {y, 0, h},
  ContourShading -> None, ContourStyle -> Red,
  Contours -> Range[0, 1, 0.2],
  RegionFunction -> Function[{x, y}, 0 <= (mapping[{x, y}][[1]] /. solution) <= 1]]]

4. Transform the image
Finally, I use Mathematica's ImageForwardTransform function to distort the image according to this mapping:
ImageForwardTransformation[src, mapping[#] /. solution &, {400, 300}, DataRange -> Full, PlotRange -> {{0, 1}, {0, 1}}]

That gives the results as shown above.
Manually assisted version
The algorithm above is full-automatic. No adjustments required. It works reasonably well as long as the picture is taken from above or below. But if it's a frontal shot, the radius of the jar can not be estimated from the shape of the label. In these cases, I get much better results if I let the user enter the left/right borders of the jar manually, and set the corresponding degrees of freedom in the mapping explicitly.
This code lets the user select the left/right borders:
LocatorPane[Dynamic[{{xLeft, y1}, {xRight, y2}}],
 Dynamic[Show[src,
   Graphics[{Red, Line[{{xLeft, 0}, {xLeft, h}}],
     Line[{{xRight, 0}, {xRight, h}}]}]]]]

This is the alternative optimization code, where the center&radius are given explicitly.
manualAdjustments = {cx -> (xLeft + xRight)/2, r -> (xRight - xLeft)/2};
solution =
  FindMinimum[
   Total[minimize /. manualAdjustments],
    {{c1, 0}, {c2, rightMean - leftMean}, {c3, 0}, {c4, 0},
     {top, topMean},
     {height, bottomMean - topMean},
     {tilt1, 0}, {tilt2, 0}}][[2]]
solution = Join[solution, manualAdjustments]


Question:
The Kalman filter algorithm works as follows

Initialize $ \hat{\textbf{x}}_{0|0}$ and $\textbf{P}_{0|0}$.
At each iteration $k=1,\dots,n$
Predict
Predicted (a priori) state estimate    $$ \hat{\textbf{x}}_{k|k-1} =
 \textbf{F}_{k}\hat{\textbf{x}}_{k-1|k-1} + \textbf{B}_{k}
 \textbf{u}_{k} $$
    Predicted (a priori) estimate covariance $$
 \textbf{P}_{k|k-1} = \textbf{F}_{k} \textbf{P}_{k-1|k-1}
 \textbf{F}_{k}^{\text{T}} + \textbf{Q}_{k}$$
  Update
Innovation or measurement residual     $$ \tilde{\textbf{y}}_k =
 \textbf{z}_k - \textbf{H}_k\hat{\textbf{x}}_{k|k-1}$$ Innovation (or
  residual) covariance   $$\textbf{S}_k = \textbf{H}_k
 \textbf{P}_{k|k-1} \textbf{H}_k^\text{T} + \textbf{R}_k$$ Optimal
  Kalman gain      $$\textbf{K}_k =
 \textbf{P}_{k|k-1}\textbf{H}_k^\text{T}\textbf{S}_k^{-1}$$
    Updated (a posteriori) state estimate      $$\hat{\textbf{x}}_{k|k} =
 \hat{\textbf{x}}_{k|k-1} + \textbf{K}_k\tilde{\textbf{y}}_k$$
    Updated (a posteriori) estimate covariance     $$\textbf{P}_{k|k} = (I -
 \textbf{K}_k \textbf{H}_k) \textbf{P}_{k|k-1}$$

The Kalman gain $K_k$ represents the relative importance of the error $\tilde{\textbf{y}}_k$ with respect to the prior estimate $\hat{\textbf{x}}_{k|k-1}$.
I wonder how to understand the formula for the Kalman gain $K_k$ intuitively? Consider the case when the states and outputs being scalar, why is the gain bigger, when

$\textbf{P}_{k|k-1}$ is bigger
$\textbf{H}_k$ is bigger
$\textbf{S}_k$ is smaller?

Thanks and regards!

I found a good way of thinking intuitively of Kalman Gain $K$. If you write $K$ this way
$\displaystyle \quad\ \bf{K_k} = \bf{P_k^-\, H_k^{\rm T} (H_k P_k^-\, H_k^{\rm T} + R_k)^{-1}}
  = \bf{\frac {P_k^-\, H_k^{\rm T}}{H_k P_k^-\, H_k^{\rm T} + R_k}}$
you will realize that the relative magnitudes of matrices ($R_k$) and ($P_k$) control a relation between the filter's use of predicted state estimate ($x_{k}⁻$) and measurement ($ỹ_k$).
$\displaystyle \quad\
  \lim\limits_{\bf{R_k \to 0}} \bf{{P_k^-\, H_k^{\rm T}} \over\
  {H_k P_k^-\, H_k^{\rm T} + R_k}}\
    = \bf{H_k^{-1}}$
$\displaystyle \quad\
  \lim\limits_{\bf{P_k \to 0}} \bf{{P_k^-\, H_k^{\rm T}} \over\
  {H_k P_k^-\, H_k^{\rm T} + R_k}}\
   = \bf 0$
Substituting the first limit into the measurement update equation
$\displaystyle \quad\
  \bf{\hat x_k} = \bf{x_k^-} + \bf{K_k}(\bf{\tilde y_k}-\bf{H_k}\bf{x_k^-})$
suggests that when the magnitude of $R$ is small, meaning that the measurements are accurate, the state estimate depends mostly on the measurements.
When the state is known accurately, then $H P^⁻ H^T$ is small compared to $R$, and the filter mostly ignores the measurements relying instead on the prediction derived from the previous state ($x_k⁻$).


Question:
What is the extra, 5th, pin on micro usb 2.0 adapters for?

Here is an image with the different connectors.  Most of them have 5 pins, but the A-type host only has four.

(source: wikimedia.org)

It's for On-The-Go, to select which device is the host or slave:

The OTG cable has a micro-A plug on one side, and a micro-B plug on
  the other (it cannot have two plugs of the same type). OTG adds a
  fifth pin to the standard USB connector, called the ID-pin; the
  micro-A plug has the ID pin grounded, while the ID in the micro-B plug
  is floating. The device that has a micro-A plugged in becomes an OTG
  A-device, and the one that has micro-B plugged becomes a B-device. The
  type of the plug inserted is detected by the state of the pin ID .


Question: I have found that many USB wall chargers use a resistive voltage divider to set the D+ and D- pins to a specific voltage, usually between 2 and 3 volts.  Other USB wall chargers short the D+ and D- pins together with no connection to anything else.  From my experience some devices will not accept a charge rate above 500mA on the chargers using the voltage dividers, but will charge up to their max input on a charger with the data pins shorted. I have read things that suggest the opposite may be true as well, but have been unable to verify this. I am hoping to figure out which method provides the best compatibility with all USB devices.

I found this page answers your question clearly. I quote the relevant parts below.

The BC1.2 outlines three distinct types of USB port and two key monikers. A "charging" port is one that delivers currents higher than 500mA. A "downstream" port signals data as per USB 2.0. The BC1.2 specification also establishes both how each port should appear to the end device, and the protocol to identify what type of port is implemented. The three USB BC1.2 port types are SDP, DCP, and CDP (see Figure 1):

Standard Downstream Port (SDP) This port features 15kΩ pulldown resistors on both the D+ and D- lines. The current limits are those discussed above: 2.5mA when suspended, 100mA when connected, and 500mA when connected and configured for higher power.
Dedicated Charging Port (DCP) This port does not support any data transfer, but is capable of supplying charge currents beyond 1.5A. It features a short between the D+ and D- lines. This type of port allows for wall chargers and car chargers with high-charge capability without the need for enumeration.
Downstream Port (CDP) This port allows for both high-current charging and data transfer fully compliant with USB 2.0. It features the 15kΩ pulldown resistors necessary for the D+ and D- communication, and also has internal circuitry that is switched in during the charger detection phase. This internal circuitry allows the portable device to distinguish a CDP from other port types.

Even with the BC1.2 specification available, some electronics manufacturers develop custom protocols for their dedicated chargers. When you attach one of their devices to a fully compliant BC1.2 charging port, you may still get the error message, "Charging is not supported with this accessory." Despite this message, these devices may still charge, but the charge currents can be extremely small. Fortunately, almost all of these proprietary dedicated chargers identify themselves by a DC level set on the D+ and D- lines by a resistor-divider between 5V and ground

Added Comment:
One might consider data signal levels are 0.0–0.3 V for logical low, and 2.8–3.6 V for logical high. Without a voltage dividing network to two shorted data pins, the voltage on them is free to float. Even though twisted data wires providing some shielding from stray electromagnetic signals, they can still potentially induce unpredictable voltages on the line. On the other hand, a voltage dividing network clamps the voltage at a safe 2.5v.

For more details, check out the Page I sourced or take a look at USB.org's PDF describing the USB Battery Charging BC 1.2 specification


Question:
The 3.0 version of the MPI standard formally deleted the C++ interface (it was previously deprecated).  While implementations may still support it, features that are new in MPI-3 do not have a C++ interface defined in the MPI standard.  See  for more information.
The motivation for removing the C++ interface from MPI was that it had no significant value over the C interface.  There were very few differences other than "s/_/::/g" and many features that C++ users are accustomed to were not employed (e.g. automatic type determination via templates).
As someone who participates in the MPI Forum and works with a number of C++ projects that have implemented their own C++ interface to the MPI C functions, I would like to know what are the desirable features of a C++ interface to MPI.  While I commit to nothing, I would be interested in seeing the implementation of a standalone MPI C++ interface that meets the needs of many users.
And yes, I am familiar with Boost::MPI ( but it only supports MPI-1 features and the serialization model would be extremely difficult to support for RMA.
One C++ interface to MPI that I like is that of Elemental ( so perhaps people can provide some pro and con w.r.t. that approach.  In particular, I think MpiMap solves an essential problem.
Edit
In response to constructive feedback that this is not appropriate for StackExchange, please move this discussion to MPI Forum issues on GitHub.

Let me first answer why I think C++ interfaces to MPI have generally not been overly successful, having thought about the issue for a good long time when trying to decide whether we should just use the standard C bindings of MPI or building on something at higher level:
When you look at real-world MPI codes (say, PETSc, or in my case deal.II), one finds that maybe surprisingly, the number of MPI calls isn't actually very large. For example, in the 500k lines of deal.II, there are only ~100 MPI calls. A consequence of this is that the pain involved in using lower-level interfaces such as the MPI C bindings, is not too large. Conversely, one would not gain all that much by using higher level interfaces.
My second observation is that many systems have multiple MPI libraries installed (different MPI implementations, or different versions). This poses a significant difficulty if you wanted to use, say, boost::mpi that don't just consist of header files: either there needs to be multiple installations of this package as well, or one needs to build it as part of the project that uses boost::mpi (but that's a problem in itself again, given that boost uses its own build system, which is unlike anything else).
So I think all of this has conspired against the current crop of C++ interfaces to MPI: The old MPI C++ bindings didn't offer any advantage, and external packages had difficulties with the real world.
This all said, here's what I think would be the killer features I would like to have from a higher-level interface:

It should be generic. Having to specify the data type of a variable is decidedly not C++-like. Of course, it also leads to errors. Elemental's MpiMap class would already be a nice first step (though I can't figure out why the heck the MpiMap::type variable isn't static const, so that it can be accessed without creating an object).
It should have facilities for streaming arbitrary data types.
Operations that require an MPI_Op argument (e.g., reductions) should integrate nicely with C++'s std::function interface, so that it's easy to just pass a function pointer (or a lambda!) rather than having to clumsily register something.

boost::mpi actually satisfies all of these. I think if it were a header-only library, it'd be a lot more popular in practice. It would also help if it supported post-MPI 1.0 functions, but let's be honest: this covers most of what we need most of the time.


Question: I see the HSV colour space used all over the place: for tracking, human detection, etc...  I'm wondering, why?  What is it about this colour space that makes it better than using RGB?

The simple answer is that unlike RGB, HSV separates luma, or the image intensity, from chroma or the color information.  This is very useful in many applications.  For example, if you want to do histogram equalization of a color image, you probably want to do that only on the intensity component, and leave the color components alone.  Otherwise you will get very strange colors.
In computer vision you often want to separate color components from intensity for various reasons, such as robustness to lighting changes, or removing shadows.
Note, however, that HSV is one of many color spaces that separate color from intensity (See YCbCr, Lab, etc.).  HSV is often used simply because the code for converting between RGB and HSV is widely available and can also be easily implemented.  For example, the Image Processing Toolbox for MATLAB includes functions rgb2hsv and hsv2rgb.


Question: What's the state-of-the-art in the approximation of highly oscillatory integrals in both one dimension and higher dimensions to arbitrary precision?

I'm not entirely familiar with what's now done for cubatures (multidimensional integration), so I'll restrict myself to quadrature formulae.
There are a number of effective methods for the quadrature of oscillatory integrals. There are methods suited for finite oscillatory integrals, and there are methods for infinite oscillatory integrals.
For infinite oscillatory integrals, two of the more effective methods used are Longman's method and the modified double exponential quadrature due to Ooura and Mori. (But see also these two papers by Arieh Iserles.)
Longman's method relies on converting the oscillatory integral into an alternating series by splitting the integration interval, and then summing the alternating series with a sequence transformation method. For instance, when integrating an oscillatory integral of the form
$$\int_0^\infty f(t)\sin\,t\mathrm dt$$
one converts this into the alternating sum
$$\sum_{k=0}^\infty \int_{k\pi}^{(k+1)\pi} f(t)\sin\,t\mathrm dt$$
The terms of this alternating sum are computed with some quadrature method like Romberg's scheme or Gaussian quadrature. Longman's original method used the Euler transformation, but modern implementations replace Euler with more powerful convergence acceleration methods like the Shanks transformation or the Levin transformation.
The double exponential quadrature method, on the other hand, makes a clever change of variables, and then uses the trapezoidal rule to numerically evaluate the transformed integral.
For finite oscillatory integrals, Piessens (one of the contributors of QUADPACK) and Branders, in two papers, detail a modification of Clenshaw-Curtis quadrature (that is, constructing an Chebyshev polynomial expansion of the nonoscillatory part of the integrand). Levin's method, on the other hand, uses a collocation method for the quadrature. (I am told there is now a more practical version of the old standby, Filon's method, but I've no experience with it.)

These are the methods I remember offhand; I'm sure I've forgotten other good methods for oscillatory integrals. I will edit this answer later if I remember them.