sums of rational squares

Question: It is a well-known fact that if an integer is a sum of two rational squares then it is a sum of two integer squares.  For example, Cohen vol. 1 page 314 prop. 5.4.9.   Cohen gives a short proof that relies on Hasse-Minkowski, but he attributes the theorem (without reference) to Fermat, who didn't have Hasse-Minkowski available.   So my question is,  how did Fermat prove this theorem?  and part 2 of the question is,  what is the simplest direct proof?   I googled for this result and found a manuscript with a proof that doesn't use Hasse-Minkowski, but it's not very short.
Answer: In his early days, Fermat realized that a natural number that can
be written as a sum of two rational squares actually is a sum of
two integral squares, but he did not come back to this claim
when eventually he discovered the proof of the Two-Squares
Theorem. The result in question can be proved with the methods
available to Fermat, as I will show here.
Theorem 1 If $n$ is a sum of two rational squares, then
every prime $q = 4n+3$ divides $n$ an even number of times.
Theorem 2 Every prime number $p = 4n+1$ is the sum of two
integral squares.
Now we invoke the product formula for sums of two squares
$$ (a^2 + b^2)(c^2 + d^2) = (ac-bd)^2 + (ad+bc)^2. $$
It implies that every product of prime numbers $4n+1$ and some
power of $2$ can be written as a sum of two integral squares,
and multiplying through by squares of primes $q = 4n+3$, the
claim follows.
Proof of Theorem 1
We will show that primes $p = 4n+3$ do not divide a sum of two
coprime squares.
Assume that $p \mid x^2 + y^2$  with $\gcd(x,y) = 1$.
Reducing $x$ and $y$ modulo $p$ we may assume that
$-p/2 < x, y < p/2$; cancelling possible common divisors
we then have $p \mid x^2 + y^2$ with $\gcd(x,y) = 1$ and
$x^2 + y^2 < \frac12 p^2$.
If $x$ and $y$ are both odd, then the identity
$$ \Big(\frac{x+y}2\Big)^2 + \Big(\frac{x-y}2\Big)^2 = \frac{x^2+y^2}2 $$
allows us to remove any remaining factor of $2$ from the sum, and we
may therefore assume that $a^2 + b^2 = pr$ for some odd number $r < p$.
Since $a$ and $b$ then have different parity, $a^2 + b^2$ must have the
form $4n+1$, and therefore the number $r$ must have the form $4n+2$.
But then $r$ must have at least one prime factor $q \equiv 3 \bmod 4$,
and since $a^2 + b^2 < p^2$, we must have $q \le r < p$.
Thus if $p \equiv 3 \bmod 4$ divides a sum of two coprime squares,
then there must be some prime $q \equiv 3 \bmod 4$ less than $p$ with the
same property. Applying descent we get a contradiction.
Proof of Theorem 2

The prime $p$ divides a sum of two squares.
For every prime $p = 4n+1$ there is an integer $x$ such that
$p$ divides $x^2+1$.
By Fermat's Theorem, the prime $p$ divides
  $$ a^{p-1}-1 = a^{4n}-1 = (a^{2n}-1)(a^{2n}+1). $$
If we can show that there is an integer $a$ for which $p$
does not divide the first factor we are done, because
then $p \mid (a^n)^2+1$. By Euler's criterion it is sufficient
to choose $a$ as a quadratic nonresidue modulo $p$. Equivalently
we may observe that the polynomial $x^{2n}-1$ has at most $2n$
roots modulo $p$.
The descent. The basic idea is the following: Assume that the prime number
  $p = 4n+1$ is not a sum of two squares. Let $x$ be an integer
  such that $p \mid x^2 + 1$. Reducing $x$ modulo $p$ shows that
  we may assume that $p \mid x^2+1$ for some even integer $x$ with
  $0 < x < p$. This implies that $x^2+1 = pm$ for some integer
  $m < p$. Fermat then shows that there must be som prime divisor
  $q$ of $m$ such that $q$ is not a sum of two squares; since
  prime divisors of sums of two coprime squares have the form
  $4n+1$, Fermat now has found a prime number $q = 4n+1$ strictly
  less than $p$ that is not a sum of two squares. Repeating this
  step eventually shows that $p = 5$ is not a sum of two squares,
  which is nonsense since $5 = 1^2 + 5^2$.
Assume that $p = 4n+1$ is not a sum of two squares.
  We know that $pm = x^2 + 1$ is a sum of two squares for some
  odd integer $m < p$. By Theorem 1, $m$ is only divisible
  by primes of the form $4k+1$. We now use the following

Lemma Assume that $pm = x^2 + y^2$ for coprime integers $x, y$,
and let $q$ be a prime dividing $m$, say $m = qm_1$. If $q = a^2 + b^2$
is a sum of two squares, then $pm_1 = x_1^2 + y_1^2$ is also a sum of two
squares.
Applying this lemma repeatedly we find that if every $q \mid m$ is a
     sum of two squares, then so is $p$ in contradiction to our assumption.
     Thus there is a prime $q = 4k+1$, strictly smaller than $p$, which is
     not a sum of two squares, and now descent takes over.
It remains to prove the Lemma. To this end, we have to perform
    the division $\frac{x^2+y^2}{a^2+b^2}$. By the product formula
    $$ (a^2+b^2)(c^2+d^2) = (ac-bd)^2 + (bc+ad)^2 $$
    we have to find integers $c, d$ such that $x = ac-bd$ and $y = bc+ad$.
Since $q \mid (a^2 + b^2)$ and $q \mid (x^2 + y^2)$ we also have
    $$ q \mid (a^2+b^2)x^2 - (x^2+y^2)b^2
      = a^2x^2 - b^2y^2 = (ax-by)(ax+by). $$
Since $q$ is prime, it must divide one of the factors. Replacing $b$
    by $-b$ if necessary we may assume that $q$ divides $ax-by$. We know
    that $q$ divides $a^2 + b^2$ as well as $pm = x^2 + y^2$, hence $q^2$
    divides $(ax - by)^2 + (ay+bx)^2 $ by the product formula. Since $q$
    divides the first summand, it must divide the second as well, and we
    have $pm_1 = (\frac{ax-by}q)^2 + (\frac{ay+bx}q)^2$.
Answer: This result is pretty shy of needing the full Hasse-Minkowski Theorem.  Indeed, since Fermat already knew which integers were a sum of two integer squares, it would suffice for him to show that those that weren't (i.e., those with an odd power of some prime congruent to 3 mod 4 showing up in its prime factorization) could also not be written as a sum of two rational squares.  But this is the easy direction of Hasse-Minkowski:  To show that (let's say) a prime $p\equiv 3\pmod{4}$ can't be written as a sum of two rational squares, it suffices to check that it can't be a sum of two $\ell$-adic rational squares for some $\ell$.  Of course, Fermat did not have the language of the $\ell$-adics, so this would have had been replaced with mod-$q^k$ conditions for various $k$.
Specifically, the modern Hasse-Minkowski proof boils down to the statement that a prime which is 3 mod 4 can't be written as a sum of two rational squares because it can't be done so 2-adically.  Indeed, one can just compute the single Hilbert symbol
$$
p\equiv 3\pmod{4}\Rightarrow (p,-1)_2=(-1)^{(p-1)/2}=-1,
$$
showing that $x^2=pz^2-y^2$ has no $2$-adic, and hence no rational, solutions, which afte the substitutions $a=x/z$ and $b=y/z$, implies one cannot write $p=a^2+b^2$ with $a,b\in\mathbb{Q}$.  Of course (again), Fermat did not have Hilbert symbols, but this is just a change of language away from Fermat's approach (I imagine).  It would not be hard to unwind the above calculation into a single (probably lengthy) mod-8 calculation, since that's all that goes into deciding which elements of $\mathbb{Q}_2$ are squares, which in turn is essentially all that lives behind the Hilbert symbols.
Comment: Can't one just say that if a=(b/c)^2+(d/e)^2, then ac^2e^2=(be)^2+(cd)^2? So this reduces to the statement that if a number can't be written as the sum of two integer squares, then that number times a square can't be written as the sum of two integer squares. But this is obvious given the theorem on which numbers are the sum of two integer squares.
Comment: Ah, the ol' "clearing the denominator trick."  Great!
Comment: The fact that $p \equiv 3 \pmod{4}$ can't be written as a sum of two rational squares can also be proved $p$-adically : if $p d^2 = a^2+b^2$ then $-1$ would be a square mod $p$, which is impossible. In modern language the equation $p=x^2+y^2$ has obstruction precisely at $2$ and at $p$.
Answer: Dear Michael,
concerning your first question, I think that Franz's proof is really in the spirit of Fermat's techniques. Concerning the second question, here is a short, elementary proof, inspired by a  theorem of Thue (cf. exercice 1.2 in Franz's book Reciprocity laws). I tried to write it using only notions known to Fermat.
We want to prove that if there exist positive integers $m,n,a$ and $b$ such that
$$m^2n=a^2+b^2,$$
then $n$ is itself the sum of two integer squares. It is easily seen that it is sufficient to prove this assertion under the hypothesis that $a$ and $b$ (and therefore $a$ and $n$) are coprime and that $n$ is not a square. Let $t$ be the unique positive integer such that $t^2< n<(t+1)^2$. Since there are $(t+1)^2>n$ integers of the form $au+bv$ with $0\leq u,v\leq t$, it follows that $n$ divides the difference $a(u-u')+b(v-v')$ of two of them. Setting $x=u-u'$ and $y=v-v'$, we have the inequalities $|x|,|y|\leq t$. The integer $n$ then divides $a^2x^2-b^2y^2$; since it also divides $a^2y^2+b^2y^2$, it divides their sum, which is equal to $a^2(x^2+y^2)$. Now, the integers $a$ and $n$ being coprime, it follows that $n$ divides $x^2+y^2$. The inequalities $0< x^2+y^2<2n$ finally imply that $n=x^2+y^2$.
Answer: EDIT: there is an elementary trick to do this due to Aubry, it is Theorem 4 on page 5 of PETE.
The positive primitive binary forms which give the easy Aubry trick showing rational implies integral are:
$$ x^2 + y^2, x^2 + 2 y^2, x^2 + 3 y^2, x^2 + 5 y^2, $$
$$ x^2 + x y + y^2,  x^2 + x y + 2 y^2,  x^2 + x y + 3 y^2,   $$ $$  2 x^2 + 3  y^2, 2 x^2 + x y +2 y^2,  2 x^2 + 2 x y + 3 y^2.         $$ Note that these are all "ambiguous," that is, equivalent to their "opposites." This is not an accident.
Probably needs mention, for the property mentioned by the OP there is no difference between the sum of two squares and the sum of three squares...
Right, I don't know about Fermat, but this phenomenon happens often enough. The first mention on MO is Intuition for the last step in Serre's proof of the three-squares theorem
and the technique, due to Aubry, Cassels, and Davenport, is mentioned in Serre A Course in Arithmetic, pages 45-47, and Weil Number Theory: An approach through history from Hammurapi to Legendre, pages 59 and 292ff in which Fermat's possible thinking is discussed.
About my use of the word "phenomenon," it is necessary for the Aubry-Cassels-Davenport trick to work that we have Pete's "Euclidean" condition, Must a ring which admits a Euclidean quadratic form be Euclidean? which is usually, for positive quadratic forms, referred to as a bound on the "covering radius" of the integral lattice under consideration. It took me a year or so to prove that Pete's condition implied that there could only be one class in that genus, A Priori proof that Covering Radius strictly less than $\sqrt 2$ implies class number one
A complete list of positive forms that satisfy Pete's condition is at NEBE. A mild generalization of the condition, due to Richard Borcherds and his student, Daniel Allcock, applies to such forms as the sum of five squares.
Answer: This is an easy consequence of the fact that if $p \equiv 3$ (mod 4) is a rational prime, then $p$ remains prime in the ring of Gaussian integers $\mathbb{Z}[i].$ Then it follows that if $a$ and $b$ are rational integers, the powers of $p$ dividing $a+bi$ and $a-bi$ (in $\mathbb{Z}[i]$ ) are equal. Hence if $n$ is an integer with $a^2 + b^2 = c^2 n$ for integers $a,b$ and $c,$ then the power of $p$ dividing $n$ is even. The fact that $p$ remains prime in $\mathbb{Z}[i]$ was (at least implicitly) known to Fermat. For if $p = (r +si)(t+ui)$ for integers $r,s,t$ and $u,$ then $p^2 = (r^2 +s^2)(t^2 + u^2).$ We can't have $p = r^2 + s^2$ since a sum of two integer squares is congruent to $0,1$ or $2$ (mod 4). Hence we must conclude that one of $r + si$ or $t +ui$ is a unit in $\mathbb{Z}[i]$, so $p$ does remain prime in $\mathbb{Z}[i].$
Answer: This is an answer to the second question, "what is the simplest direct proof?"
Let m be an integer satisfyng $\frac{a^{2}}{b^{2}}+\frac{c^{2}}{d^{2}}=m$. $a,b,c,d \in \mathbb{Z}$, gcd(a,b)=1, gcd(c,d)=1.
$\frac{a^{2}d^{2}+b^{2}c^{2}}{b^{2}d^{2}}=m$
$a^{2}d^{2}+b^{2}c^{2}=mb^{2}d^{2}$
$b^{2}(md^{2}-c^{2})=a^{2}d^{2}$.
As our assumtion $b^{2} \not | a^{2}$ so $b^{2} | d^{2}$, $d^{2}=kb^{2}$. Then $\frac{1}{b^{2}}(a^{2}+\frac{c^{2}}{k})=m$.
$\frac{c^{2}}{k}=mb^{2}-a^{2}$ which is an integer. Thus we have $k=1$ as gcd(c,d)=1.
We have $\frac{a^{2}}{b^{2}}+\frac{c^{2}}{b^{2}}=m$, $a^{2}+c^{2}=mb^{2}={p_{1}}^{\alpha_{1}}...{p_{k}^{\alpha_{k}}}$ [Unique prime factorization].
If $a^{2}+c^{2}=wp$, p is prime and gcd(w,p)=1, then we can find integers x, y such that $x^{2}+y^{2}=p$.
Thus for every $p_{1}$, $p_{2}$,...,$p_{k}$, we can find $a_{1}, a_{2},...,a_{k}$ and $c_{1}, c_{2},...,c_{k}$ such that
${a_{1}}^{2}+{c_{1}}^{2}=p_{1}$
${a_{2}}^{2}+{c_{2}}^{2}=p_{2}$
$\vdots$
${a_{k}}^{2}+{c_{k}}^{2}=p_{k}$
Now if $m=p_{1}p_{2}$, ${a_{1}}^{2}+{c_{1}}^{2}=p_{1}$, ${a_{2}}^{2}+{c_{2}}^{2}=p_{2}$.
$({a_{1}}^{2}+{c_{1}}^{2})({a_{2}}^{2}+{c_{2}}^{2})$ = ${(a_{1}a_{2}+c_{1}c_{2})}^{2}+ {(a_{1}c_{2}-c_{1}a_{2})}^{2}=m$.
We can continue in this way to show the claim if $m=p_{1}p_{2}...p_{k}$.
Comment: Welcome to MathOverflow. I've edited your post to make clear the question you are answering. You may want to make clear that $gcd(w, p) = 1$ (as otherwise, $3^2 + 0 = 3*3$ is a counterexample to your statement). I'm not sure I understand your proof that $k = 1$; isn't it enough to show that $b^2 | d^2$ and $d^2 | b^2$? Further, you need that $gcd(a^2, b^2) = 1$ to show $b^2 | d^2$.
Comment: Thank you very much for pointing out gcd(w,p)=1. From gcd(c,d)=1, gcd(c^{2},d^{2)=1. Thus, we can say k does not divide $c^{2}$ as $d^{2}=kb^{2}$. Then k=1 as it must give integer in the right-hand side. But your method is much better.

sums of rational squares


Block that shows nodes based on node type

Question: I want to create a module that displays nodes of a certain node type. Can this be done, and can anyone point me to a place where I can find how to do this?
Answer: There's currently 12,966 sites using the beta3 release of Views 7 (http://drupal.org/project/usage/views). I'd suggest that you install the module and try to produce what you're describing as I suspect it will work fine. A beta3 release suggests that the module is nearing a production release with no new functionality being added.
Be brave, adopt the new software rather than painting yourself in a corner by writing your own custom code.
Answer: First thing you should be looking into is module development in general. Everyone has their own way of researching such things, it could be a book such as "Pro Drupal Development" or a online video series such as http://buildamodule.com/
Are you looking to build the module for Drupal 6 / 7 etc all needs to be taken into consideration too.
To answer your question yes, I would imagine creating a block module to display certain node types be fairly easy. However you might be able to do this with views much easier... Just create a new view, filter by node type and add a block display.
Comment: Thank you for your response. I have ordered the book "Drupal 7 Module Development" and will check out the online video series.

The Views module is only in beta for Drupal 7, so this is not an option right now. Of course, when my module is done, Views is probably out of beta a long time ago. I understand I will have to consider the possibilities. Thanks again for your response.
Comment: No worries, as @DeeZone has suggested below... even though Views is in Beta it is more than likely good to use for your desired functionality. Views is also very handy for all sorts of other tasks in administrating a website. :)

If you want a really light weight site though, developing your module would be the best bet.
Comment: I will test Views, and I hope with heavy caching the server load will not be to intense.
Answer: This is very easy to do in views.module. Just create a view that filters by your desired node type, then create a 'Block' display type. The block will then show in the block admin page and you'll be able to place it on your site as appropriate.
Comment: Seems everyone is suggesting the Views module despite it being beta. I am convinced and will be testing it. Thanks :)


Looking for a book about a group of people hibernating while traveling between the stars

Question: The book I'm looking for was about a ship launched from a dying earth to colonize another planet. The story is told in flashbacks and the main character has dreams about past lives while hibernating.
Comment: Should that be a *dying* Earth? More details would help a lot. There are a lot of books that center around leaving a doomed Earth.
Answer: Possibly The Dream Millennium, James White, 1974.

John Devlin, a 26-year-old medical doctor, is the captain of a sleeper ship built to colonize planets in other solar systems. The spacecraft's trajectory is such that it will make passes of eleven[3] stars thought to have a good chance of supporting habitable planets, over the course of about a thousand years. Most of the starship's systems are automated, so Devlin does not have to do much maintenance, but he is required to look at potential planets for colonization and solve problems as they arise. Except for being awoken at long intervals to eat, exercise, and perform his duties as captain, Devlin spends all of his time in hibernation, during which he dreams the entire lives of people and other creatures that lived and died on Earth in the past.
Answer: "I Hope I Shall Arrive Soon" is the title of a short story by Philip K. Dick with the same topic. It is also known as "Frozen Journey".

In the story, a man (Victor Kemmings) regains consciousness during a failed attempt at cryosleep on board a spaceship. The ship's artificial intelligence cannot repair the malfunction and cannot wake him, so Kemmings is doomed to remain conscious but paralyzed through the ship's entire ten-year-long journey. To maintain his sanity, the A.I. replays Kemmings's memories to him.
Comment: It's a possible match. It looks like his past memories, not past lives, but maybe the querent misremembered.
Answer: You may be thinking of Old Twentieth (2005) by Joe Haldeman. The book is set on a fleet of spaceships, making the thousand-year journey from Earth to another star system.
Most of the people on board are immortal due to medical advances, and they pass the time using a virtual-reality system called "The Time Machine", experiencing simulations of events from the 20th century. People start to die while in the simulated environment, and the man who maintains the system has to investigate.
Here are some reviews of the book. It has a page at ISFDB.


How to color object based on roughness?

Question: I'm very new to blender so apologies if this question doesn't make that much sense. Anyways I'm working with tumors and I'm trying to find a way to color them like a topographical map (the end result would look similar), with the blue being the smoother/flatter areas, and red being areas farther from the main surface. Does anyone have any ideas?
Comment: Look into the Sharpness output of the Geometry node
Comment: Could you give a closer definition of 'roughness', or 'protruding'? Possibly an example?
Comment: @RobinBetts I reworded it
Answer: One approach to this might be to use Dynamic Paint and Vertex Colors to create a proximity map between your surface, and a smoothed version of it. I imagine this will be for visualization and illustrative purposes, there's nothing calibrated about it. The method assumes quite high vertex density.

Derive a base surface, from which, heights will influence color

In this example, I used AltS to scale the original mesh down along its surface normals, and a Smooth Modifier. (The smoothed object you can see in the illustration is a copy; the one actually used is inside the original mesh. If you make your copy an instance using Alt D, the you'll be able to adjust it conveniently, while viewing its effect.)

Under the physics tab of the properties panel > Dynamic Paint, make the original mesh a Canvas, with settings as shown:

(.. you have to click the '+' next to the 'Paintmap Layer', to create a Vertex Color layer in the object)

Under the physics tab of the properties panel > Dynamic Paint, make the smoothed mesh a Brush, with settings as shown:

(You will have to tweak the 'Paint Distance' parameter, in particular, to get a good range of tones.)

Give the original mesh a material whose color is influenced by the tones in the Vertex Color layer, here left with its default name of 'dp_paintmap' (As you can see I haven't set the range of tones up perfectly, here)

and this is the sort of result:

Other options include combining this map with Sharpness as suggested by Duarte, or inverted normal Ambient Occlusion, to emphasise higher frequency (sharper) surface details, or thinner protrusions.
Answer: If you want to visualize something like surface roughness based on the mesh geometry I think there's no native way to do that in Blender.
Baking a displacement map of a high detail object to a smoothed version and exporting it, you could try image processing to calculate a representation of the local roughness. The resulting image can then be used as a texture in Blender.
As an example I used this "marshmallow" with regions of vertices randomized with different intensity.

The result ended up to look like this:

As a first step I created a rough UV map of the object followed by scaling it down and moving the UV islands a little bit apart as the baking will add some pixels of border around each island.

I duplicated the object and applied some iterations of smoothing – without reducing the poly count as I would like to reuse the UV map. The smoothed object is shown offset to the right in the screenshot, but would remain at the original position.

In Blender Render mode – which makes it easier to bake displacement maps – I create a new image with 2048×2048px, select the high detail object, shift click on the low detail version, go into edit mode and bake the displacement map in the render tab of the properties panel. Make sure to have "selected to active" checked and add a bit of margin.

I saved the image as grayscale and wrote a script for Python with numpy, scipy, matplotlib as well as scikit-image installed.
import numpy as np
import matplotlib.pyplot as plt
from skimage.morphology import disk
from scipy.ndimage import convolve

im = plt.imread('displacement_map.png')
im[im==0] = np.nan

k = disk(10)  # kernel shape is circle of radius 10px
              # should not be larger than margin of displacement_map

im = np.absolute(im - np.nanmean(im))
roughness = convolve(im, k, mode='nearest')
plt.imsave(fname='roughness_texture.png', arr=roughness)

The image roughness_texture.png that should be produced by the script can be added as a texture for the material of the object. By default, the colormap will be the purple to green viridis, but it can be changed to one of matplotlib's other color maps by requesting it in the imsave function. Alternatively, you can use a grayscale color map and use Blender's color ramp node to change the colors within Blender afterwards.
plt.imsave(fname='roughness_texture.png', arr=roughness, cmap=plt.cm.gray)
Comment: @RobinBetts `disk` is a (square) numpy array with a `1` everywhere closer than radius to the center and `0` everywhere else. Basically it generates a circular mask. By convolving an array with ones in it over the image, the result is an array with the values being the *sum* of the local (10px radius) neighborhoods of each original pixel. Normalizing the array, i.e. `disk(10) / disk(10).sum()` would result in a filter with the *mean* of the local neighborhood – which technically would be a little bit closer to the definition of the surface roughness, but I didn't look at the numbers anyway.
Comment: I'm hooked.. could you describe what the _contents_ of the disk is, that you've convolved over the height map? (I'm not  familiar with skimage.morphology, though it looks as though I'll want to be.. )
Comment: It would be great to have a convolution node in Blender.. so you could filter procedural textures..I  guess it would have to be part of the Texture system, which has always seemed a bit out of kilter to me, really belonging to the internal renderer? Which is going anyway? I don't know how it's going to evolve...

How to color object based on roughness?


If $\lim_{x \to \infty} x_n = \liminf_{n \to \infty} x_n = \limsup_{n \to \infty} x_n= -\infty$ does it exist a convergent subsequence of $x_n$?

Question: If $\lim_{x \to \infty} x_n = \liminf_{n \to \infty} x_n = \limsup_{n \to \infty} x_n= -\infty$ does it exist a convergent subsequence of $x_n$? I've learned that the limit of a convergent subsequence is called accumulation point,$\limsup$ as the greatest accumulation point and $\liminf$ as the smallest accumulation point. Then if $\limsup$ and $\liminf$ are $-\infty$ then all limits of all subsequences of  $x_n$ are between $-\infty$ and $-\infty$ i.e. any of the sequences converges. I'm not really sure if this argument is correct. Could you help me please?
Comment: If $\{x_n\}$ converges (including to the general points $\pm \infty$), then all its convergent  subsequences must converge to the same limit.
Comment: @Solitary could you please say where can I find the theorem you're using to say this? I'm reading "Elementary Analysis" of Ross and there is mentioned that this property is only applicable to convergent sequences.
Comment: I give you a simple proof in the following answer, hope it helps.
Answer: Suppose $\{x_n\}$ diverges to $+\infty$ but one subsequence $\{x_{n_k}\}$ converge to $-\infty < L < +\infty$.
Since $\lim_{n \to \infty} x_n = +\infty$, there exists $N \in \mathbb{N}$ such that
$$x_n > L + 1 \text{ for all } n > N. \tag{1}  $$
On the other hand, since $\lim_{k \to \infty} x_{n_k} = L$, there exists $K \in \mathbb{N}$ such that
$$|x_{n_k} - L| < 1 \text{ for all } k > K. \tag{2}$$
Now for any $k$ sufficiently large such that $k > K$ and $n_k > N$, by $(2)$ we have
$$x_{n_k} = L + x_{n_k} - L < L + 1,$$
which is contradict with $(1)$.
Use the similar argument, you can cover other cases.


Is it possible to calculate standard deviation from d (effect size)? How do you do it?

Question: I am doing a meta-analysis and one of the papers report d instead of SD. I do also have sample size and mean for each group, but I don't have the SD for each group.
Answer: A bit of simple algebra should suffice here.
Let $X_1$ and $X_2$ be the means which you say you have, $d$ be Cohen's $c$ and $s$ be the pooled standard deviation.
$$
d = \frac{X_1 - X_2}{s}
$$
Multiply both sides by $s$
$$
s * d = X_1 - X_2
$$
Now divide both sides by $d$
$$
s = \frac{X_1 - X_2}{d}
$$
which is the desired result.
Note that this is more complex if what they are reporting is not in fact Cohen's $d$ but the bias corrected version usually known as Hedges' $g$.


Preserving text formatting for dynamic website

Question: I am facing a problem while creating a dynamic website. I am building it for some pharma company, which have many products. The problem is, every product have different sections of description, and have to be formatted differently. I wanted to store all the product descriptions in the database, but at the same time preserve the formatting of each description. I also plan to provide an admin interface, where they could edit the product information themselves.
I could use Joomla or any other CMS for that purpose, but i wanted to know if i want to build such a system of my own,  where i could format the text in an editor and them save that thing into database and when i retrieve it, i get the same formatting. How could i do this?
Also i wanted to do this in PHP.
Thanks
-- Mohit
Answer: Just use a WYSIWYG editor like ckEditor or TinyMce. That will handle the text formatting.. then you jsut store in your database.


How to start method when a value of a global variable changes?

Question: Sorry for not having any code in my question!
I want to implement a program where i want to start gyroscope updates when the accelerometer x axis reading exceeds a certain threshold value. When gyroscope is activated i need to stop accelerometer updates as well. The way , i planed is to take accelerometer data to a global variable and then compare it with the an if condition. if it satisfies the condition i need to send the signal to start gyro update and stop accel update?
I can implement code about accel and gyro updates but the problem is i have no idea how to start gyro data n stop accel data when the value of global variable exceeds the threshold value? Please help me!
Answer: you can use getter and setter to change variable. in setter you can check any condition you want. then you just can, for example, post notification about reaching needed threshold.
<code>- (void) setNeededValue:(valueType)newValue;
{
    neededValue = newValue;

    if( neededValue > threshold )
    {
        [[NSNotificationCenter defaultCenter] postNotificationName: someConstStringAsNotificationName object: self];
    }
}
</code>
to receive notification use this code in any class you want to receive it by calling
<code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler) name:someConstStringAsNotificationName object:nil];
</code>
Comment: Thank you for ur valuable guidance! If possible can you show me the logic with a piece of code! Thank you! :)
Answer: Sounds good to me, you just need to try it out.  Pseudo:
<code>if ( globalVariable > thresholdValue ) {
    stopAccelData();
    startGyroData();
}
</code>
Comment: Smart Pseudo code bro! :) But i want to control accel updates and gyro updates using two different methods rather than using one! :)
Comment: You could also take the approach of using something like a mutex.  That way, only one process could be running at a time, and also notify other processes when it has completed.
Comment: Can u suggest me any references? :)


Passing thread priorities to thread pools

Question: I have a Java component that does some super complicated business logic, some of it parallelized and threads executing subtasks are pooled. Now each request to this component can have some priority thats is mapped in some way to thread priority. A the the beginning of execution i can assign a proper priority to executing thread. The problematic part is to pass priority to each threads executing subtasks. I know that spawning a new child thread will accomplish this because child threads inherit priority of parent threads but i would like to take advantage of thread pooling. An the question:

Is there a way to ensure that each thread in execution path has proper priority ?
How can i monitor threads priority at each stage of execution, of course i don't want to hard-code any tracing code? On thing that came into my mind is to write some tracing script in BTrace

Cheers.
Tomek
Answer: I assume you already know this, but whether JDK Thread's priority value matters or not is highly OS-specific, and may translate to "has no effect whatsoever". So are you sure it actually matters? If so, maybe edit question to mention OS that system runs on.
Also: it is not very common to even try to use thread priorities; in addition to priorities not necessarily working, it is not trivial to make good use of them even if they work. More commonly synchronization primitives are used, as well as controlling level of concurrency (number of active threads), not priorities. This because there are seldom benefits to have having more active CPU-bounds Threads than cores system has.
Comment: I know that implementation of priorities is a very OS/JVM specific think, but my component work only on windows and priorities seem to work quite well there. Also I am not building a component from scratch but only plugging priorities into existing a thing. You mentioned synchronization primitives. Could you please elaborate that  How would you use that approach to prioritize say 1000 parallel requests without starving the ones with lowest priority ?
Comment: Wrt 1k requests; depends. If they are mostly waiting for I/O, using NIO (-based solution) would make sense -- 1000 threads or more can be very inefficient model. If CPU-bound, well, IMO you should never start serving that many concurrent request but start failing early.  So what I mean is that limit number of actual threads by queuing, starting to fail early etc: threads can not solve overload situation.

But if you feel thread priorities help, and they do work on platform (which you are probably right about wrt Windows), then nothing wrong in using. Just that make sure they do help.
Answer: You want to use thread pools, which would be made useless if you had to spawn new threads just to set job priority.
I think you want each job (not thread) to have a different priority. If that is the case, let's look at a constructor signature for ThreadPoolExecutor:
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
TimeUnit unit, BlockingQueue<Runnable> workQueue)

Instead of using one of the recommended Executors' factory methods to construct your thread pool, do new ThreadPoolExecutor(...) yourself, using one of its numerous signatures.
Pass Executors.defaultThreadFactory into this constructor (the signature I listed above does this internally). This will do automatic thread priority assignment as it creates the threads (for a fixed size thread pool, that should happen just once per thread, at app start).
Pass a BlockingQueue<Runnable> or PriorityBlockingQueue<Runnable>  into this constructor. This is the queue which will allow you to prioritise jobs (not threads).
Extend Runnable into an abstract PriorityRunnable class which allows get/set of priority. These represent the jobs, so when you want to make a new job, simply extend this and custom-set the priority as appropriate for that job.
Implement Comparator to perform ordering on elements as you insert them into the queue, and let that queue use it.
Add your jobs to the queue.

Note that if you have your queue already populated by this time (eg. for batch processing apps), you can call executor.prestartAllCoreThreads() or executor.prestartCoreThread(n) at once after construction.
It's all pretty simple, and takes surprisingly few lines of code to set up.
EDIT: Just found the same approach being discussed over at Java Ranch.
Answer: As far as setting the priority of the thread is concerned, you can use the different methods of the Executors class which take a ThreadFactory. This factory would be responsible for the creation of threads based on the passed in "Runnable".
Regarding monitoring, can you extrapolate on the scenario you are trying to address here when you say "each stage of execution"? As it has been mentioned elsewhere, since there isn't a clear mapping between Java and OS thread priorities, relying on these priorities would be a bad thing, in case that is what you are attempting here.
Answer: This could solve your problem:      Thread.currentThread().setPriority([1..5]);
You can use them from anywhere. If you use them from inside a runnable launched by a thread pool, you can control the single thread priority and change it as needed.
Answer: I recently implemented this. I did it much as Nick Wiggill suggested.
But you can't just do what he suggested, because ThreadPoolExecutor doesn't put the jobs you asked for in the workQueue--instead, it wraps them in its own RunnableFuture and puts them in the queue. So you have to override its newTaskFor method to pass along the priority.
The source code is online under the Apache 2.0 license:
https://github.com/TheClimateCorporation/claypoole/blob/master/src/java/com/climate/claypoole/impl/PriorityThreadpoolImpl.java


What is a good P value for statistical significance when conducting a Wilcoxon Rank Sum test?

Question: Is a P value of 0.4 statistically significant for a Wilcoxon Rank Sum test?
Comment: In order to be significant at the 5% level, the test should have P-value smaller than 0.05. // So P-value of 0.4 is not significant at any level usually considered of practical use.
Answer: Here is an example with data sampled (in R) from distributions of the same shape, but
with a rightward shift of $12$ for the second sample.
set.seed(121)
x1 = rgamma(20, 5, .1)
x2 = rgamma(20, 5, .1) + 12

The two sample medians happen to differ by about $22.5.$
summary(x1)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  12.10   24.62   42.50   43.53   61.02   77.18
summary(x2)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  36.05   55.61   64.94   68.40   72.53  150.03

Roughly speaking, the fact that the 'notches' in the sides of boxes in the boxplots
do not overlap is taken as an indication that the two samples are not from the same
distribution.
boxplot(x1, x2, notch=T, horizontal=T, col="skyblue2", pch=20)

The Wilcoxon signed-rank test has P-value $0.0014 < 0.05$ so the two sample medians
are significantly different at the 5% level (also, for this particular example, at the 1% level).
wilcox.test(x1, x2)

        Wilcoxon rank sum test

data:  x1 and x2
W = 85, p-value = 0.001435
alternative hypothesis:
  true location shift is not equal to 0


Why weren't Ionian / Aeolian / Locrian modes considered Gregorian modes?

Question: It is said that the Ionian (major), Aeolian (natural minor), and Locrian modes weren't really three of the ancient church (Gregorian) modes.  What is the reason?
Answer: Historically, the modes were methods of classifying chants. There were few if any chants having the note patterns that fit the Ionian or Aeolian or Locrian modes. Later (1400s or so) Locrian wasn't used as the natural fifth above the final note (B) was diminished. Actually, in the earliest known chant descriptions, the note B was mutable (B soft written "B" being Bb and B hard written "H" being B natural; this practice has been followed in German writings.) (Other languages may have written them differently; some used B-moll and B-dur or the like.)
The modes roughly described the range of chant melodies. From D to d (an octave with scale steps D-E-F-G-A-G-B-C-D with half steps between E and F and between B and C) was the normal Dorian; lower would have been A-B-C-D-E-F-G-A (called Hypodorian meaning below Dorian) to describe chants that had a different range. The final note in both cases was a D. (The pitches were relative, not absolute.) This would have been the Aeolan were the chants to end on A but most ended on D in this classification. Similarly for Hypolydian (C-D-E-F-G-A-B-C) with F being final and Hypophrygian being B-C-D-E-F-G-A-B. The scale patterns existed but were not considered separate as the chants didn't end on these notes.
Hypomixolydian had the same pattern as Dorian but with different endings.
During this time, the hexachord classification was also developing and used along with the modes. The "soft hexachord" F-G-A-Bb-C-D, the "hard hexachord" G-A-B-C-D-E, and the "natural hexachord" C-D-E-F-G-A-B. These were written in an overlapping manner and allowed one to describe "modulation" between modes. It was very complicated. Check Google and the Wikis about chant modes and hexachords.
Later in the 1500s some authors did allow for 12 modes and some for 14. With the invention of F# and Eb then C#, etc., things got more complicated until by the 1800s, the current naming became common.
Comment: Excellent answer, kept pretty straightforward. Would it be fair to say that after Amrose (4C) and Gregory (6C) that nothing significantly changed for the next millenium, until  mid 16C? +1.
Comment: @Coemgenus: The soft (or mollis) hexachord contains a "soft" B-flat and thus begins on F.
Comment: The soft hexachord should start with G, not F.
Comment: I got the descriptions here. http://www.medieval.org/emfaq/harmony/hex1.html#:~:text=The%20basic%20hexachord%20system%20and,for%20a%20semitone%20(semitonium).
Comment: @Tim: Actually, the history of modal theory is really complex and went through quite a few different stages. There was no modal theory (at least as we know it) at the time of Ambrose or Gregory. It seems to have originated in the 8th/9th centuries as part of Carolingian reforms that were intended to classify the aural tradition of existing chant melodies, at first according to their cadence patterns (nothing to do with scales). Originally, there were four "modes" (at that point called "tones"), then 8, then at some point the Greek terms were applied, etc. Lots of stages.
Comment: @Athanasius Then the answer should say "F-G-A-Bb-C-D". As it is now, it skips G and adds E, maybe a typo.
Comment: @Coemgenus: Thanks.  Yes, it was a typo.  Will fix.
Comment: 'the "natural hexachord" C-D-E-F-G-A-B': that would mean that the natural hexachord had seven pitches.  Since it has only six, it's C-D-E-F-G-A.
Answer: Ideally, we like to imagine 7 modes for the 7 tones of the diatonic scale:

A = Aeolian
B = Locrian
C = Ionian
D = Dorian
E = Phrygian
F = Lydian
G = Mixolydian

In fact, motives can be found in all 7 tonalities (the other answer misleads on this point), but their classification was perceived in the first millennium as a system of not 7 modes but 4 (doubled to 8, for there were two versions of each mode, as described in the other answer):

The First (Church modes I and II) = Dorian, Aeolian, or both
The Second (Church modes III and IV) = Phrygian, Locrian, or both
The Third (Church modes V and IV) = Lydian, Ionian, or both
The Fourth (Church modes VII and VIII) = Mixolydian

What might be dubbed the Fifth, Sixth, and Seventh in a "pure" heptamodal system are seen rather as variants of the other four. This is because of the flattenable B, a tradition that appears to date back to, or at least has theoretical continuity with, the principle of the "diazeuxis" in the musical system of Ancient Greece.
The custom of permitting B as both natural and flat in the course of a diatonic melody introduces an allowance for "one degree of modulation" of the tonality, without actually deeming a change of mode. For example, if we allow for B-flat in the D mode, D takes on an Aeolian character, since its intervals are now identical to the A mode when the A mode has a B-natural. Thus:

A mode (naturally Aeolian) + B-flat = A Phrygian (= E mode)
B mode (naturally Locrian) + B-flat = B-flat Lydian (= F mode)
C mode (naturally Ionian) + B-flat = C Mixolydian (= G mode)
D mode (naturally Dorian) + B-flat = D Aeolian (= A mode)
E mode (naturally Phrygian) + B-flat = E Locrian (= B mode)
F mode (naturally Lydian) + B-flat = F Ionian (= C mode)
G mode (naturally Mixolydian) + B-flat = G Dorian (= D mode)

Trim off the redundancy, and you get a minimum of four possible modes, with one degree of modulation:

The First = Aeolian <--> Dorian
The Second = Locrian <--> Phrygian
The Third = Ionian <--> Lydian
The Fourth = Mixolydian

Guido of Arezzo captures this rationale in his Micrologue on Music, Chapter 7:

De modis quatuor et affinitatibus vocum.
Cum autem septem sint voces ... septenas sufficit explicare, quae diversorum modorum et diversarum sunt qualitatum. ... Et nota, quod se per ordinem sequuntur, ut primus in A. secundus in B. tertius in C. Item primus in D. secundus in E. tertius in F. quartus in G.  Itemque nota has vocum affinitates per diatessaron et diapente constructas: A. enim ad D, et B. ad E, et C. ad F, et D. ad G, a gravibus diatessaron, ab acutis vero diapente coniungitur hoc modo:

English:

On the four modes and the affinities of voices:
While there are seven voices [tones], then, ... it suffices to explain the seven, which are of diverse modes and qualities. ... And note that they follow themselves in order, as the first on A, the second on B, the third on C:  likewise the first on D, the second on E, the third on F, the fourth on G.  And likewise note these affinities of voices, constructed through a diatessaron [perfect fourth] and diapente [perfect fifth]:  for A is joined to D, and B to E, and C to F, and D to G, by a diatessaron from the lowers, or by a diapente from the uppers.

These "tonal affinities" are the underlying principle that makes the circle of fifths possible.  If we were to hypothetically allow for not one but two degrees of modulation up or down the circle of fifths, i.e., two flats for example, we would have three modes covering all 7 diatonalities, for example:

First = Aeolian <--> Dorian <--> Mixolydian
Second = Locrian <--> Phrygian <--> Aeolian
Third = Ionian <--> Lydian <--> ...

Or for three degrees only two modes:

First = Locrian <--> Phrygian <--> Aeolian <--> Dorian
Second = Mixolydian <--> Ionian <--> Phrygian

At six degrees, we have only one mode, whose melodies can be composed in all seven tonalities of the original modes.
If we undo all those allowances and forbid flats and sharps in all chant melodies, then we will have to classify 7 modes, one for each of the 7 tonalities, unless of course we forbid the Ionian, Aeolian, and Locrian for example. But that simply did not happen in Gregorian chant, where you can find the interval patterns of all seven modes. It's just that they are perceived as four.
This kind of perception is not dissimilar to today where a minor-key song can have Aeolian, Phrygian, and harmonic minor elements, but we still think of it as "minor" and often don't even notice those other elements until we analyze the piece.
Comment: I would add that the names of the modes, at least of the three that are the subject of the question, are anachronistic.
Answer: The other answers are interesting and informative, but there is a simpler answer:  those three modes were identified and named at a much later point in history.  The Aeolian and Ionian modes were introduced to music theory in the middle of the sixteenth century, hardly "ancient" history, and the Locrian mode had to wait another couple of centuries, not being introduced before the eighteenth.
The other answers describe the reasons behind this timing.


Prove that if a commutative ring $R$ is integral domain, then the polynomial ring $R[x]$ is also an integral domain.

Question: I know that it is true that if a commutative ring $R$ is integral domain, then the polynomial ring $R[x]$ is also an integral domain. But I am having troubles with proving this statement. Can I ask for someone's help, please?
Comment: If you have two nonzero polynomials, when you multiply them, can the product of their highest degree terms be zero?
Answer: Suppose that $R[x]$ is not an integral domain. Then there are two nonzero elements, $p,q\in R[x]$ such that $pq=0$. Write $p$ and $q$ as
$$p(x) = \sum_{i=0}^n a_ix^i;\qquad q(x)=\sum_{i=0}^mb_ix^i$$
where deg$(p)=n$ and deg$(q)=m$. Consider the coefficient of the $x^{n+m}$ term, $a_nb_m$, in the product $pq$. Since $pq=0$, this implies $a_nb_m=0$. This contradicts the assumption that $R$ is an integral domain.
Comment: @rentatodias The problem is that $x$ is not an element of $\mathbb{F}_p$, just a free variable, and so Fermat's little theorem doesn't apply. That is, $x^p\ne x$ as polynomials in $\mathbb{F}_p[x]$. That said, this does mean that $x^p-x=0$ in $\mathbb{F}_p[x]/(x-a)$.
Comment: I have a question. Taking $R:=\mathbb{F}_p$, which is a field (therefore an integral domain) we have by Fermat's little theorem that $a^{p}=a$ for all $a\in\mathbb{F}_p$, so $(x^{p-1}-1)x=0$ as polynomials in $\mathbb{F}_p[x]$. This means $\mathbb{F}_p[x]$ is not an integral domain... What am I missing?
Answer: You have to show that if $f(x), g(x) \in R[x]$ are elements, then if $f(x)g(x) = 0$, it must mean that neither $f(x)$ or $g(x)$ are the zero divisors.
Such elements take the form $f(x) = \sum a_n x^n$ and $g(x) = \sum b_m x^m$, then their product $f(x)g(x) = \sum_{n,m}a_nb_mx^{n+m} =0 \iff a_nb_m = 0$. But $a_n, b_m \in R$, so neither of these are zero divisors meaning the original polynomials are not zero divisors. Since these polynomials are chosen arbitrarily, you are done.


Problem with insert/update links with tinyMCE

Question: I have a problem with tinyMCE but only on live environment from some reason tinyMCE rewrite absolute url and only for some TLD sites, so far I'm notice that it doesn't work for .eu domains, does someone hade a same problem or know what can fix this?
Answer: We needed to set both of these options in order to get TinyMCE to stop rewriting URLs to relative paths.
relative_urls : 0
remove_script_host : 0

Answer: Although this question has already been answered. I have my own solution and it could be helpful to some others if the accepted answer does not work.
Please see link below for more info.
tinyMCE.init({
    ...
    convert_urls: false,
});

https://www.tiny.cloud/docs/configure/url-handling/#convert_urls
Answer: Am I the only person that finds the TinyMCE relative_urls option confusing ?
If you're writing an article/blog post and want to include a ink to a web site other than one you're on, I think the term "absolute URL" describes what you want. You want to put "http://www.somesite.com" and not have TinyMCE put either a forward slash '/' or a relative path '/mysite/' in front of it.
Surprisingly, if you set the following :
tinyMCE.init({
        ...
        relative_urls : false
});

then that's exactly what TinyMCE does :(
But, if you do this :
tinyMCE.init({
        document_base_url : "http://www.somesite.com",
        relative_urls : true
});

Then you seem to get plain, unadulterated links.
Go figure.
Answer: I ran into some similar problems with tinyMCE before. It has some strange default behavior with URLs. There are a number of initialization properties you can set that effect how it behaves. Take a look at the documentation and experiment with these properties. At least that's what I did and eventually got the behavior I wanted.
Good luck!
Answer: relative_urls: false,
remove_script_host: false,

That will result with URL like http://www.youpage.com/subfolder/file/etc
Answer: You can do this
tinyMCE.init({
        ...
    relative_urls : false,
    remove_script_host: true,
});

for more details https://www.tinymce.com/docs/configure/url-handling/#remove_script_host


"Choice Column" SharePoint

Question: I had created a choice column in SharePoint with "or specify value" and then I edited this list in Info-path. I deleted this "Drop-down menu" and added one from Info-path. But now I do not get "Specify value in a text box" option when I publish it. Before editing it in Info-path I had it so that there was a drop-down menu to choose from and if the value did not exist in the drop down then the user would specify it in a drop-box. The only downfall with this was that the drop-down did not update the information once the user enters a specific value. So I thought of using Info-path to provide me a workaround. However, now I do not have the previous functionality at all. Please advise.
Answer: Apparently, drop down controls cannot do that OOB. But combo or Multiple Selection List boxes can, if you can use one of those instead.

"Choice Column" SharePoint


Remove one voice from a video?

Question: My close friends husband died last weekend.  I came a across a video I took of him singing her favorite song but I'm singing pretty loudly also.  Is it possible to remove my voice or at least make it less loud?  When I showed her the video she cried and had just thought yesterday that she would never get to hear him sing that song to her again.  This would be such a gift for her.
Answer: I'm afraid this is unlikely to be possible with current technology.
In the past few years, removing a voice from a music track has turned from pipe-dream into reality, using machine learning techniques [often mislabelled Artificial Intelligence].
Removing one voice from another singing in unison or even harmony though, is a whole different level of "AI".
If the voices are on different sides of a stereo file, then you could possibly separate the stereo & process just one side. I'm assuming this is a phone recording with a mono soundtrack, which I think is currently an unreachable goal.
Answer: sorry to hear that :/
I don't think you could do this automaticly with AI, but of course you can edit the audio with EQ and loudness automations to at least make your parts less obvious or loud. Afterwards just render a new video with the new soundfile.
If you don't have the tools to do it, I surely could help you out with that :)
My friend makes animated videos and I cut the sounds to his videos so it would be no big deal I gues. Peace

Remove one voice from a video?


Tryptophan Operon Working Mechanism

Question: The Trp operon has 2 methods to check for presence of tryptophan, one indicating the absence of free Trp and the other the absence of charged Trp tRNA. If both methods showed absence of Trp there is tryptophan synthesis. However, the synthesis of tryptophan involves 5 enzymes to be synthesized, and usually we find all the amino acids in a protein such as an enzyme. Therefore, there is high probability that Trp is found in these 5 enzymes. Where does that Trp come from if there is neither free tryptophan nor charged tRNA for Trp?
Answer: You're right that if there was really a complete lack of Trp, then the cell wouldn't be able to make the enzymes. But the cell doesn't have to wait until [Trp] drops all the way to zero -- it can induce expression of the operon when the concentration gets sufficiently low (in practice there's some continous relationship between [Trp] and expression). Note that there's always going to be a little bit of Trp around as there are constantly proteins being degraded (and resynthesized).
But you're on to something -- in fact there is some bias towards lower usage of a particular amino acid in enzymes that are responsible for synthesizing that amino acid. Here's the paper: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1839009/ although the effect isn't that high for Tryptophan.

Tryptophan Operon Working Mechanism


is my fish going to die?

Question: My redcap orlanda seems to be in fairly critical condition, he just floats up and torpedoes to the bottom, then floats at the top for a while, his gills are still moving and he is still trying to swim around, but he isn't having much success, is he going to die? Is there some way I can save him? Please help :(
Comment: Can you give some more details such as size of tank, ammonia, nitrite, nitrate, pH, temperature, etc... What do you feed the fish?  Since you noticed this, have you been doing partial water changes?  As much information as possible is very helpful for others in the community to provide the best answer.
Comment: See, I don't know any of these details, all I know is the tank is a 35gallon and I haven't done a water change in about a week cause I was using an ich cure to get rid of ich,
Comment: And also, can I use green beans as a substitute for peas in getting rid of a swim bladder infection?
Answer: Fancy goldfish are prone to swim bladder issues related to several different causes... some minor, some more serious. The wrong foods can cause digestive bloating and/or constipation and this can put pressure on either of the swim bladders or the lines leading to them and this prevents the fish from being able to control their swim bladders. Try feeding green pea (pinch the shells off and discard the shells.. then mash the meat a little if your fish are really small. This will help cure constipation issues.
Other causes can be internal bacterial or parasitic issues causing inflammation of digestive tract or other organs causing the same pressure on the lines or swim bladders.
Fancy goldfish are prone to this because of the inbreeding that took place to create the deformities and mutations you can see on the outside also can cause deformities and mutations to internal organs as well. Further, their two swim bladders, which are normally spread out far away from each other in normal goldfish, are all crammed together in fancy goldfish due to their compacted and round body shape.
Start doing daily 25% PWC's (partial water changes) as dirty water will also cause fish to get sick much faster so giving them clean water will help them get well faster.

is my fish going to die?


Rollercoaster physics!

Question: I'm completing an assignment about roller coaster physics, however, I'm having difficulty understanding a concept. The image depicts a rollercoaster with a motor, however, I am not sure what it means when it says to determine "the energy that must be put in to reach point 2". I can determine the energy specifically at points 1 and 2, but I'm not sure if that's of any use. Where did I go wrong?
Answer: The Energy given by the motor between point 1 and point 2 would be equal to the difference in Energy between point 1 and 2.
In the second part as you have been given Power of motor, you can use P=dE/dt to determine the time taken.
For third and fourth part you simply have to conserve energy as the motor is only between point 1 and 2.
Comment: Thank you so much for the clarification for each part of the question! Just a thought, are you supposed to use the change in energy you calculate in part A for part B in the power formula?
Comment: @MeganDime Yes as the power is constant, it provides constant energy in unit time and it will you the time required to give the energy change between point 1 and 2.
Answer: Well, if you can determine the value of the mechanical energy (potential+kinetic) at those two points, then their difference must be equal to the energy that the motor supplied to the cart. for part b) you want to use $P=\frac{dE}{dt}$ to determine the amount of time it takes for the motor to output the energy that you found in part a)
If you cannot figure out part c) and d) feel free to reply and I can help you out.
Comment: hey! thank you so much for the clarification. for part 3, i was thinking of using the equation Em = mv^2/2 (because mgh cancels out) and then plugging in the mechanical energy on the left side of the equation according to the law of conservation of energy. but would i need to use the mechanical energy at point 1 or 2? because isn't the mechanical energy at those 2 points different, so i would get 2 different answers? I'm not sure what I should do :/
Comment: Change in energy is 0 because the motor is not doing work past point 2. This implies that the gravitational potential energy at the top of the hill is converted to kinetic energy at the bottom of the hill. mgh+KE(initial)=KE(final) so you must add the gravitational potential energy of 124.5 meters to the kinetic energy it has at the top of the hill and that will give you the kinetic energy at the bottom of the hill. To answer your question about which one of the two points, you want to use the last point that you know the carts energy, point 2.
Answer: You are going in the right direction; after calculating mechanical energies at points 2 and 1, you calculate the difference, $ E_2 - E_1 = \Delta E = \Delta K + \Delta U = (K_2 - K_1) + (U_2 - U_1)$, which is exactly the extra energy you put in, to go from point 1 to point 2.
Notice that both $\Delta K$ and $\Delta U$ comes out to be positive (non zero), so there must be non conservative force acting on it, that's exactly what the motor is doing, so,
Work done by motor is $$\int_1 ^2 P dt = \Delta E$$
this gives you the time taken $\Delta t=t_2 - t_1$.
The third and fourth parts are the easier ones, as for them, $\Delta E = 0$.
Comment: this is great, thank you!
Answer: Consider that the roller coaster is at point 1. The roller coaster has some kinetic energy as depicted in the figure and some potential energy if we consider ground as a zero reference point.
As the roller coaster is moving the point 2 we can see that the velocity of the roller coaster has been shown to increase from 5.24m/s to 8.86m/s and there has been an increase in the gravitational potential energy of the roller coaster. This simply implies that there has been some additional energy supplied to the body which caused its total mechanical energy to increase.
Now, coming to the solution the energy that must be supplied should be just the difference between the total mechanical energy between point 2 and point 1. (At this point I am just assuming that there is no friction on the hill as there has been no mention about any energy losses in the question).
The 3000W motor will do the work for the roller coaster cart to reach the mechanical energy mentioned in position 2.
Comment: thank you for clearing up some of my questions! :)

Rollercoaster physics!


Mirror Modifier does not work on where ther are no faces

Question: If I open up Blender v2.73 and select the cube and delete it. Then select front view ortho and add a circle mesh and check align to view. Then add a mirror modifier the mirrored part does not appear. However if I make a face (doesn't matter how, press f or extrude and edge) then the mirrored half appears. Is this a bug? I'm new to blender so don't feel confident about reporting this. This appears to work as expected in a tutorial video that I watched (Venoms Lab2 Modelling 1).
Comment: it wont appear as it is mirrored to itself(original overlap with the mirror), add a mirror object and move it you'll see it there
Answer: All modifiers have several options that alter the way they are displayed. Not all modifiers have every option available. The buttons for these display choices are shown at the top of each modifier -

The first two options  are available to all modifiers and make the modifier visible in final render or viewport display. In object mode in the viewport with this enabled you will see the edges created by the mirror modifier.

When available the other two options effect what modifier data is shown in edit mode.
While in edit mode and with the third option disabled you will not see any of the mesh created by the modifier.

While in edit mode and the third option enabled you will see only faces drawn that are created by the modifier. This is the default for many modifiers.

The final option allows the full edit mesh to be displayed. With this enabled you can select parts of the mesh on the mirrored side. Be careful with this option as all movements are done on the real geometry only, as you select mirrored vertices and move them they will move 'backwards' to what you expect.

Also remember that with the mirror modifier, if your mesh is centred around the point of the mirror, the duplicated mesh may be located in the same place as existing mesh data.
Comment: I don't think it is entirely clear (to the untrained eye) what 'options' you are referencing in your answer, e.g. it's not clear you are talking about the camera, eye, cube and triangle on the modifier when you say first, second, third 'option' etc.
Comment: Yeah, I was thinking highlighting each image was overdoing it, a small image of them should make it obvious what to look for.
Answer: Edges are a the equivalent of a geometrical line segment, having neither height nor width, just length. The only reason they exist is to connect the vertices, it has no visible change.
A single vertex in a similar manner is the same as a geometrical point, having no height, width, or length, just being a set of infinitesimally precis coordinates, creating no visible surface to render.
You will have to extrude the mesh in some way to make it visible at all.
Another point, made by Chebhou, is that the modifier mirrors the object based off of the origin of the mesh, if you have a complete circle mirrored on all axis, it will appear to be exactly the same. It is only when you delete some of the vertices that you notice it is actually being mirrored.
Comment: @ChisMatthews, just to clarify, it *does* mirror, you just can't see it. Be very careful when you talk about computers and you say "nothing happens".
 buddy, something always happens. Hit [Z] to go into wire-frame mode. this'll allow you to see the mirrored edges. (watch closely, they are very light.)


Javascript variable reuse?

Question: Is it OK to reuse variables for different data types in terms of performance and memory usage ?
What happens to old data, is it garbage collected immediately after type casting ?
Comment: Can you give an example of what you mean?
Comment: Where's the casting? You're just re-assigning something else. The type doesn't matter because of dynamic typing.
Comment: @delnan what about implicit cast ? (I think I read it somewhere, just asking, no idea what's going on inside)
Comment: Again, what casting? There's a variable. It has some value. You go and assign it some other value. What should be cast?
Answer: It's OK to reuse variables, although unless you're doing some crazy things (say so in the question) with the amount of variables you're using, you probably should not reuse them too liberally in this way. It's considered good coding practice in general to have a variable declared to point to a specific thing, and use a different variable when you want to refer to something else.
"Variables" in Javascript are just references. They're not inherently expensive-- they don't take up more space than their text in the code and a few bytes in memory pointing to somewhere else. If you reuse a variable name by setting the reference to something else (or null/undefined), then the GC will know that that original reference is detached and know that it can be collected.
The GC in whatever browser or environment you're using will choose when to actually run the collector based on lots of factors.
Answer: Full disclosure: I have no knowledge of the internals of any particular JavaScript engines. I'm going from general principles of VMs and interpreters.
Usually, variable names just refer to other memory locations. So, whether you remove an old variable (which happens when it goes out of scope) and introduce a new one, or replace the current contents with a new object, doesn't matter much in terms of memory allocation.
Garbage collection might be different in each implementation. Immediate garbage collection is difficult; the only way I can think of doing it involves reference counters, and it's tough to make that work even for cyclic data structures. So, most garbage collectors in the wild do non-immediate collection cycles where, each time, a whole bunch of data gets removed. The cycles might, for example, be run automatically when memory use goes above a certain threshold within the engine (but it'll usually be more refined than that).
Answer: JavaScript is a loosely-typed language, and can store any datatype in any variable (even reused ones).
If you are combining types, though, you should check them periodically using the typeof keyword to ensure they are the type you think they are (for instance, trying to perform a mathematical operation on a string will concatenate or break, depending on the situation).
Furthermore, JavaScript variables stick around as long as they are within scope. Once a scope is left, the variables within it are destroyed (eventually - it's automatic and transparent). As far as garbage collection on reassigned variables, the old value is destroyed as soon as the new value is assigned.
Comment: This is the only answer so far that makes any assertions about how GC-like operations occur. Could use some references.

Javascript variable reuse?


Probability that k randomly drawn permutations can be arranged to compose to the identity

Question: Consider the symmetric group $S_n$ under the uniform distribution. For integer $k > 1$, suppose we draw $k$ elements $s_1, \dots, s_k$ independently at random. What is the probability that there exists at least one rearrangement of the $s_i$ that composes to the identity?
Comment: For any fixed order, the product is also a uniform random permutation. So the *expected* number of arrangements equal to the identity is $k!/n!$. However the probability cannot exceed $1/2$ no matter how large $k$ is (think parity).  I think this problem has been studied; hopefully someone will know it.
Comment: The probability is given by $1/n!$ for $k=1$ and $2$ and by $\frac{2\cdot n!-p(n)}{(n!)^2}$ (where $p(n)$ is the partition function) for $k=3$.
Comment: @BrendanMcKay: Note that if $x_1\ldots x_k=1$ then any cyclic rearrangment has product $1$ as well. Hence I think the assympotics for $k$ fixed and $n$ large is  actually $\frac{(k-1)!}{n!}$.
Comment: @KasperAndersen That's a good observation, but it has no bearing on the expectation of the number of arrangements which is $k!/n!$.  Your expression is the expectation of the number of arrangements modulo circular shift.
Answer: Only a partial answer, which however is too long for a comment: Let $p_{n,k}$ denote the given probability. Then we have
(1) $p_{n,1} = p_{n,2} = \frac{1}{n!}$, $p_{n,3} = \frac{2\cdot n!-p(n)}{(n!)^2}$.
(2) $p_{1,k}=1$, $p_{2,k}=\frac{1}{2}$.
(3) $\frac{1}{n!}\leq p_{n,k}\leq \frac{(k-1)!}{n!}$.
(4) For $k$ fixed, most likely $p_{n,k}\sim \frac{(k-1)!}{n!}$ for large $n$.
(5) $p_{3,4} = \frac{77}{216}$, $p_{3,5} = \frac{139}{324}$, $p_{3,6} = \frac{101}{216}$, $p_{4,4} = \frac{35}{216}$, $p_{4,5} = \frac{3257}{10368}$ and $p_{5,4} = \frac{9533}{216000}$.
Clearly $p_{n,1}=\frac{1}{n!}$ and for $k\geq 2$
\begin{equation*}
p_{n,k} = \frac{1}{(n!)^k} \sum_{x_1, \ldots, x_{k-1}\in \Sigma_n} f(x_1, \ldots, x_{k-1})
\end{equation*}
where $f(x_1, \ldots, x_{k-1})$ denotes the number of elements $x_k$ in the symmetric group $\Sigma_n$ such that $x_{\sigma(1)} x_{\sigma(2)} \ldots x_{\sigma(k)}=1$ for some rearrangement $\sigma\in \Sigma_k$. This equation is equivalent to $x_k^{-1} = x_{\tau(1)} x_{\tau(2)} \ldots x_{\tau(k-1)}=1$ for some $\tau\in \Sigma_{k-1}$, i.e. $x_k$ should be the inverse of some rearrangement of the product $x_1 x_2\ldots x_{k-1}$. Since the number of rearrangements is between $1$ and $(k-1)!$ we obtain (3) and (1) for $k=1$, $2$. If $n\leq 2$, $\Sigma_n$ is abelian so there is exactly $1$ rearrangement, proving (2).
Moreover for generic elements $x_1, \ldots, x_{k-1}$ we have $f(x_1, \ldots, x_{k-1}) = (k-1)!$ indicating why (4) should hold. (I havent written down the details, hence the most likely above). Finally consider $p_{n,3} = \frac{1}{(n!)^3} \sum_{x_1, x_2\in \Sigma_n} f(x_1,x_2)$. Here $f(x_1,x_2)$ equals $1$ if $x_1x_2=x_2 x_1$ and $2$ otherwise. Thus, with $X = \{ x,y\in \Sigma_n | xy=yx\}$ we have $p_{n,3} = \frac{1}{(n!)^3} \left(1\cdot |X| + 2\cdot ((n!)^2-|X|)\right)$. Note that
\begin{equation*}
|X| = \sum_{x\in \Sigma_n} |C_G(x)| = \sum_{x\in \Sigma_n} \frac{|\Sigma_n|}{|x^{\Sigma_n}|},
\end{equation*}
where $x^{\Sigma_n}$ denotes the conjugacy class of $x$. The last sum clearly equals $n!$ times the number of conjugacy classes in $\Sigma_n$, i.e. $n! p(n)$. Plugging this in gives the desired formula for $p_{n,3}$ proving the last part of (1). Finally, point (5) was obtained by  direct computer calculation.
Comment: Impressive analysis! Do you think there is a chance for a "closed form" answer? Say, in terms of the partition function and other known combinatorial objects. Or are asymptotics maybe the best one can hope for?
Comment: I'm not sure if there is a closed form answer. One natural step would be to compute $p_{n,4}$ which would involve counting solutions to equations in $\Sigma_n$ like $xyz=xzy$  (which is easy) or $xyz=zxy$ (which looks hard...).


Performing PCR on samples whose DNA concentration is nul

Question: Is it vain to perform a PCR on samples whose DNA concentration was measured as nul by a NanoDrop?
Answer: Nope, you could get amplification from samples that are orders of magnitude below the nanodrop detection limit (~2 ng/uL). To compare: most manuals for polymerases recommend 1 ng of plasmid template, and will probably work with much less, especially if you use a few more cycles.
But if you expected to see something on the nanodrop, and you get nothing, something else might be completely wrong.
Comment: You can go down into the picogram range. And you could use nested PCR to ensure specificity.
Answer: Some times nanodrop is unreliable. However, to be sure that you are not wasting your time, I would redo the extraction. Nanodrop in a lot of PCR methods is a control test to validate that the extraction went well. So, I would redo the extraction if I where you.


How did the author got this final result from this Gaussian Distribution formula?

Question:
How did they got the final result?
Answer: Take natural logarithm of the expression. Logarithm of product of two terms can be written as sum of logarithms of each term: log(a.b) = loga + logb. e and natural logarithm cancel each other, there is left first term in the result. Logarithm of a 1/number is equal to -log(number), it gives second term in the result.
Taking logarithms of exponentials is quite common method for preventing numerical overflows and ensuring numerical stability.


Count the number of points of a polygon

Question: Actually, this is a continuation of a previous post entitled "Count the number of corners of a polygon". Although I managed to count the number of points (i.e. saying corners) of each polygon the problem is that even a polygon may be approximately rectangular actually has more than four points because of the digitization process i.e. sometimes an approximate straight line consists of more than 2 points. How can I ignore the intermediate additional points that are not really needed for my purpose? Thanks.
Comment: Did you try casting the polygon as an IPolycurve and calling [Generalize](http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//002m000002m5000000)?
Comment: @Demetris, 90 degrees and 270 degrees both look the same, it depends if you measure clockwise or counter-clockwise.  For the threshold you'll want to compare to 180 degrees to determine if you want to ignore.  `bool ignore = Math.abs(angle - 180) > threshold`
Comment: You could check the angles formed at each point; if greater than a certain threshold, don't count that point.
Comment: Actually, I have already thought to do that but my new problem is that some angles are measured based on the exterior turn and not the interior of the polygon. For example, while actually an angle is 90 degrees I got 270 degrees. The thing is that I dont not know why this happens and which angles for each polygon have this mistake. I try to compare some polygons using a CAD system. Do you have an idea about this problem?
Answer: I would simplify the polygon first to remove any of the unwanted vertices.
Comment: (+1) @Demetris This is a good, simple solution.  The vertices that remain in the simplified polygon will be exactly the ones you want to count.  You have the flexibility to use any simplification routine you like (and many of them let you set a tolerance), allowing you to achieve the results you intend.  Of course you don't replace the original polygon with the simplified one--the simplification is done on-the-fly purely for the purposes of obtaining the vertex count, and then is abandoned.
Comment: It is not a good idea to remove vertices because you may considerably modify the real shape of the polygon.
Comment: Demetris; the OP is actually asking to simplify the features, just not using those words. Using a suitable algorithm, you should be able to maintain the overall shape fairly well.
Answer: Go through each vertex and for each that is outside of tolerance of 180 degrees include in the count?

Count the number of points of a polygon


Call sales order model inside console command object

Question: After ugprade to M2 2.2.4, I got problem in my custom module. The module has console command but upon upgrade I'm getting "Area code is not set". After few hours of debugging, I found out that the root cause is calling \Magento\Sales\Model\Order object as parameter in my __Construct function.
Replacing it with reourceModel will work, but I'm just wondering why the main order model is not working. Any idea?
Answer: Change:
\Magento\Sales\Model\Order
To:
\Magento\Sales\Model\OrderFactory


Formula field assistance

Question: Is there a way to create a formula field on the Account object that pulls all values in a picklist field from All related Contact records?
IE: Contact has a picklist field named "Program". I would like to create a formula field on the Account named Programs which lists all the values from the Program field of all Contacts related to it.
Answer: No that's not possible with only a formula field. You will need to either:

create an APEX trigger on Contact for this, or
use a combination of roll-up summaries (1 for each of the programs, with a SUM of all Contacts having that program) and a formula field (rendering the program names based on the roll-up summary fields). This might not be a good option if you have many different programs
Comment: Thanks for the info and suggestions. We don't have a developer on the team so I might try number 2.

Formula field assistance


Which is better? SFTP or FTPS

Question: I've heard it from some sources that SFTP is preferable to FTPS. If this is the case, I'm wondering why exactly.
Comment: "How cool would it be to see a question get ping ponged SF->SO->SU->MSO->SF->SU->SF->SU->SF->MSO->Closed – Lucas McCoy"
Comment: A question like this is better suited for Serverfault.
Comment: @joshhunt A question did make the homerun, but not one has made a whirlwind.
Answer: There is a pretty explanatory article on the SSH-SFTP blog that details the differences between SFTP and FTPS, and gives an overview of the scenarios each one of them is more suited for.
According to the above mentioned article, each protocol has "pros" and "cons", so depending on each specific scenario, one protocol may be more effective that the other one.
Here below I will recap the points that - in my humble opinion - are the most important:
SFTP is always secure, FTPS may be not: SFTP is a subsystem of the SSH protocol, and therefore it always runs in an encrypted/secured channel; FTPS instead may feature a plain (unencrypted) FTP fallback strategy, in case the server does not support SSL/TLS.
FTPS can be faster than SFTP: in the exact same network conditions, FTPS could be probably faster than SFTP, as it runs the control channel and the data channel seperately (while SFTP runs in a single channel and interleaves the control packets within the data flow)
SFTP is firewall-friendly, while FTP(S) is not: SFTP runs inside SSH thus it uses only one port on the server (default: 22); FTP(S) instead requires either the possibility for the server to connect back to the client (active) or a wide number of open ports on your firewall for the server to accept incoming data connections (passive).
FTPS can delegate trust, SFTP can not: FTP(S) leverages the SSL/TLS intrinsic security based upon X.509 certificates that can be issued by a Certification Authority trusted by both parties, while SSH Server Keys can only be issues by the server part and must be trusted by the client part.
Comment: Can you give a more detailed description of the linked content, and explain how it relates to the question? This will help ensure that this answer remains useful in the event the link becomes invalid.
Comment: Sure. I am going to edit the answer now...
Answer: I prefer SFTP over FTPS mainly because it takes extra effort to set up an FTP server on a server. Most probably the server is going to already have SSH installed to administer it remotely, so why not just take advantage of what is already installed? Using SFTP requires no extra effort to get it running.
Most FTP clients have built in support for SFTP, so client support is mainly a moot point.
Answer: This page from CodeGuru has a good summary of the pros and cons of each:

As usual, the answer depends on what your goals and requirements are. In general, SFTP is technologically superior to FTPS. Of course, it's a good idea to implement support for both protocols, but they are different in concepts, in supported commands, and in many other things.
It's a good idea to use FTPS when you have a server that needs to be accessed from personal devices (smartphones, PDAs, and the like) or from some specific operating systems that have FTP support but don't have SSH/SFTP clients. If you are building a custom security solution, SFTP is probably the better option.
As for the client side, the requirements are defined by the server(s) that you plan to connect to. When connecting to Internet servers, SFTP is more popular because it's supported by Linux and UNIX servers by default.
For private host-to-host transfer, you can use both SFTP and FTPS. For FTPS, you would need to search for a free FTPS client and server software or purchase a license for commercial one. For SFTP support, you can install an OpenSSH package that provides free client and server software.
Answer: SFTP has no problems with port mappings, and thus no issues with NAT router/firewalls. (And, many home DSL and cable modems are in fact NAT routers, and attaching a standalone wireless access point might even introduce "double NAT".)
In FTP, and hence in FTPS, multiple connections are needed. Client and server agree on the IP address and ports to be used within the so-called "application level" communications. But, a NAT router or firewall (which would rather only care about "transport level" issues) needs to know about these details, and hence needs to inspect the actual data. This raises many issues, which are non-existent for SFTP.
Answer: I dont think that one is preferable over the other. It really depends on your infrastructure. This thread from CodeGuru discusses the pros and cons of SFTP and FTPS.
One benefit of FTPS is the data channel. The data channel can be redirected to transfer files from server to server. This feature is not well understood. Thats why alot of people would say that the FTP data channel is unnecessary.
I believe that if you're just interested in sending files securely, then you should go with FTPS. If you already have an SSH infrastructure, then SFTP might be useful.

Which is better? SFTP or FTPS


I am installing new ubuntu in my system which one should I choose 16.04 or 17.10?

Question: I am setting up a new ubuntu system. I want to know which version should I choose to go with. My usual work is to surf the internet and do programming in React Native, Python, Docker etc. I want to know if there is any Dependency related issues with Ubuntu 17.10 or is it ready for development purpose also. Please help me decide which one should I go with.
Answer: I'm just a desktop end user, but I would stick with 16.04 since it's the stable long term supported (LTS) version.  It should have the least likely chance of dependency issues since many vendors standardize on it knowing it will be supported for 3 years.
The next LTS, 18.04, is due out this April therefore there is a ton of development going on to 17.10 that will culminate into 18.04.
Comment: fyi:  Ubuntu LTS 16.04 has five years of support for everything in the 'main' repo (or everything on the official install iso)
Comment: If he is using MATE for example, it is 3 years. 5 years only the main Ubuntu LTS release!
Answer: 16.04 is a LTS (Long-Term Support) version and is more stable than 17.10, which has 9-month support only against 5 years from LTS (Ubuntu flavors might have different EOL).
Usually some developers want to have access to the most recent features and packages, so that would be good to stick with 17.10, but that means after July 2018 you will have to upgrade your computer to get access to software updates - 17.04 release ended its life by January 13th, 2018.
If you don't want to upgrade your computer every 9 month and the software available in 16.04 is OK for you then stick with 16.04.
Check also the Ubuntu release page: https://wiki.ubuntu.com/Releases
Answer: I'd choose Ubuntu 16.04 as it has the long-term support meaning its bugs are fixed and the system is overall stable.
Anyway, 18.04 version with the long-term support as well is going to come out soon, so it'd make sense to wait for it and upgrade from 16.04.


(Un)Decidability of the root existence problem for functions with bounded domain

Question: The problem whether a real function $f$ has a root or not is undecidable, given that $f$ is from a class of functions including polynomials and the sine function (http://dl.acm.org/citation.cfm?id=321856). Usually, undecidability is proved by using a periodic function like sin to encode integer problems. Is there anything known about undecidability of the root existence problem for some "reasonable" class of functions with bounded domains, such as from a bounded $\Omega\subset\mathbb{R}^m$ to $\mathbb{R}^n$?
Comment: As mentioned in http://mathoverflow.net/questions/109814 , the real field expanded with all analytic functions on a bounded domain is an o-minimal structure. However, I'm not aware of any results on the decidability of its reducts to a finite language (note that decidability of an o-minimal structure is equivalent to decidability of the root existence problem for its definable functions). Decidability of the real field with exponentiation is a notorious open problem related to Schanuel's conjecture.
Comment: Also, asking the functions to have bounded domain does not make much of a difference per se. A "reasonable" class of functions on, say, $(0,1)^m$ can be made into a "reasonable" class of functions on $\mathbb R^m$, and vice versa, by composing with a "reasonable" homeomorphism of $(0,1)$ and $\mathbb R$, such as $1/(1-x)-1/x$.
Comment: Emil: right, thank you. What I have in mind is in fact compact domains (typically, finite unions of cubes), my formulation was not very good.
Answer: Suppose there is an algorithm that decides whether a function $f\colon \Omega \to \mathbb{R}$ has a root. Then one can also compute a root of $f$ if $f$ has one.
One can see this using a standard bi-partition argument:
Cover $\Omega$ with finitely many balls of radius $1$. This is possible since the closure of $\Omega$ is compact. Then using the algorithm we can find a ball that contains a root of $f$.
Then we cover this ball with balls of radius $2^{-1}$ and again find a smaller ball which contains a root...
Iterating this process yield a sequence converging to a root of $f$ with rate $2^{-n}$ or in other words a Cauchy-real representation for a root.
Now, finding a root for a function implies Brouwer's fixed point theorem.
To see that let $\Omega$ be bounded and closed and $g\colon \Omega \to \Omega$ continuous. $g$ has a fixed-point at any root of the function $f\colon \Omega \to \mathbb{R}$, $f(x):= \lvert g(x) - x\rvert$.
For Brouwers fixed point theorem it is known that there is no algorithm to find solutions, see for instance Computable counter-examples to the Brouwer fixed-point theorem, Petrus H. Potgieter.
Thus, we can conclude that there is no algorithm which decides whether a function has a root.
Comment: The questions asks for an algorithm *deciding* whether or not the function has a root, not an algorithm for *finding* a root. So you need an extra step to show that deciding whether there is a solution in $\Omega$ also allows you to compute one. I think that can be done but it would be nice to include here.
Comment: @François thank you, I missed that point.
Comment: This is really beautiful!
Answer: Suppose $f$ is continuous (and therefore uniformly continuous) on a compact domain $K \subseteq {\mathbb R}^n$ (and this is effective in the sense that given $\epsilon > 0$ you can construct $\delta > 0$ such that
$\|x - y\| < \delta$ implies $\|f(x) - f(y)\| < \epsilon$.  Then if $f(x) = 0$ has no solution in $K$ you can prove that fact: take $\epsilon > 0$ small enough, take $\delta$ as above, cover $K$ with finitely many open balls of radius $\delta$, and compute the values of $f$ at the centres of these balls with sufficient precision to show they all have norm $> \epsilon$.
Comment: Robert: thank you. However, in this way you can only prove the non-existence of a root (if it doesn't exists).
Comment: Peter: Yes, I know.  I don't think there is any way in general to prove the existence of a root if it does exist.


Why couldn't Kousei hear himself play?

Question: In the beginning, there were several times when Kousei was playing the piano, and he suddenly felt that he was at the bottom of the ocean and couldn't hear what he was playing. Why did that happen, and was he able to hear himself play at the end?
Answer: The reason is because of the psychological trauma he suffered from being forced by his mother to play exactly as the notes book dictates and punish him for every wrong notes. He felt frustated as even when he did his best and won competition by competition, her mother still wasn't satisfied as he still made a few mistakes here and there, despite already called as the human metronome for his astounding accuracy by others. And the when he's fed up, he burst in anger at his mom and soon after his mom died, making him feel shocked and guilty which shown in his mother's ghastly appearance in when he played his piano. This psychological trauma is the cause and it doesn't immediately kick in too, which explains why he can hear the first few notes and when he's getting into it, he lost it.
Answer: The more he focuses, the more he gets into it, and the more the traumatic memories kick in. It's probably some sort of side affect from maybe PTSD or Post-Traumatic Stress Disorder that only occurs in Kousei's case, because his mother introduced him to the piano and now since she is gone, part of the piano left with her.

Why couldn't Kousei hear himself play?


Facebook "publish_actions" permission

Question: I can't publish anything on user timeline when facebook has remove "publish_actions" permission? If it can,how to upload video on user timeline?Or how to review "publish_actions" permission with Graph API v2.12.
Answer:
On August 1st, 2018, the Live API publish_actions permission, which
  allows an app to publish on behalf of its Users, will be reserved for
  approved partners. In the coming weeks, a new permission model that
  allows apps to publish Videos to their User's Groups and Timelines
  will be announced.

Source: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes
Answer: just remove this line of your facebook code
<code> LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
</code>

Facebook "publish_actions" permission


How to make USB smartphone charger?

Question: I want to make a USB cell phone charger. I know USB operates in 5 volts which means i need to drop down voltage if i have battery potential greater than 5 Volts. I have 12 volts sealed lead acid battery (SLA) of capacity 9AH. I need to drop down the voltage for which i am using LM2596 buck regulator ( Switching power supply) and it can deliver 3 amperes of current. But my cell phone charger(came with the product) is rated for 2A. So i was wondering how can i limit the current so that it doesnot blow my Cell phone. Thanks
Answer: The cell phone charger spec is a maximum. I.e. the maximum current that can safely be drawn from the charger is 2A. If the buck converter is rated for 3 amps, then you have more than enough current available to charge your phone. Your phone will draw the current it needs.
Some phones (especially Apple devices) are finicky about the data lines. You can't just leave them floating (with nothing connected). Adafruit has a good discussion about reverse engineering the voltages that are required on the USB data lines for charging Apple devices.
Comment: Thank you for your Response,So, i can directly connect my phone to the output of buck regulator without current regulation meaning that smartphones (no matter what models do they belong) will automatically draw current what it needs???
Comment: Correct. Think about a resistor. From Ohm's law, a 10 ohm resistor placed across 5 V battery would draw (or allow) 0.5 A. A buck converter provides a constant voltage source like a battery, allowing a variable current to flow depending on the load. Your phone is the load in this case.
Answer: Provided you correctly set the voltage by the feedback network, you cannot blow your phone by current rating. The phone will draw precisely as much power as it needs.
Also FYI, you should connect the data wires together (better with a 100 ohm resistor) to inform the phone that this is not a computer, but a charger. I used to have a phone (Sony Ericsson j108i) which refused to charge without proper USB detection or at least this workaround.

How to make USB smartphone charger?


How to install Epson L375 printer in Ubuntu 16.04

Question: I have installed now Ubuntu 16.04 in my computer, but the installation of my Epson Ecotank L375 printer failed. I can not find the driver of the printer and there is not a lsb file for the drivers installation. What could I do to solve this problem?
Comment: Possible Duplicate: http://askubuntu.com/questions/763157/ubuntu-16-04-installing-epson-driver-fails-on-lsb-3-2
Answer: All I had to do is run this command before adding a printer and the printer is recognized immediately
<code>sudo apt-get install printer-driver-escpr
</code>
The solution was provided on http://askubuntu.com/questions/763157/ubuntu-16-04-installing-epson-driver-fails-on-lsb-3-2 as pointed out by @AntoniosHadjigeorgalis.
Comment: This also work with Ubuntu 20.04.
Answer: Add Ubuntu Trusty repository via system>software update>other software install lsb and then remove the repository. You can install the driver. This is the only way now till a solution is brought up by Canonical. The lsb files work in Xenial and even if one does an update from Trusty to Xenial with lsb installed, they are left behind and fully functional.
Comment: could you please specify or write a more detailed explanation please? I recently installed Ubuntu and couldn't follow all of you steps. Many thanks beforehand.


What is a phenomenological perspective?

Question: I have seen in answers on this site (about consciousness in connection with rebirth) that Theravada adhere to a phenomenological perspective on consciousness. Can anyone explain for me what it means to have a phenomenological perspective? And which schools does not have this perspective?
Answer: Generally, "a phenomenological perspective" refers to phenomenology as expounded by Husserl, and so forth. It is a way of speaking that is typical of contemporary students. It refers to a perspective that underlies the manner in which phenomena appear to one's consciousness, or (a step further) the aspects one's consciousness take.
Therefore, in relation to 'lower rebirth', a so-called phenomenological perspective would approach the way one experiences suffering. The aspect one's consciousness takes when it is subject to this or that suffering.
Generally, such a perspective entails suspending facts and factual inquiries (as in "let us not take rebirth altogether as a fact or a non-fact, and let us not bother with determining whether there is indeed rebirth"). When one suspends all judgments about the supposedly external world (or its quality of being external), that suspension is called epokhē, an ancient Greek term.
From that viewpoint, a phenomenological perspective relates to a form of skepticism.
Some people take another stand by even negating (not just suspending) such or such a phenomena as a fact, as in: "there is no such thing as rebirth and hells, but that doesn't matter because we might very well experience the world in a hellish way". This amounts to a form of criticism.
Answer: In Buddhism there are:

Concepts or mental construction - pannatti
Atomic, indivisible constructs - paramattha

If something is a mental construct it should be constructed in the mind of a being using the atomic building blocks. These constructs form as reaction to stimuli which is felt through consciousness. The related constructs are also felt and known though the mind sense door. Also consciousness need to be directed to the object which needs feeling or experiencing. Since there needs to be an observer with consciousness to know and feel phenomena you can say "Theravada adhere to a phenomenological perspective on consciousness".
Answer: Our everyday perspective is what I call "the Fish-in-the-tank Perspective" (or more formally "the Agent Perspective"). There are all these fishes in the tank, competing for resources and occasionally making love or fighting, and we identify with one of them.
Instead, the Buddha offered a perspective I call "phenomenological reductionism". Everything is reduced to the experiences of five senses and "the inner eye" (mind). Switching from the fishtank perspective to the phenomenological perspective helps the student get away from the focus on chasing some external objects and avoiding others - and to focus instead on one's own reactions, emotions, mindstate etc.
So instead of the objects being "real" and your reactions being involuntary "caused by the objects" we flip the perspective and take ownership of our reactions, while reducing the objects to merely projections of our interpretation. The idea is that this way we can 1) optimize our behavior because we now can modify our reactions instead of being driven by the objects and 2) we can control our own level of happiness independently of what happens in the external world.
The phenomenological perspective plays the dominant role in Theravada and Yogacara schools. This is not the only perspective utilized in Buddhism though - there are also the "Dharma Path perspective" (karma, rebirth, levels etc.) used for beginners - which is really just a modified version of the fishtank perspective; as well as the global/objective/non-dualistic perspective which in Early Buddhism surfaces as the practice of the Four Immeasurables and the Three Marks of Existence, culminating in the attainment of the "divine eye" (dibba-cakkhu) - and in Vajrayana as the lower levels of Dzogchen. Then there is the perspective of Emptiness - or perspective of no perspective - famously cultivated as Prajnaparamita and on the higher levels of Dzogchen...
So in (Mahayana?) Buddhism the perspective is not something dogmatically declared to be true - it is used as a tool. This pragmatic attitude to perspectives is itself a perspective as well, cultivated e.g. within the Mahamudra tradition - as much as I can assume to understand it.
But yeah, coming back to what I said in that comment - what I meant was, that Theravada (within the larger perspective of phenomenological reductionism) specifically as pertains to explaining "consciousness" - sees it as a linear single-threaded sequence of experiences discussed exclusively in the first-person's perspective. In this sense, any idle talk about rebirth should be seen as a mere slippage back into the fishtank perspective.
My point in that discussion was that from errr.... my perspective, consciousness is not a single threaded series (santana) but rather a network of influences spanning time, space, and a number of media - some of which happen to be sentient beings. So from this perspective, consciousness is not one or many, in fact it's not an entity at all - it is a name for an activity of imprinting/reflecting/influencing that takes place in the world at large.
Answer: My assumption is that this would have something to do with the Theravada's reluctance to speculate on ontological matters, preferring instead to investigate consciousness as it is experienced while bracketing any metaphysical or ontological questions.

What is a phenomenological perspective?