Solving $e^x = 6x$ for $x$ without a graph.

Question: Throughout my high school career I was always told that an equation of this sort ( $e^x = 6x$ for example) couldn't be solved algebraically. However I feel that there may be a way (and you may be out there saying "of course there is a way") I know that it can be solved graphically, but is there any other way(s) to solve this equation: $$e^x = 6x$$
**Without graphing or using a equation solver **
Comment: @WaveX Have you tried the newton-raphson method ? 2 can be choosen as the initial value.
Comment: What you were told is, roughly speaking, correct. The closest you can get to an 'algebraic' solution to that equation would require the use of some Special Function in order to isolate the $x$ you intend to solve for (because it occurs in an exponent in one place, and not in an exponent elsewhere).
Comment: No, this is a [transcendental equation](https://en.wikipedia.org/wiki/Transcendental_equation).  It can be solved approximately through numerical methods.
Comment: @Justin Benfield I assume you are referring to the Lambert W function? Granted I haven't learned enough about it yet to know how it works.
Comment: If your going to accept lambert w though, then the trick is to let $-u=x$ and continue from there.
Answer: The term "solved algebraically" is a bit tricky, because you have to specify what functions are permitted in the "algebraic" solution. For example, if you don't allow the square root function, then even the equation $x^2 = 2$ can't be solved algebraically.
So, when people discuss equation solving, they usually talk about solutions expressed in terms of "radicals", which includes square roots, cube roots, and so on. And the use of simple trig functions (like sine, cosine, tangent) is usually permitted, too.
With these sorts of restrictions, equations like $e^x = 6x$ can not be solved "algebraically" -- there is no formula for the solution. I believe there are proofs of this; certainly one can prove that polynomial equations of degree higher than four can't be solved by radicals. But the proofs would be difficult to understand unless you have a good mathematical background.
In practice, if you just want to calculate a solution, the existence (or not) of an algebraic method doesn't matter very much. You can always use numerical methods, like the Newton-Raphson algorithm, to find roots, instead. And, in fact, even when formulae do exist, people still use numerical methods, sometimes. For example, there are formulae giving the roots of cubic and quartic equations. But they are complex, and it's difficult to go through all the computations without numerical errors building up. So, numerical methods might give more accurate answers.
Comment: I particularly like this answer because we generally think of "solvable algebraically" to mean through elementary operations like addition, subtraction, multiplication, and division.  But division itself can be very "difficult" to perform...usually we gloss over this with the rational numbers, e.g. $1\div 3 = \frac{1}{3}$.  If you think about how to get the decimal value of $1\div 3$ it's not all that dissimilar to how you would find the solution to $e^x = 6x$ via an iterative method such as [Newton's method](https://en.wikipedia.org/wiki/Newton%27s_method).
Comment: @Jared --  Yep, as soon as you start using a computer, almost **everything** is an approximation. The approximations used in doing division or computing square roots are somewhat hidden, so it's easy to overlook them, as you say. The approximations involved in Newton-Raphson methods are more visible, but they are not necessarily less accurate or more dangerous.
Answer: You can use the Lambert-$W$ function to write an "algebraic" solution, or at least an 'explicit' solution. As pointed out in the comments, let $-u=x$:
$$e^{-u}=-6u\Rightarrow\frac1{e^u}=-6u$$
$$\frac1{ue^u}=-6\Rightarrow ue^u=-\frac16$$
From the definition of the special function, $ze^z=k$ can be written as $z=W(k)$, and thus:
$$u=W\Big(-\frac16\Big)$$
$$\bbox[10px, border:1px solid black]{\therefore x=-W\Big(-\frac16\Big)}$$
Comment: Thanks for the step by step answer. There's a small typo in your second line though, "$ue^e$" I'm guessing should be $ue^u$ :)
Answer: I am a fan of fixed point iteration because I find it easy to set up.  You want to work your equation into the form $x=f(x)$ where the derivative of $f(x)$ at the root is small and certainly less than $1$ in absolute value.  Then pick a reasonable starting value for $x_0$ and iterate $x_{i+1}=f(x_i)$.  As logs are slowly varying I would write this as
$$x=\log (6x)=\log (6) + \log (x)$$
A starting value of $x_0=\log(6)$ looks reasonable.  After a couple dozen iterations in a spreadsheet (love copy-down) it has converged to about $2.833148$


Should I create a own .h file for my protocol and are there naming conventions for them?

Question: When I create a protocol, I was used to put it right into the .h from a class that this protocol belongs to. But what when I want a pretty "general" protocol that a lot of classes might use? Would I make a .h file for this protocol only? And if so, are there special naming conventions to distinguish it from a class header file?
Answer: I think whatever is the clearest, most obvious way of doing it is the "right" way. In the case you describe having the protocol in its own header file probably does make sense.
There's no generally accepted naming convention for protocols so, again, call it something that makes sense.
Answer: Yes if it's a general thing that will be shared, put it in its own .h file. As for naming, just use the standard TypeName case for the protocol, and typename.h for the file, like you would for other types and classes.
Answer: For avoiding name collision, as would occur with NSObject class and protocol, I name the header file of a protocol with the Protocol suffix:

class: OWNWhatever.h
protocol: OWNWhateverProtocol.h

But if you plan to use your protocol with several classes, such name collision is not likely to happen.


Does "I'm staying in Dallas through April" mean until April 1 or until April 30?

Question: So, this is embarrassing ... I'm a native English speaker, and someone told me they're "staying in Dallas through April." Does that mean they're leaving Dallas April 1 or April 30? This post addressed the question, but it only got one answer, and I'm trying to figure out if there are multiple interpretations to this. Thanks!
Comment: Since '1 through 10' includes 10, I would assume April 30 is included. But I've always found it a weird phrase.
Comment: This phrase lacks precision, so it doesn't really tell you when he is leaving.  I would guess that he would most likely be in Dallas through at least part of April, but not necessarily all the way until the 30th.
Answer: I would say up to April 30. The month mentioned is included. Merriam-Webster is an authoritative dictionary of US English, and they give this as one of the meanings of through:

4—used as a function word to indicate a period of time:
such as [...]
c: to and including
Monday through Friday

Through (Merriam-Webster)
Lexico (Oxford Dictionaries) gives the same 'including' meaning:

5 North American
Up to and including (a particular point in an ordered
sequence)
they will be in London from March 24 through May 7

Through (Lexico)


Running out of heap space

Question: I am having a heap space problem. My program is simple. There are two actors (send & receive) "send" actor is passing 10000 objects per second to "receive", and receive publishes those objects. the receivers received object is  being saved in the container but the container is being emptied every second. So no chance the container is running out of space. Now after 420000 objects my eclipse shoes an error saying " ioconsole updater has encountered problem" . And when i goto into details i see the error Internal error :: Java heap space
I have tried increasing the heap size.
My Heap size is 8096m and maxpermsize is 4096
I am monitoring my code using visualVm and i am noticing that it is not exceeding the heap size atall. Totally blank as how to fix the problem.
Can some one let me know what other possible scenarios can lead to such errors.
Answer: IOConsole is an eclipse class, not your program's. Are you printing to System.out a lot? Under Window > Preferences search for "console". Set some sort of limit for all the console buffers. Try printing less output from the program. Maybe log to a file instead.
Comment: Yea i was not able to find the printf lines because it was done by lagback.xml file. As changed the status in that file the log lines got reduced and the error got reduced. Thanks a lot..
Answer: This problem has occured due to the buffer size in console.
Solution :
Right Click the Console -> Preferences
limit the console.
Answer: You can add the following JVM args to give you an idea of the memory usage and what the GC is doing:
<code>-Xloggc:/tmp/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
</code>
Answer: I encountered the problem and I tried to solve it by changing heap and buffer settings in eclipse. However I couldn't solve it. Then I noticed there is a memory leak in my program and the number of threads increase in time. The problem was solved after I had fixed the bug. I think memory leak is not the most probable reason for it but it should be considered.

Running out of heap space


Assuming equal changes in terms of percentage points for two populations. Very easy question, but a reference needed

Question: How to explain to non-statisticians that if we have e.g. obesity rate equal to 40% in men and 12% in women, the target values in men and women in 2030 should NOT be equal to 38% in men and 10% in women? Do you know any paper/guide that would explain it to policy-makers that one should take into account the baseline level, when assuming the target values? Actually, I would like to show that time series of social indicators are more likely to show exponential trends instead of linear trends. Any help will be appreciated.
Comment: Why do you think the rates can't decrease? Second, what is a forcasted target? A forecast is a guess; a target is a wish.
Comment: I meant target values. Actually, I would like to show that it is unfair to demand decrease of obesity rate by 2 percentage points both in men and women, since the baseline levels equal to 40% and 12%, respectively. I would like to justify the need of assuming a relative reduction, as Stephan Kolassa stated.
Comment: That's a huge difference, and you should edit the post to reflect this.
Answer: First, there is a difference between a forecast (what we expect to happen given specific circumstances) and a target (what we want to happen, and are prepared to change circumstances to achieve).
Second, to your question: I believe that this point is so trivial that nobody would publish anything on it. And it should be easily explainable. I doubt that someone who will not or cannot follow the explanation would be convinced by a reference.
You may have more luck in framing the development differently. "Obesity incidence will be reduced by 10% in both men and women" is a relative reduction and translates into a reduction from 40% to 36% in men and from 12% to 10.8% in women.


Mineable Tokens? Is it possible? If so, how can I make one?

Question: Just wondering if you could make a ethereum token that is mineable. I saw this link, but don't really know about it and i dont know anything about solidity. Can someone please help me? Thanks, Crypthusiast
Answer: Yes, you could build this quite easily with OpenZeppelin along with EIP 918
Take a look at EIP 918: Mineable Token Standard. Proposed interface:
<code>contract ERC918  {

   function mint(uint256 nonce) public returns (bool success);

   function getAdjustmentInterval() public view returns (uint);

   function getChallengeNumber() public view returns (bytes32);

   function getMiningDifficulty() public view returns (uint);

   function getMiningTarget() public view returns (uint);

   function getMiningReward() public view returns (uint);

   function hash(uint256 _nonce, address _minter) public returns (bytes32 digest);

   function _reward(address _minter) internal returns (uint);

   function _epoch() internal returns (uint);

   function _adjustDifficulty() internal returns (uint);

   event Mint(address indexed from, uint rewardAmount, uint epochCount, bytes32 newChallengeNumber);
}
</code>
Comment: Can you make it so i can copy and paste into it, i am a noob and dont know how
Comment: The funniest request I have seen :)


Is it advisable to use a therapeutic stretch band as a yoga prop?

Question: Is it recommended (or discouraged) to use a long therapeutic stretch band instead of a belt-style band for yoga poses?  As an example, is innovation with the strap a bad idea, such as wrapping it around the heel in revolved head-to-knee pose?
Comment: Usage for pillates prop not yoga.
Answer: If you want to create resistance in a strengthening exercise, then obviously it is a band. If you are doing a static stretch, then a strap is usually best because it gives you more control over your position.
Answer: There isn't much difference, and it depends entirely on what you want to achieve.
Straps are useful, when there is a static pose, and you want to "close the chain". For example, if you can't reach your toes while bending forward with good form, instead of compromising the spine, the straps add length to your hands and provide stability in the pose. A stretch band will also work for this purpose, but will provide slightly less stability. I use resistance bands in this way and the difference to using a strap is minor. Even if the yoga poses are static, they are usually active, that is, certain muscles are engaged, and both a strap or a stretch band will provide something to resist against.
The whole point of a stretch band is, that it can change length and provide resistance against movement. It is most useful if you have some dynamic stretches in your routine.


Why does an unhinged body rotate about its centre of mass?

Question: If a force is applied to a body which does not act through its centre of mass, it rotates about its centre of mass and not any other point. Why?
Answer: It happens I think because rotation about axes which do not pass through the center of mass are usually inherently unstable and hence the rotation tends to "decay" to a more stable axis, i.e the one passing through its center of mass. Also, the moment of inertia of a body is usually the lowest through a certain principle axis through its center of mass.(Moment of inertia is analogous to mass in rotation. i.e. more moment of inertia for a certain amount of force force implies lesser angular acceleration) A simple proof for this is:
The moment of inertia $I=mr^2$ for a point particle at a distance r from its axis of rotation. Now consider two particles separated by some distance $l$. Assume an axis of rotation passing through the line joining these both, at a distance $x$ from the first particle, and $l-x$ from the second.
then the moment of inertia about this axis is $$I=Mx^2 + M(l-x)^2$$
Differentiating with respect to $x$, we get: $$\frac{dI}{dx}=2Mx-2Ml+2Mx$$ If you want to find the minimum value of x needed for the lowest of moment of inertia, equate the expression above to zero. This gives $I$ to be minimum at $$x=l/2$$ from the first particle which is the position of center of mass of the system. The moment of inertia is always lowest through an axis through the center of mass. (True for all rigid bodies.) and hence the most stable rotation is achieved through an axis through the center of mass.
Comment: The answer I accepted leads me to believe that rotation of an unhinged body about a point other than its centre of mass is impossible(because the velocity of the centre of mass would vary in the absence of an external force). Hence, I would think of rotation around axes other than the COM to be not just unstable but impossible.
Comment: Yes, but that is true only for objects which have no constraint on them. for example a door hinged would only rotate about the hinge when a force is applied to it. nonetheless, it is true in an isolated unconstrained object.
Comment: Exactly. An unhinged body in other words.
Comment: Yes. I hope the answer helped though anyway.
Comment: @HritikNarayan  I was also searching for the answer to this question. In fact even I had thought that M.I about C.M should be least and the body should naturally rotate about a point of least M.I , just as in translation the body of greater mass wouldn't be affected as much as a body of less mass by the same force. I was just thinking how to prove it mathematically. And I found it here. Great Answer !!
Comment: why is that the body would want to decay to rotating about the axis with least moment of inertia?
Answer: The idea is that if there are no forces on an object, then no matter how it rotates, its center of mass must move at a constant velocity. Then in the frame of the object, the center of mass appears stationary and everything else rotates around it. In general this cannot be said of any other point in the object.
To see that the center of mass moves at a constant velocity, remember that the center of mass $\renewcommand{\r}{\mathbf{r}}
\renewcommand{\rcm}{\r_\textrm{cm}}
\rcm$ is defined by $\rcm = \frac{1}{M}\int \r \rho d \r$, where $\rho$ is the mass density distribution of the object and $M = \int \rho d \mathbf{r}$ is the total mass of the object. Then the center of mass velocity $\renewcommand{\a}{\mathbf{a}}
\renewcommand{\acm}{\a_\textrm{cm}}
\acm$ can be found by taking two time derivatives: $\acm = \frac{1}{M}\int \a \rho d \r$.
Now the integrand $\a(\r) \rho(\r)$, by newton's second law must be the total force $\renewcommand{\F}{\mathbf{F}}\F$ at the point $\r$. This force has two contributions: an external force $\renewcommand{\Fext}{\F_\mathrm{ext}}\Fext$ and an internal force $\renewcommand{\Fint}{\F_\mathrm{int}}\Fint$. Thus we have that $\a(\r) \rho(\r) = \F(\r) = \Fint(\r) + \Fext(\r)$. Plugging this back into our expression for $\acm$, we find $\acm = \frac{1}{M} \int \Fint(\r)+\Fext(\r) d \r = \frac{1}{M} \Fext + \frac{1}{M} \int \Fint(\r) d\r$, where $\Fext$ is the total external force.
Now the internal force comes from pairwise interactions with other parts of the object. So if $\Fint(\r, \r')$ is the force of the piece of the object at $\r'$ on the piece of the object at $\r$, then the total internal force at $\r$ is given by $\Fint(\r)=\int \Fint(\r,\r') d \r'$. Then the total contribution of $\Fint$ to $\acm$ can be written $\frac{1}{M} \int \Fint(\r) d\r = \frac{1}{M} \int \Fint(\r,\r') d\r' d\r$. But switching the order of integration, we find $\frac{1}{M} \int \Fint(\r,\r') d\r' d\r = \frac{1}{M} \int \Fint(\r,\r') d\r d\r'$ by Newton's third law we have $\Fint(\r,\r')=-\Fint(\r',\r)$. Combining this with the previous equation we find $\frac{1}{M} \int \Fint(\r,\r') d\r' d\r = -\frac{1}{M} \int \Fint(\r',\r) d\r d\r'$. But then relabelling the dummy variables on the right hand side, we find that $\frac{1}{M} \int \Fint(\r,\r') d\r' d\r = -\frac{1}{M} \int \Fint(\r,\r') d\r' d\r$. which implies that $\frac{1}{M} \int \Fint(\r,\r') d\r' d\r =0$. Therefore $\frac{1}{M} \int \Fint(\r) d\r =0$, and so $\acm = \frac{1}{M} \Fext $. Therefore if the external force is zero, the center of mass moves with constant velocity.
Comment: dont we consider the case where an axis passes thru the point of contact (an instantaneous axis of rotation) for a cylinder performing pure rolling on a surface
Comment: @SchwarzKugelblitz He was basically asking about how the center of mass is always the only point in a rotating object that moves with constant velocity. You are right that at a given instant the contact point on the cylinder is stationary and the cylinder rotates about this point, but as you continue watching this point, it traces out a curved path (a cycloid in fact). However, the center of the cylinder moves with constant velocity.
Comment: I see. Thanks for the reply!
Answer: It does happen because, in the free condition only the Centre of mass is the point which can provide the necessary centripetal forces for the rotation of body.


How to assign static IP address to Raspberry Pi Model 3+ connected via Wi-Fi?

Question: I recently finished setting up my Pi with Raspbian Stretch lite and configured the Wi-Fi successfully.  I was trying to assign a static IP address to it, but all I can find are tutorials for LAN not over Wi-Fi connections.  I was hoping to take the easy path and assign the IP through my router, but it doesn't have that option.
Answer: It is basically the same way you would do it for your ethernet interface, you simply need to use the name of your wireless interface (presumably) wlan0.
In Raspbian stretch (lite), if you add this part to your /etc/dhcpcd.conf you should be fine:
interface wlan0
static ip_address=192.168.1.99/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

Of course you need to adapt the IP-addresses to your specific setup.
Comment: Did you at any point activate ssh on your Raspberry Pi? Per default it is disabled.
Comment: Hey thanks for your answer, finally i decided to connect the pi directly to my router via ethernet, but now when i try to ssh into it im getting permission denied when typing the password... Any idea how to fix this without the use of a monitor?
Comment: Yes i did... now its all working smoothly.


Is the a way to project surface cuts through the entire object?

Question: I am trying to cut this block mold at the lines I made.  The issue is that I can only cut the surface, and can't figure out how to cut all the way through, including the inner geometry.  Is there a way to project these lines through the entire object?
Answer: Use the Knife Project tool: https://docs.blender.org/manual/en/latest/modeling/meshes/editing/subdividing/knife.html#knife-project Make sure you turn on Cut Through option

.. Or the Knife Tool and hit Z key to make sure to turn on Cut through:
Comment: Thanks but I had tried both of those already with no luck. It may be too complex of a file. Thanks anyway!


Why is grass green?

Question: How come grass isn't blue or pink, but apparently, it is according to this scientist it is every color but green. I also got told by my teacher that grass is only green and no other color. So I am confused, but with an answer please try and be simple.
Comment: I'm voting to close this question as off-topic because it isn't a question about physics
Comment: As always, related [xkcd](https://xkcd.com/1818/) with caption text: *If you ask "why are leaves green? the usual answer is "because they're full of chlorophyl, and chlorophyll is green, even though "why does chlorophyll scatter green light?" is a great question too.*
Comment: Your link to "this scientist"? also have you checked out chlorophyll ?
Comment: Chlorophyll absorbs all colours and does not remit them except those around the green part of the spectrum.
Comment: This is not just about grass being green. It's about what you could call the 'every-color-but' theory of color. Something looks like its color is X? Actually it's every color but X! The argument is that something looks X because it reflects X-colored light, while absorbing Y-colored, Z-colored... But why does absorbing Y- or Z-colored light mean that the object's 'real color' is Y or Z? Is there some physical or color-theoretic deep justification for this way of speaking, or is it just a popular contortion of words that sounds cool because it's paradoxical?
Comment: Go check your "the scientist" again.  Did they say it **is** every color but green, or did they say it **absorbs** every color but green.
Answer: Plants contain chlorophyll for harvesting energy from sun-light.
From Wikipedia: Chlorophyll:

Chlorophylls absorb light most strongly in the blue portion of the electromagnetic spectrum as well as the red portion. Conversely, it is a poor absorber of green
  and near-green portions of the spectrum, which it reflects, producing the green color of chlorophyll-containing tissues. Two types of chlorophyll exist in the photosystems of green plants: chlorophyll a and b.

This can be seen from the absorption spectrum of chlorophyll a and b:

So your teacher's statement "grass is only green and no other color" is somewhat over-simplifying.
More precisely you can say: grass is a mixture of cyan/green/yellow/orange color (wavelengths from 490 to 610 nm).
Answer: Plants require the absorption of light to sustain them. This means that their leaves contain chemicals that absorb light and turn it into chemical energy that fuels the plant, in a process called photosynthesis. The most common of these photochemicals is called chlorophyll. It absorbs most colors of light in the visible spectrum except green, so the light that passes through a leaf or reflects off it has a strong green tint.
Answer: It is not a coincidence that grass is green. Of course chlorofyl does absorb little green light but that is hardly an explanation. I can't find the reference right now but there was a study that argued that it serves to balance the power generation over the course of the day. In the morning and evening the light us more reddish. In the middle of the day the green light peaks. By avoiding this peak plants, so it was argued, are more efficient. Compare to a setup of solar cells. By pointing half of your cells more to the east and half more to the west  a more constant power is generated, allowing a less powerful converter so a gain in efficiency.
Comment: Interesting point of view. See [Why did chlorophyll evolve to be green as opposed to black?](https://www.quora.com/Why-did-chlorophyll-evolve-to-be-green-as-opposed-to-black-which-would-absorb-more-energy). It gives some more reasons why nature might have decided not to use green light for photosynthesis.

Why is grass green?


Is it possible to convert high rotational speed air vortices into high speed quasi-laminar airflow and how to do it?

Question: I am no expert on the fluid mechanics field, but I am interested in generating high rotational speed vortices for my little research project. I believe that if a high speed airflow coming out from a convergent nozzle is made to impact at an oblique angle a  low speed airflow coming out from a divergent nozzle, the result will be vortices at high rotational speed. Is that possible and if so how can I obtain a quasi-laminar airflow out of these vortices? Assume airflow velocity lower than 0.3Mach.
Comment: What are you trying to achieve? It would be great if you could edit your question and add information about your experimental setup, why you need to use converging and/or diverging nozzles, what you mean by quasi-laminar airflow, and why you need it.
Comment: Dear Al Nejati. Please see my post below.
Answer: Thank you for your most valuable suggestions. I have learned that at the tip of an airplane wing vortices form when high pressure low velocity airflow below the wing tries to move to the low pressure higher velocity airflow above the wing. Also, by using compressed air in vortex tubes it is possible to generate vortices that can rotate at 1,000,000 revolutions per minute. At least one  wind turbine produces these vortices (https://www.youtube.com/watch?v=WB5CawKfE2M), but it does not take advantage of the high rotational speed of these vortices because they are generated behind the turbine blades instead of their front.  I would like to generate the vortices before they impact the turbine blades. On the other hand, it is well known that the lift force generated on an airplane wing or on a wind turbine blade is proportional to the square of the airflow velocity provided the airflow is laminar, i, e., non-turbulent. I believe it would be useful to convert high speed vortices into a laminar or quasi-laminar airflow and the to use the latter to increase the lift force either on aircraft wings or turbine blades.  By quasi-laminar airflow I mean an airflow that has passed through the space. between very thin sheets and very closely separated among them, somehow straightening the streamlines. In order to generate the vortices, I would make the airflow pass through a convergent nozzle and through a divergent nozzle but following separate paths, and making the two output airflows collide at a certain oblique angle.


Why excited electrons come back to ground or some intermediate level?

Question: Everything I have read did not explain it at all and just stated the fact. So WHY (what specific forces involved) excited electron spontaneously comes back to ground energy levels. Is it nucleus pulling electron inwards, so electron can not hold on in new energy level because part of energy was emitted while traversing orbital levels, or something else?
Comment: Some comments removed. Friendly reminder that comments are for improving the question; if you'd like to post a brief answer, then post it as an answer.
Answer: It is the principle of minimum total potential  energy,  carried to the quantum mechanical level. Principles and laws are extra axioms necessary to use mathematical equations to model data and observations, and predict new set ups.
It is a basic observation that water flows downhill, if it can, after all. Electrons if a lower energy state exists will decay into it emitting the appropriate energy photon for energy conservation (another law).
Comment: Do you think the wavefunction and the probabilistic interpretation of quantum mechanics could answer this question too? I mean, intuitivelly i think it makes sense.
Also came to my mind the Feynman phase interpretation, is it possible that the phase just add construtivelly to make  more strong chance the electron return to ground state?
Comment: The quantum mechanical theory and its extension, quantum field theory,  with its laws, postulates and principles was chosen *because* it fitted the observations. Ov course it gives a mathematical cause, it was constructed to do so.
Comment: Thank you for your answer. I bet physicists will understand it ;). I am looking for simpler terminology answer.
Comment: Maybe the extra energy of excited electrons is carried away by already propagating photons (which exist everywhere at all frequencies). The instant the energy is carried away the electron falls to a lower state. when the electron is excited again, another photon (already coming from a random direction), picks up the energy and continues on, in the same random direction. Maybe
Comment: @BillAlsept not in the  standard model theory of particle physics https://en.wikipedia.org/wiki/Standard_Model
Comment: @annav Yeah I know, there's nothing standard about new ideas. That's why I said maybe.
Answer: Simply electrons want to minimize it's (potential)energy. Why it wants to minimize its energy? Because we have defined energy in such a way that when a system is at equilibrium, or steady state whatever you say, it's energy is lowest.
Now when we heat some gas and light comes out of it due to electrons spontaneously going the lower state from upper state. Now this may create a question like when energy is given then why not every electron takes energy, goes to higher state and rest there where it is, and resulting no emission. But when we speak of such situation then talking about one electron of a single atom is not the correct way of saying things, when the number of electrons is very high then it is possible that even you continuously give the system energy, some electrons will take up that energy and immediately afterward come downward giving up those energy in form of light. It is a statistical process.
Thus summing up electrons do tend to come to ground state, due to minimization of (potential)energy, but not every electrons and every second, there is a statistical description , that how many electrons will spontaneously come to ground state in what time.
Answer: Classically, if a charge accelerates, it will emit energy out into the electromagnetic field as radiation. This remains roughly true for quantum particles: the electromagnetic attraction between an electron and the nucleus accelerates them and therefore they tend to emit emit energy as particles of radiation (photons).
The idea of energy levels in an atom comes from ignoring the possibility of photon emission in the mathematics, keeping only the attraction between the electron and nucleus. In this picture, the excited states are indeed stable and never decay. Adding the possibility of photon emission makes all the excited states into "resonances", metastable states with "long" lifetime but that eventually decay. But adding this possibility does not change the possible ways to arrange the electron and nucleus in the absence of photon, and the (average) energies of such states also doesn't change much. Thus, no new states appear below the ground state, so the ground state atom cannot decay by photon emission. I.e. the ground state atom has no lower state to go to upon photon emission, so photon emission cannot happen even though the charges are constantly being accelerated.
Note that the full theory of photon emission is incredibly complicated: it requires quantum field theory and cannot be handled by basic quantum mechanics. Handling bound states (like atoms) in quantum field theories is also particularly difficult. I don't think a full treatment exists for arbitrary atoms, and finding one for even just hydrogen may be hard.


when calling "JRequest::get('FilterForm')" result is empty

Question: When calling the method <code>$this->filterForm    = JRequest::getVar('FilterForm');</code>, I get an empty result.
But checking the com_banners component on the same system shows a result. What can I do to get it working?
Comment: `JRequest` is deprecated and soon to be removed. Please use this: https://docs.joomla.org/Retrieving_request_data_using_JInput
Answer: This is the way to retrieve an input:
<code>$jinput = JFactory::getApplication()->input;
$this->filterForm = $jinput->get('FilterForm', 'default_value', 'filter');
</code>
TIP: Take into account that if your don't specify a default_value, it will return null when no value is detected. If your don't specify a filter, it will apply a strict filter, CMD, for commands (It allows a-z, 0-9, underscore, dot, dash. It also removes leading dots from result).
Comment: The result is still NULL (when I remove the 'filter' and the 'default_value'). I think, I have something completly wrong. Thats why I get no result.
Comment: @DreiBaer - In which case the issue will be with a different part of your code.
Comment: WHat do you mean with "case"? I have implemented it Component-File -> Controller (with constructor) -> View.


Confusion in symbol of subset.

Question: If every element of set $A$ is an element of set $B$ then we say that $A$ is subset of $B$. $A$ is said to be proper subset if $A$ does not equal $B$.
My question is -
whether the symbol we use to show subset is  same as that for proper subset? I have seen that $A$ is subset of $A$ itself is shown by the same symbol as that for the subset while when we write improper subset, we usually write equal to sign with symbol of subset.
So, please help me to know this.
Answer: I'm afraid the usage varies by author.
Some of the symbols are unambiguous: '$\subsetneq$' always means a proper subset, and '$\subseteq$' means a subset which could either be proper or not.
But the symbol '$\subset$' is ambiguous. For some, it always means a proper subset (identical to '$\subsetneq$'. For others, it just means a subset without regard to properness (identical to '$\subseteq$').
My personal preference is to use '$\subset$' to just mean any subset, proper or not. When I specifically want to exclude the possibility of equality, I explicity indicate this using '$\subsetneq$'.
Comment: I think the "modern way," as implied by the partial-order nature of subsets, would be to use $\subseteq$ for any subset and $\subset$ for proper subset, paralleling to $\leq$ and $<$. But I understand both preferences.
Comment: *Comment:* The conscientious author will indicate the meaning of the symbol where it makes a difference. In my experience, it typically doesn't matter.
Comment: Yes, I suspect it is mostly older text, back from the days of hand-typesetting, which are more likely to abuse the notation. I can't even begin to imagine the typesetting nightmare that was Dickson's History of the Theory of Numbers.
Answer: As @MPW pointed out, $\subset$ is ambiguous.  My preference, therefore, is not to use this symbol at all.  I use $\subseteq$ for "subset" and $\subsetneq$ for "proper subset". So you won't encounter any ambiguities in my papers; as for other people's papers, good luck.
Comment: Do you refuse to publish in journals that require you to use their standard notation and use $\subset$?
Comment: @JiK I don't recall any attempt by a journal to mess up my choice of symbols.  If I knew in advance that a journal will insist on $\subset$, that would certainly decrease the probability of my submitting a paper there, though it might not decrease the probability all the way to zero if there were other good reasons for wanting to publish in that particular journal (e.g., a special issue in honor of one of my friends).

Confusion in symbol of subset.


Why does maximum likelihood estimation for uniform distribution give maximum of data?

Question: I am looking at parameters estimation for the uniform distribution in the context of MLEs.  Now, I know the likelihood function of the Uniform distribution $U(0,\theta)$ which is $1/\theta^n$ cannot be differentiated at $\theta$. The conclusion is that the estimate of $\theta$ is $\max(x_i)$, where $x_1,x_2,\ldots,x_n$ is the random sample. I would like a layman's explanation for this.
Answer: Your likelihood function is correct, but strictly speaking only for values of $\theta \ge x_\max$.
As you know the likelihood function is the product of the conditional probabilities $P(X_i=x_i|\theta)$.
$$L = P(X_1=x_1|\theta) \times P(X_2=x_2|\theta) \times \ldots \times P(X_2=x_2|\theta) $$
We can look at three different cases for your $\hat\theta$ = the estimate of $\theta$ that maximizes the likelihood.
(i) $\hat\theta_1 < \max(x_i)$
Let's say that $x_j=x_\max$. This gives $P(X_j=x_\max|\theta=\hat\theta_1) = 0$, because $x_\max$ is outside the support of the random variable, and so
$$L = P(X_1=x_1|\theta=\hat\theta_1) \times \ldots \times P(X_j=x_\max|\theta=\hat\theta_1) \times \ldots \times P(X_2=x_2|\theta=\hat\theta_1) = 0 $$
(ii) $\hat\theta_2 > \max(x_i)$
Here all the data is within the support so we have $L=1/\hat\theta_2^n$.
Clearly case (ii) is better than (i) because $1/\hat\theta_2^n > 0$.
(iii) $\hat\theta_3 = \max(x_i)$
Once again $L=1/\hat\theta^n$. But case (iii) is better than case (ii) because $\forall a,b:\; a>b>0 \;=>\; 1/a < 1/b$.
So out of the three cases, case (iii) maxmizes $L$. (Note that you can use calculus to show that $L$ is monotonically decreasing for $\theta < x_\max$ if you wish.)
Answer: You asked for an intuitive explanation.  So let's think about what happens when we take a sample $x_1, x_2, \ldots, x_n$ from a uniform $[0,\theta]$ random variable, where $\theta$ is a fixed but unknown parameter.  From the data, we would like to calculate a statistic (a function of the data) that estimates the value of the parameter; moreover, this estimator $\hat \theta$ maximizes the likelihood of having observed the particular sample that we obtained.
Clearly, $\theta$ cannot be smaller than the largest observation we made (or else we could not have observed it!).  But in order to "maximize the likelihood," we also note that $\hat\theta$ should not be unnecessarily large.  For instance, if we observed $x_1 = 2, x_2 = 7, x_3 = 4$, we could pick $\hat\theta = 100$, but intuitively this is not a good estimate--the chance that we observed $2, 7, 4$ given that the true value of the parameter is $100$ is quite small.  It is much more likely that, given the information we have, the true value of the parameter is close to $7$.  In fact, we can show mathematically that the probability of observing the sample given $\theta > \max_i x_i$ is smaller than if $\theta = \max_i x_i$.
We can also characterize $\hat\theta = \max_i x_i$ in terms of sufficiency:  notice that once we observe the largest value, the other values give no additional information about the true value of $\theta$.  So in our example, once we saw the maximum of $7$, the observations $x_1 = 2$ and $x_3 = 4$ are irrelevant for the purposes of estimating $\theta$, because we already know that $\theta \ge 7$.
Of course, we must formalize all of this with the appropriate mathematics, but this is essentially the underlying intuition involved.
Answer: ${}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}$
Answer: A layman's explanation is that you observe realizations of a random variable, whose upper bound you do not know. You have no idea if it is $10$, $42$, $1337$, or so on. The only thing you know is that it is greater than $0$ and less than the bound you're interested in, $\theta$. Intuitively, it makes sense that your best guess is the greatest observation you have. Naturally, $\theta$ cannot be less than the greatest observation you have, because you have something greater than it. But if you would add an arbitrary (positive) number to your greatest observation as an estimate, you could very well exceed the true $\theta$. Thus, you settle for the greatest observed value as your estimate of $\theta$, because that is a pretty good guess.
If you add an indicator function to your pdf, it is even more clear that the likelihood is maximized at the maximum observation.
Comment: Well, if you're a bit bigger than the maximum, then theres less probability (in a small neighborhood) around each of the observations since the density becomes less tall than if you had chosen the maximum, so the likelihood has to be lower than the maximum.


Setting charging limit on MBP?

Question: Is it possible to tweak settings so that the battery will only charge up to 90% -95% and then use power adapter to run ?
A friend told me he was able to set such limits on his non-mac PC so I was hoping there would be a way to do it. From reading I have done online it appears this is better than having a 100% battery most of the time.
I have an MBP 13" 2012 running latest version of OSX ML(10.8.2).
Comment: You might want to try using [Watts](http://binarytricks.com/) - configurable reminders to calibrate your battery, take it off AC after too long, etc.  I found it well worth the purchase price.
Answer: The logic for doing what you want is already hard-coded into the battery and its internal charging circuits. Not only is pretty much every laptop on the market today doing this, but I imagine it's not something you can change, either. (Commenting from personal experience, I've seen this behavior in every laptop I've owned or had loaned to me over the past 6 years-- Two Dells, two MBPs, and a Lenovo)
When it comes to proper care of laptop batteries these days, the only real advice that an end-user can take is

Store the battery in a cool, dry place when it's not being used, and don't heat it up while it's charging.

Yes, that means you probably don't want to use the laptop while the battery is charging.
Pretty much every other detail with regards to charging cycles or the implementation thereof have been gone over by experts that study batteries for a living, and are likely already tailored to your battery far better than any generic internet advice will give you.
Answer: For anyone coming here in the modern era, there are quite a few updates. For one, as of 10.15.5, Apple is introducing Battery Health Management to do this sort of thing automatically: https://www.slashgear.com/macbook-charging-is-changing-as-macos-gets-smarter-about-batteries-16617057/
If you're using a Mac on 10.15 Catalina or newer and you'd like more control, the following two projects will let you set peak charge capacity:
https://github.com/davidwernhart/AlDente
https://github.com/sicreative/BatteryStatusShow
If you're on an older Mac or you're already an Alfred user, I put together a quick workflow that lets you set either 70% or 100%:
https://www.alexwhittemore.com/controlling-macbook-pro-charging-cap-with-alfred/
This post also contains a ton more info on battery charging and options.
Finally, especially in the era of USB-C Macs, options abound for less-powerful charger bricks to charge your machine slower for less wear. I personally use a 61w normally, and only use the 87 if I specifically need the power for a heavy workload. Even 30w might be a good choice for charging overnight. But stick with name-brands: many a MacBook has been destroyed by a no-name 87w USB-C supply.

Setting charging limit on MBP?


Best way to retrieve attachments from MS Exchange

Question: We tried using the JavaMail API for a while, but we sporadically received ArrayIndexOutOfBounds errors documented by this bug report:
http://kenai.com/bugzilla/show_bug.cgi?id=3155
It was marked as fixed, but we continued to have that error actually. Additionally, the performance using JavaMail to retrieve attachments was consistently very slow. On the order of around 10 KB/s even when on the same network as Exchange so we decided to try a different approach.
We found that we were able to get significantly better performance using a Mapi client called MoonRug: http://www.moonrug.com/features.html
This worked substantially better than JavaMail, but we still have errors every now and then connecting to Exchange and downloading attachments (of varying sizes from 3KB to 20MB).
I am starting to question if having Java call Exchange directly is even the right approach for us to take. Does anyone have a recommendation for a better way to do this? We are primarily a java shop, but if there is a different tool or technology that can take emails from Exchange and put them on the file system somewhere for a java process to read and process that is an option for us.
The goal of this application is to take incoming mail on a certain inbox and save them and the attachments to a back end system that users can interact with. We currently do a pull process where we poll the inbox every minute. If there is some way to make this a push process by integrating something into Exchange Server directly to take email and automatically export them onto a file system that would also be an option for us.
Answer: You may want to take a look at DavMail. It's Java based, and it does access Exchange. It may or may not provide you with code you can use. Otherwise, it may allow you to use it as a gateway between your JavaMail-based app and Exchange.


Implementing SAML Identity Provider in Node for Offline app?

Question: We are in process of building a series of apps that will run offline or in very austere environments.  We'll also be integrating with other 3rd party apps.  Many of these will require logins so we're attempting to use SAML to handle login between them.
I found saml2-js:
https://github.com/Clever/saml2
And it seemed like a great starting point for both the SAML Service Provider and Identity Provider - but diving in I now see it does not implement the Identity Provider at all.
I already have a basic SAML Service Provider setup, but we need an Identity Provider that can run offline.  Are there any Node or GoLang Identity Provider libraries we can use to implement this?  If not, another recommendation?
Answer: Passport is the usual Node option but that's client side only.
There are a number of IDP's you can use e.g.:
Free: simpleSAMLphp / Shibboleth / identityserver4
Cloud: Auth0 / Okta / Azure AD
On-premises: ADFS


Migrating PostgreSQL files to new server

Question: We have a Win 2008 server that went down because of cpu failure.  We were running parts of the Atlassian stack (JIRA, Confluence, Stash, and Bamboo) on it using PostgreSQL as the database.  I now have the harddrive from that dead server mounted in to a Win 7 machine as a secondary harddrive.  We unfortunately did not have backups setup.  All of the instructions I see for migrating databases to new machines involve running PostgreSQL cli programs against a running PostgreSQL instance, but in my case all I have is a folder not a running PostgreSQL server.  I would like to be able to install PostgreSQL on the Win 7 machine, somehow get the data migrated over to the new PostgreSQL installation and off of that secondary drive.  Then I would like to export the data out using the standard procedures and move it to a new production server or possibly export using the Atlassian backup tools if we end up moving the data in to the Atlassian cloud service where they use who knows what db engine.  Either way though I need the data off the olddrive and running in a new PostgreSQL server to move forward.  Anyone have any ideas?
Answer: Install the latest minor release of the same PostgreSQL major version - e.g. if you were using 9.3.1 before, install 9.3.9. Make sure it's the same architecture - i.e. if you were using a 32-bit PostgreSQL before you must install 32-bit PostgreSQL now.

Stop the service using the services control panel (services.msc).
Delete %PROGRAMFILES%\PostgreSQL\9.3\data.
Copy the old data directory to that location.
Get properties on the data directory and in the security tab recursively grant full control to NETWORKSERVICE.
Start the service using services.msc
immediately set up backups.
Comment: While not the first to respond (Thanks Joishi!) this seems to be the most clear description for people with similar issues so I am marking this post as the solution.  I actually did the migration before seeing your post and it appears to have worked (as far as I can see dbs) without the access right change but I will go back and make that change just in case.  Thanks for the post.
Answer: It's been a while since I've done anything like this, but last I recall - If you have ALL of the corresponding files, you should be able to copy them and start up the server .. it will go into recovery mode to validate that it's got everything that it needs.  Of course, if it finds that it's missing something, it will likely either not start or complain in the log files that it's missing something (depending on the severity of what it's missing).
The most likely files that you MAY NOT HAVE would be the WAL files (by default stored in the pg_xlog directory .. but could be different if it was configured that way).
If the configuration was different, you will need to make sure that the new environment is suited to match the configuration that postgres is expecting (for example - if the WAL files were located in a different place than default).
The postgres configuration files may also not be where you would expect them ... they COULD be in the base directory of the database, or they could be in the postgres config directory (which I do not recall the exact location of it - you can look in the /etc/init.d/postgres-9.3.sh file, iirc)
Comment: The one thing I can tell you is that I have a standard Windows install of PostgreSQL 9.3.  I almost certainly took the default options for everything.  Theoretically just the CPU went down and the harddrive should be fine so all the files should be there and in the standard locations.  I see 3 files in that pg_xlog dir under the data dir which appear to be the WAL files.

So you are suggesting that I install 9.3 on my Win7 box and replace the data dir in that new install with the data dir from the old install then the dbs will be rebuilt from the WAL files?
Comment: You will need to STOP the postgres service before doing that .. but yes.  Default directory on windows is `C:\Program Files\PostgreSQL\9.3\data` .. replace this whole directory, and I believe it should start up with everything that was in the old database.
Comment: It looks like Craig Ringer has a more complete answer above (basically the same as mine, but with more specific details).  Good luck.  :)


Is there any way to get AutoHotKey or IronAHK working?

Question: I am very interested in getting AutoHotKey, the windows program for automation of keystrokes, working under Ubuntu. So far I have installed Wine, but am unable to use any of my previous windows scripts. Are there any recommendations?
Comment: see [here](https://unix.stackexchange.com/a/710969/103120) for an up to date answer
Answer: Autokey is a linux equivalent of AutoHotKey for Windows.
(Update 01May16) The above page no longer exists. There is now a port of it to Python 3 on Github.
Some of its features

KDE and GTK versions available, making AutoKey integrate well into any desktop environment.
Write Python scripts to automate virtually any task that can be accomplished via the keyboard
Built-in code editor (using QScintilla in KDE or GtkSourceView2 in GTK)
Create phrases (blocks of text) to be pasted into any program on demand (uses the X selection)
Create collections of phrases/scripts in folders, and assign a hotkey or abbreviation to the folder to display a popup menu
Regular expressions can be used to filter windows by their title, to exclude hotkeys/abbreviations from triggering in certain applications
Scripts, phrases and folders can be attached to the tray icon menu, allowing you to select them without assigning a hotkey or abbreviation
AutoKey can track your usage patterns and present the most frequently used items at the top of the popup menu

For me, the biggest difference is that Autokey uses Python as its scripting language, instead of a specific proprietary language as AutoHotKey.
They also have an Ubuntu PPA, so you can install it easily and keep up with updates.
You can read a really good article(on How to Geek), on installing and using Autokey to set you up quickly.
Comment: autokey crashes all the time in ubuntu 13.10
Comment: Decio, you rock. i just went and installed this and have started setting it up. while i don't need as many text macros at home as at work, i can easily see this turning into one of my favorite applications. bravo.
Comment: I'm glad to help :-)
Comment: I installed AutoKey.  Learning python now, but it seems that there is lots of redundancy in the scripts. The autocomplete script is from AutoHotKey is what I really would like.  This link (goo.gl/6Y5k) is an 81kb zipped file, but runs at 4.9Mb uncompressed text. It locks up AutoKey just using it.
Comment: @RunningUtes I'm not sure what you intend with this file since the AutoHotKey script language won't work with AutoKey AFAIK. Funny enough I was able to import the file using the QT GUI of autokey.
Answer: If you have AutoHotKey scripts to automate Windows applications running in Wine, then AutoHotKey is exactly the program to use.  Fortunately, AutoHotKey is very easy to install in Wine, as the Wine project uses it for our automated QA tools.
The easiest way on Ubuntu is to just enable the Wine PPA and install the Wine package there.  This will pull in the winetricks package.  Then you can open a terminal and type "winetricks autohotkey" and it'll download+install it for you automatically.
Comment: Good to know, never though of using AutoHotKey with apps in wine.
Answer: This is more a warning than a solution.  I found instructions for building IronAHK on Ubuntu 10.  Check all the comments to get it working on Ubuntu 11.  But after building and trying to run a few scripts it seems to me that IronAHK is rather far from a full implementation.  Core functionality such as, say, hotkeys doesn't seem to be working yet...  Would be happy to be shown wrong here though.
Comment: IronAHK seems totally dead by now. No updates for several years. Pity :-/
Comment: @TorbenGundtofte-Bruun It is officially confirmed (on git page of IronAHK)
Answer: IronAHK and AutoHotkey (Wine) works on Ubuntu, although they will only capture hotkeys and forms under .NET (IronAHK) or Wine Applications (AutohotKey).
I've teste AutoKey and it is great, but unfortunately it doesn't handle mouse events very well.
IronAHK is not being developed anymore, so you will have to build from source using monodevelop. I found some bugs related to goto (around 3 issues), which I changed to if else statements, then I could compile normally.
Answer: there's quite a few text macro applications for linux, as well as some applications for recording and re-running various keyboard and mouse events as needed.
while i've never used AutoHotKey specifically, i use Texter at work and believe it's similar to what you're looking for. (if not could you please clarify particularly what it is you want to get done and maybe that'd help somebody answer).
there are a lot of applications/IDE's that support text macros in linux, or if you're looking to combine repeated actions across multiple applications there's xmacro... http://xmacro.sourceforge.net/


How close to itself can the JWST see? Inside our own system, or must it look beyond like it is far sighted? Essentially, can JWST see Mars or others?

Question: How close to us can we see with JWST, would we be able to look at our neighbor planets and/or their moons (when in the right place logically) or would things that close be out of focus?
I tried looking it up, but it seems everyone is (understandably) more into how far away it can see.
Comment: I think there's a very similar question somewhere, where the answer is calculated that everything farther away than 1.5 km is "infinitely far away". There has already been [images of Jupiter](https://blogs.nasa.gov/webb/2022/08/22/webbs-jupiter-images-showcase-auroras-hazes/).
Comment: @pela $$\frac{1}{f} = \frac{1}{d_1} + \frac{1}{d_2}$$ and a focal length of 0.13 km suggest otherwise; you'd have to move the focal plane by a dozen meters to do that! I think your number applies to 60 mm f/15 refractor in the back yard. If you could move the focal plane back by 10 cm for example you'd be focused at 172 kilometers. So the challenge here is to find out what the range of motion is for JWST's "focus knob". Related in Space SE [Has Hubble ever focused on something close enough that it had to move away from being focused at infinity?](https://space.stackexchange.com/q/50904/12102)
Comment: and [How does the JWST change focus when it goes from looking at a near subject to looking at a far subject? (Does it even change focus?)](https://space.stackexchange.com/q/58765/12102) and [Can James Webb take pictures of our solar system? In what ways will they differ from/compliment those from Hubble?](https://space.stackexchange.com/q/57492/12102) and [Could Hubble observe the night side of the Moon?](https://space.stackexchange.com/q/33790/12102) (answer is it did, but not to see it)
Comment: @uhoh Ah, thanks! Good thing I'm not an observer
Comment: On a related note, objects near the JWST are likely to be bright and hot.
Comment: @PM2Ring Not necessarily: JWST will also observe [asteroids and comets](https://jwst-docs.stsci.edu/methods-and-roadmaps/jwst-moving-target-observations).
Answer: Mars was a (possibly de facto) requirement. The JW attitude control system was given slew rates compatible with observations that far. Some limit had to be stated, and faster slew would cost more, either outright, or in impacts to other spacecraft elements (systems engineering), or in programmatic impacts (e. g., test requirements or lifetime or image jitter or whatever).
Slew rates are important because targets move, and JW moves. For extragalactic work etc., exposures measured in many seconds do not produce relevant motions (>PSF). For Solar-System work, motions are not just relevant but 3D- targets produce not just streaks but arcs if close enough (therefore fast enough).
In flight, part of the delay of several months (before first science light) was as-built, as-flown testing and demonstration. Ops has now reported that the attitude and slewing functions, of science-grade (not merely transit from one observing field to the next) have come in better than spec. This means JW can see closer than Mars.
Comment: A temporary, reversible -1 for complete lack of supporting sources. There's no way for readers to verify if "slewing rate" is really the limiting factor beyond "take my word for it". Good Stack Exchange answers need to support their facts with verifiable sources. *Thanks!*
Comment: And what would readers do with that? Finish their Cycle 3 proposals (more likely Cycle 4 at this point)? A qualified, working astronomer would have already known the answer, because they already read the necessary documentation on submissions, because they need not waste their time submitting notions instead of viable work. i. e., the act of asking belies not already knowing…even knowing who to speak to. Verify…why? If an internet commenter were qualified, they would not be _an internet commenter_ . What work will be left undone?
Comment: *Welcome to Stack Exchange!* This site works a little differently than others you may have used. It's not for everyone; SE may not be your cup of tea.


Why $C(n\mid l(n)) \ge C(n) - C(l(n))$ for Kolmogorov complexity

Question: Denote by $C(n)$ the plain Kolmogorov complexity of $n$ and the length of a binary encoding of $n$ by $l(n)$, why do we have
$$
 C(n\mid l(n)) \ge C(n) - C(l(n))?
$$
If I have a shortest program $p$ for $n$ given $l(n)$ and a shortest program $q$ for $l(n)$, then to compose out of them a program for $n$ (i.e. first compute $l(n)$ and then use this and $p$ to compute $n$) I need some way to tell them apart, thereby I need to put additional information into a program for $n$ using the programs $q$ and $p$, hence I do not have just $C(n) \le C(n\mid l(n)) + C(l(n))$, but this is written in my textbook as holding "clearly"? Or does this just hold if $C(n) \ge l(n)$?
Comment: Are you certain this is plain complexity, rather than prefix-free complexity?
Comment: As a separate point, questions like this are certainly unrelated to descriptive set theory; they are not really related to computational complexity unless we consider some sort of resource-bounded Kolmogorov complexity; and Kolmogorov complexity is not only a "computer science" topic (no more than computability theory in general), so I have edited the tags of the question.
Comment: Yes, I am sure, it is Example 2.2.5 from *An Introduction to Kolmogorov Complexity and Its Applications*, do you have a copy of this book (if not I can make a screenshot of the relevant page?) and there they just discuss plain Kolmogorov complexity. Thanks for your remarks regarding my tags!
Answer: In Example 2.2.5 of Li and Vitanyi, they say that they are looking at a string such that the "pattern of 0s and 1s is very irregular, $C(n) \geq l(n)$". What I believe they mean (added part in italics) is that they are looking at a string such that "the pattern of 0s and 1s is very irregular, that is, $C(n) \geq l(n)$". The final sentence of their example is only intended to apply to that case. The prose in that example is challenging for me to read, overall.
However, as we discussed in the comments, I don't see immediately how to fill in the argument in the book. The overall conclusion seems to be salvageable, as in the comments.
Comment: Thanks for your efforts, but why we have $C(n) \le C(n \mid l(n)) + C(l(n))$, that was my initial question?? (might be obvious but I do not see it...)
Comment: I don't see it either, immediately. There should be an additional term, unless I am missing some special assumption. But the overall conclusion of the argument seems to be sound, which is what I decided I could verify in the answer.
Comment: Ok. As I see it the inequality $C(n) \le C(n\mid l(n)) + C(l(n))$ is essential, but could we derive the conclusion if we have an additonal term $C(n) \le C(n|l(n) + C(l(n)) + f(n)$? In that case using $\log n \le C(n)$ we have $C(n|l(n)) \ge \log(n) - 2\log\log n - r - f(n)$. We could achieve $f(n) = 2\log\log n+1$ by coding the length of $l(n)$ (self-delimiting) into the input, then we have $$ C(n | l(n)) \ge \log(n) - 4\log\log n - r - 1 $$ and the same conclusion could be drawn. Might it be possible that this is an error in the book and the authors just forgot about the additional term?
Comment: You say: "Start with $C(n) \le C(n|l(n)) + C(l(n))$, which is true anyway"??? I am confused by what you are saying... why now you accept that it is true and a few comment above you share my objections that this might not be true (or is not obvious)??? As I see it your reasoning just works if someone accepts this inequality as true, but exactly that inequality is under discussion...
Comment: You're right - I'm going to delete that part of the answer. We agree that it should say that $C(n) \leq C(n|l(n)) + C(l(n)) + f(n)$ for an appropriate and unbounded $f(n)$. Apparently I was trying too hard to salvage the argument in the text, and began to work as if their inequality was actually right. But your version of the argument also gives the right conclusion.


Rigid body pile of objects not settling

Question: I'm trying to apply the ideas of these two tutorials to a different (non-donut) object.  I want to drop the 100 or so objects onto the ground to form an irregular pile of the objects.
My object is a single mesh, all extruded from a cube, no joined objects.
I've made an array of them in x and y, making sure to keep them separated and not touching each other.
I've applied the arrays, then selected all the objects, gone to Edit Mode and pressed p to separate - selecting "by loose parts"
Applied a rigid body, type = passive to the ground plane, and "active" to the falling objects.
I've tried the objects at 1kg and 0.1kg, and adjusting the friction on the active and passive objects, but I get the same issue - the objects are swirling into a kind of weird vortex?
https://youtu.be/3ivJlWRnzx4
Answer: Argh - I forgot to "Set Origin" to "Geometry" for each of the falling objects.  Hope this helps someone else

Rigid body pile of objects not settling


How to prevent WhatsApp images and other local pictures folders appearing from Google+ Photos app?

Question: I've enabled auto backup for camera photos except local folders. Although local folders are not uploaded to the cloud, Photos app keeps showing these folders and making a mess. I'd like to have this app clean with only camera photos just like Dropbox's Carousel do.
Comment: You may be able to create a blank file named ".nomedia" (yes the period is needed; the quotes aren't) in the folders you don't want it to index using a file manager. Then reboot the phone. This *should* prevent them from showing, but not always. Also it could cause problems for the apps that rely on those photos, so this may not be the ideal solution.
Answer: Update 2021: How to do it in the new  Google Photos Android app:

Open Google Photos.
Click on your avatar in the upper right corner.
Click on Photo Settings.
Click on Backup & Sync.
Click on Back up device folders
A list of folders will appear with a toggle on the right.
Toggle on / off the folders you want to back up.

Update 2014: How to do it in the new  Google Photos Android app:

Open Google Photos.
Go to Settings on the left panel.
Click on Backup & Sync.
Scroll down a bit.
Click on Choose folders to back up...
Activate or deactivate each folder by clicking the switch.

Google+
From: Back up photos & videos automatically
Turn on or off for individual folders

Open the Photos app .
Touch the menu icon   at the top left and then On Device.
To the right of each folder title, touch the cloud icon to turn Auto Backup on or off for that folder:

 Auto Backup is on for that folder.
 Auto Backup is off for that folder.
Comment: new version of photos app doen't have this option. .nomedia works perfect.
Comment: @shailesh thanks for noticing, updated with new steps.
Answer: Goto accounts > Google > sync > un tick   pictures
Comment: It sounds like OP wants camera pictures to still be synced, this will break that.


How to build a environment strategy for managed package if we have to use Saelsforce DX?

Question: Thanks in advance.
We developed a managed package into a partner developer org (PDO). Namespaces is already created in PDO. Now we would like to leverage SFDX. I would like to have environment strategy like Developer Env -> Testing Env -> UAT -> STAG -> PROD.
My questions
Will I be creating UAT, STAG, PROD org in my partner business org?
If yes after development/testing in scratch org I merge changes to UAT branch which should deploy changes to UAT sandbox. How would this application work on UAT sandbox as namespace is attached with code? Anyways we have to push final code to partner developer org.
Answer: Our developers add features to our managed packages using SFDX and scratch orgs, and our Continuous Integration uses those too via https://claimvantage.github.io/sfdx-jenkins-shared-library/. Scratch orgs support namespaces.
But at the moment, the package version upload is done back in the old developer edition org by doing a:
sfdx force:source:convert

followed by a:
sfdx force:mdapi:deploy

then followed by a manual version upload. Not too big a burden, as for us this is typically the final step after several weeks of feature development.
Eventually, packaging 2 should simplify this and make it more automatable.
PS
This single command:
sfdx:source:deploy

can be used in place of the two convert/deploy commands.
Comment: @Mossi Devs push their changes into GitHub (where the push automatically identifies and handles all changes) and the process to get the code into the managed package is to pull all changes from GitHub and then deploy that (so again everything is automatically handled). There is no manual change tracking.
Comment: Have you tried sfdx:source:deploy instead of converting? Any challenges there? I've been out of the ISV game for a few years now, curious if it has any unusual hurdles compared to mdapi.
Comment: @sfdcfox Will definitely try `sfdx:source:deploy` next time; I assume it will work.
Comment: @sfdcfox A colleague confirms you are right.
Comment: How do you remember what was added/changed by the devs in their Scratch Orgs? I assume you are updating the managed package manually after the deployment stage, right?
Comment: Looks like `source:deploy` doesn't automatically update the content of the managed package (`mdapi:deploy` does). FYI.
Answer: I work at Salesforce.org, where we created and use the free and open source CumulusCI (CCI) to manage the builds and environment generation for products like the Nonprofit Success Pack.
CCI prescribes "CumulusCI Flow", which is a branching and workflow model specifically designed for building managed packages using SFDX and scratch orgs. (CCI is in essence an orchestration layer on top of SFDX, which can be run locally or using a CI system). In full CumulusCI flow, the only persistent environment you use is your packaging org, and no work is done directly there; instead, all development is done in feature branches in scratch orgs, and is deployed to the packaging org only when merged to master.
UAT and other testing environments can be, and should be, scratch orgs. CCI provides the tools to automate setting up these environments for the use of different parts of your team, such as a customizable qa_org flow to build a quality assurance environment. Investing in this build automation pays off in the long term because you're guaranteed reliable, reproducible environment setup that's easy to pivot to new versions or different branches, without having to maintain the state of persistent orgs.
Comment: Thanks for the detailed explanation. Unfortunately Cumulus CI supports only GitHub and we are using Bitbucket so probably I will have to drop the idea of using Cumulus CI. But if I don't use and go through SFDX + Git flow using Bitbucket how will I involve QA people /Business User for manual testing that too knowing the fact that each developer will have their own set of scratch orgs for dev, qa and uat...correct me I am wrong.


Can I apply for a UK or any EU country visa after removal?

Question: I studied in the UK between 2006-2011, unfortunately in 2011 while trying to apply for a post study work visa, Immigration officials found anomalies with my bank statement and they had to remove me from the UK. I am now resettled in my country and my circumstances have changed. I may be required to travel to one of the EU countries (Sweden) early next year. I am just concerned if my application may be denied based on the past circumstances.
Comment: Um... Can you explain what sort of 'anomalies' they found that caused them to serve you with removal papers? Are you sure 'anomalies' is the right word?  Also, which form was served, IS151A or IS151B, or one of the IS8x series?
Comment: they established that the bank statement was a forged one. on that basis they thought I was trying to obtain visa deceptively. Unfortunately I do not remember which type of form I was served with. They did put a reference number in one of the pages in my passport.
Comment: Also, the OP's case is a removal and the canonical answer addresses deportation, please see http://www.communitylawservice.org.uk/images/uploadpics/removal_and_deportation.pdf
Comment: The UK and the EU are separate for visa purposes. Can you tell us precisely which country you may be visiting?
Comment: @Flimzy The UK is a member of the EU.
Comment: @Dirty-flow: Yes, but most EU countries are in the Schengen area, and the UK is not. This is often what's most relevant for visas.
Comment: This is not a duplicate question because the OP 1. reports a change in circumstances and 2. lost paperwork and  3. a removal under P320 rather than student working.  The canonical answer does not address these parts of the question.
Answer: You were removed from the UK in 2011 when you made an application for a post-study work visa and they determined that you had submitted a forged document.  You do not have your removal paperwork, and hence do not know the conditions of your removal. You may need to visit Sweden and want to know if your removal will have a pejorative effect on your application.
The first step is to recover the information surrounding your removal to find out if you have been placed on an exclusionary register. To do this, you can file a Subject Access Request with the Home Office and wait for their reply. This can be frustrating because you will need to clear identity hurdles imposed by the Data Privacy Act and several exchanges of correspondence may be needed. Having cleared all the identity hurdles, they may opt to refuse your request. They would do this if you have been placed upon an exclusionary register. If this happens you will have to take it up with the Ministry of Foreign Affairs in your own country because you have no further recourse with the UK (or any other country the UK exchanges information with).
If they reply, you should then take the information to a specialist practitioner in the Law Society for a consultation. They will be able to tell you if a ban is currently in effect and the extent to which you are vulnerable going forward for the rest of the EEA.  Your selection of a practitioner should be informed by the list of firms that have a branch office (or correspondence status) with Sweden. The list is here.
For the UK part of your question and given that a ban is not currently in effect, the next time you apply, the ECO will be required to place a mandatory ban under Paragraph 320 (11) (where the applicant has previously contrived in a significant way to frustrate the intentions of the Rules by:...) (emphasis mine).  There is no discretion permitted.
For the EU part of your question, the UK is a participant in the Schengen Information System and is required to place an alert entry in SIS whenever an in-country removal has been ordered.  Both an alert entry and exclusionary entry are causes for Schengen refusals.  Depending upon the circumstances of your removal, the UK may have also made an entry in the European Criminal Records Information System and this will also prompt a refusal.
For your tacit question about 'change of circumstances', your solicitor will know how to frame this change in a positive and convincing light and to provide the necessary supporting documentation such that you have a better chance of success (but not guaranteed).  I estimate that the 'all-in' costs for consultation and subsequent application would start at about £700 and range to about £1,500 depending upon their  competence in the field and other complexities in your case.
Comment: What is an exclusionary register? Also, the UK cannot submit information about immigration issues pursuant to Article 24 of Regulation (EC) No 1987/2006
Comment: @greatone I don't see why, up until the actual moment of Brexit, the UK can not submit expulsion information under clause 3 of that Article. Can you elaborate? (Nor, actually, do I see something preventing EU states from adding information provided by non-EU countries such as the USA, if they wish.)
Comment: @ Andrew Lazarus This is from 2006 so things might have changed. "Joan Ryan: We have law enforcement access but we do not have access to immigration information within Schengen SIS II." https://publications.parliament.uk/pa/ld200607/ldselect/ldeucom/49/6112903.htm


Subdirect product - terminology

Question: Let $A$ and $B$ be algebras of the same type such that the set of all their subdirect products consists of their ordinary product alone. Is there any terminology that describes this situation? I mean something like "we say that $A$ and $B$ are disjoint/orthogonal/...".
Comment: I have not heard of a name for this.  Is this equivalent to A, B, and AxB all being subdirectly irreducible?  If you were building a matroid, you might use matroid terminology for this relationship.  Gerhard "Hasn't Done This For Years" Paseman, 2016.07.08.
Comment: This seems like an interest notion. Do you have an examples of this?
Answer: Libor Barto and Marcin Kozik invented (and subsequently proved many results about) a concept called "absorption," which doesn't exactly give the new terminology you asked for, but does give special conditions under which a subdirect product must be the full product.
In particular, they prove the main Absorption Theorem which states that (in a Taylor variety) if $A$ and $B$ are "absorption-free," then any "linked" subdirect product of $A\times B$ is the full product.  I'm leaving out many details and all the definitions, but you can get them direct from the source. (See especially Theorem 2.3.)

Subdirect product - terminology


Proof of Sufficiency of Cauchy-Riemann equations

Question: I understand that the Cauchy-Riemann equations $$\frac{\partial u}{\partial x}=\frac{\partial v}{\partial y}$$ and $$\frac{\partial u}{\partial y}=-\frac{\partial v}{\partial x}$$ are necessary for a complex function to be complex-differentiable, but I would like to see a proof that they are also sufficient for this to be true. I am assuming that these partial derivatives exist and are continuous everywhere that they are satisfied.
Comment: They aren't. You also need conditions on the partial derivatives involved (continuity, for example). Note that, for example, $f(x+iy) = x^2$ satisfies the equations at $z=0$, but is not analytic. The general sufficient conditions are either rather complicated or not actually known, depending on who you ask. Either way, your question needs a more precise formulation.
Comment: Is there an example of a function that is not complex-differentiable at a point where the C-R equations are satisfied and the partial derivatives exist and are continuous?
Comment: No, see my answer.
Answer: Well, let be provide some inspiration based on linear algebra.
Remember in multivarible culculus, we always deem derivative as a linear mapping, or more concretely, a matrix. Now let's apply it in the case of complex linear space.
Let $f$ be a complex function on $ \mathbb{C} $, then $f$ is homolophic at point $z_0\in \mathbb{C}$ if and only if $Df(z_0)$ is a complex linear map from $\mathbb{C}$ to $\mathbb{C} $. Then identify $i$ to a matrix $\begin{pmatrix}
0 & -1 \\
1 & 0
\end{pmatrix}$, i.e., we deem $i$ as a complex linear map which rotate the plane 90 degrees anticlockwise. Next,  $Df(z_0)$ is a complex linear map if and only if $Df(z_0)$ commutes with $i$(think it why?), i.e., $Df(z_0)=\begin{pmatrix}
u_x & u_y \\
v_x & v_y
\end{pmatrix}$
$$\begin{pmatrix}
u_x & u_y \\
v_x & v_y
\end{pmatrix}\begin{pmatrix}
0 & -1 \\
1 & 0
\end{pmatrix}=\begin{pmatrix}
0 & -1 \\
1 & 0
\end{pmatrix}\begin{pmatrix}
u_x & u_y \\
v_x & v_y
\end{pmatrix}$$
if and only if $u_x=v_y, u_y=-v_x.$
Comment: Sorry, let me fix my previous comment: $f$ is anti-holomorphic at point $z_0\in \mathbb{C}$ if only if $u_x=-v_y, u_y=v_x$ at $z_0$. Hint: In this time, the condition is $Df(z_0)i=-iDf(z_0)$. @JacksonFitzsimmons
Comment: An more interesting thing is that by the same way you may find $f$ is anti-homolophic at point $z_0\in \mathbb{C}$ if only if $u_x=-v_y, u_y=-v_x.$ at point $z_0$
Comment: Oh wow, that's really insightful. Thank you for that.
Answer: A function $f:\mathbb{R}^2 \to \mathbb{R}^2$ represents a complex-linear map (with respect to the standard complex-linear structure on $\mathbb{R}^2$ given by $i\cdot(u,v) = (-v,u)$) iff its matrix with respect to the standard $\mathbb{R}$-basis has the form $\begin{pmatrix}
a & -b \\
b & a
\end{pmatrix}$ (easy exercise). If $f(x,y) = (u(x,y),v(x,y))$ is $C^1$ then its derivative (again in the standard basis) is the matrix $\begin{pmatrix}
u_x & u_y \\
v_x & v_y
\end{pmatrix}.$
Now note that $f$ is complex-differentiable at a point if and only if it is real-differentiable there and its derivative is a complex-linear map. (Proof: $f$ is complex-differentiable at $z$ with $f'(z) = a \in \mathbb{C}$ if and only if $f(z+h) = f(z) + ah + o(h),$ and any $\mathbb{C}$-linear map $\mathbb{C} \to \mathbb{C}$ has the form $h \mapsto ah$ for some $a \in \mathbb{C}.$) Combining this with the remarks above we see that a function $f:\mathbb{R}^2 \to \mathbb{R}^2$ is complex-differentiable if and only if it is real-differentiable and its real and imaginary parts satisfy the C-R equations. In particular if $f$ is of class $C^1$ then $f$ is complex-differentiable if and only if its real and imaginary parts satisfy the C-R equations.
Answer: The integral around every single triangle is zero by Green's theorem. If the integral around every single triangle is zero then the function is complex differentiable by Morera's theorem. Done.
Comment: But now I have to see a proof of Morera's theorem, thank you though. I am new to complex analysis.
Comment: "If the integral around any triangle is zero, then$\ldots$" is ambiguous: it could mean "If there is any triangle around which the integral is zero, then$\ldots$".  But "If the integral around every triangle is zero" is unambiguous. ${}\qquad{}$
Comment: can i recommend Priestley's Introduction to Complex Analysis?


Check for only numerical input in batch file

Question: In the Windows NT-based command line (mostly for XP or higher), is there a way to verify if a switch being provided is a number only? Depending on the number, I want it to loop through the code x number of times
Comment: Personally, I prefer the method in this answer for: [Make sure user entered an integer](http://stackoverflow.com/a/685214/108350).  Use the command processor to do _all_ that work.  You can simplify it to 2 x lines as a minimal solution: 1. `set /a  NO_LINES=%~1`; 2. `if  %NO_LINES% NEQ %~1  goto ABORT`.  When the two are equal - The variable or parameter _is-numeric_.
Answer: Edited to fix the regex as per debham's comment. Turns out that adding a space before the pipe after echo adds a space to the piped string, which was what broke the start/end of line matching previously. The regex could be further improved by discarding whitespace at the beginning and end.

There's the findstr command. It can search files with regular expressions, much like grep in Linux. It can also search piped input.
@echo off

set param=%1

echo %param%| findstr /r "^[1-9][0-9]*$">nul

if %errorlevel% equ 0 (
    echo Valid number
)

Explanation
The parameter used is set into the param variable. However, there is nothing stopping you using the parameter directly (%1 for the first paramater).
findstr is used to search the piped input with the /r flag for regex.
The pattern:

^ means beginning of line.
[0-9] means a digit. The * means the previous repeated zero or more times. So [0-9][0-9]* means one digit, plus zero or more digits. In other words, at least one digit. The + one or more times does not seem to be supported by findstr. Note that [1-9] is used for the first digit to disallow leading zeroes - see the comments.
$ means end of line.

Now, a for loop in batch for x number of times... if x is not a valid number, the loop actually does not run at all - it just gets skipped for the next line. So there is no need to check if the input is a valid number!
@echo off

set param=%1

for /l %%a in (1,1,%param%) do (
    echo %%a
)

The loop is done using for /l, where (x,y,z) means start at x, increment by y until z is reached. And it sets %%a to the current number/iteration.
Note: this actually fails if there is a leading zero, causing the command processor to treat it as an octal number. See dbenham's answer for a better solution.
Comment: As written, this solution will fail with a parameter like `"this 1 fails"` The FINDSTR should do an exact match. It should not do a word match.
Comment: Excellent explanation! And easy to use
Comment: @dbenham Thanks. I tried beginning/end of line matching before, but that failed due to echo passing an extra space. Fixed now.
Comment: @CanadianLuke You may wish to take a look at the edit.
Comment: A value of `09` or `010` could cause problems because of octal notation. See [my answer](http://superuser.com/a/618410/109090) for regex that disallows octal notation.
Comment: @dbenham Huh. Never knew batch even recognised it (in hindsight - it's probably using some standard library function for the conversion - I believe C's one does that). I'll just point people at your answer, though.
Comment: I suspect CMD.EXE has its own number parser, though I haven't any evidence to support that - it's just a gut feeling. I've written up rules as to how CMD.EXE parses numbers in various contexts, all based on empirical evidence: http://www.dostips.com/forum/viewtopic.php?f=3&t=3758
Answer: The following works very well for me. SET /a param=%1+0 always returns 0 if %1 is empty or not numeric. Otherwise, it provides the given number.
SET /a param=%1+0
IF NOT %param%==0 ECHO Valid number

Comment: This will fail if parameter = 0. Also will treat a parameter like "1+1" as a number, which might cause problems, depending on requirements.
Answer: This will detect if the first parameter is a valid natural number (non-negative integer).
@echo off
echo %1|findstr /xr "[1-9][0-9]* 0" >nul && (
  echo %1 is a valid number
) || (
  echo %1 is NOT a valid number
)

If you want to allow quotes around the number, then
@echo off
echo "%~1"|findstr /xr /c:\"[1-9][0-9]*\" /c:\"0\" >nul && (
  echo %~1 is a valid number
) || (
  echo %~1 is NOT a valid number
)

Note - leading zeros are disallowed because batch treats them as octal, so a value like 09 is invalid, and 010 has a value of 8.
Answer: Inspired by Bob's excellent answer with the following additions

Fix the errorlevel logic
Implement a DoWork loop/sub that iterates through the number and does
some arithmetic

:::::::::::::::
::CountTo.bat
:::::::::::::::
@echo off

::This is the number to test
if "%1"=="" goto :Usage

set param=%1
set matchPattern="^[1-9][0-9]*$"

::test if param matches matchPattern, quietly
:: (redirect stdout to nul, and stderr to stdout)

echo %param%|findstr /r %matchPattern%>nul 2>&1

:: check for errorlevel 1 or higher.  errorlevel 0 is handled as
:: an unchecked fall-through
if errorlevel 1 goto :MyHandleErrorCode

::Success (errorlevel ! >= 1) so proceed.
echo %param% is a valid number
echo  (matches findstr /r %param% %matchPattern%)
echo  findstr returned errorlevel 0

::any other code that the batch file needs to do goes here
echo.
echo Iterating from 1 to %param%
echo.
for /l %%i in (1,1,%param%) do call :DoWork %%i

::anything else,
:: .
:: .

::cleanup
:: .
:: .

::exit the batch file here, skipping embedded subroutines
goto :eof

:::::::::::::::::::::::::
:: Main work subroutine
:::::::::::::::::::::::::
:DoWork
set /a offset = %1 - 1
set /a square = %1 * %1
echo item %1
echo   offset: %offset%
echo   square: %square%
echo.
goto :eof

:::::::::::::::::::::::
:: Error handler code
:::::::::::::::::::::::
:MyHandleErrorCode
echo.
echo CountTo %param%
echo   %param% is not a valid number
echo   (does not match findstr /r %param% %matchPattern%)
echo   findstr returned errorlevel ^>= 1
:: error code doesn't have a goto :eof, we want to drop through to :Usage

::::::::
:Usage
::::::::
echo.
echo Usage:
echo.   CountTo ^<someNumber^>

The problem with the following is that it always returns 'Valid number' because 'if errorlevel 0' is always true due to the fact that it is a '>= 0' compare, not a '== 0' compare.
@echo off

set param=%1

echo %param%| findstr /r "^[1-9][0-9]*$">nul

if errorlevel 0 (
    echo Valid number
)

my $.02
Comment: Whoops... fixed the errorlevel on mine too. Direct numerical comparison rather than the automatic fall-through.
Answer: You can validate any variable if its number:
SET "var="&for /f "delims=0123456789" %i in ("%a") do set var=%i
if defined var (echo."NIC">nul) else (echo."number")

Answer: set xx=33
echo %xx%
SET /a %xx%+0 2>nul >nul && echo all Digits

set xx=3x3
echo %xx%
SET /a %xx%+0 2>nul >nul || echo No Digits

Comment: Can you add some explanation too, please?
Answer: I don't know why but on my system the findstr command didn't work. The errorlevel wasn't being changed on match or no match.
I did come up with another method though
:: Look for all digits. Parse the string and use all the digits as
:: delimiters. If the entire string is a digit then we will get an empty
:: parse value.
SET ALL_DIGITS=0
FOR /F "tokens=* delims=0123456789" %%a IN ("%VALUE%") DO (
    IF "[%%a]" EQU "[]" SET ALL_DIGITS=1
)

IF %ALL_DIGITS% EQU 0 (
    ECHO ERROR: %VALUE% is not all numbers
)

Answer: One approach:
set test_var=001
(
  (if errorlevel %test_var% break ) 2>nul
)&&(
  echo %test_var% is numeric
)||(
  echo %test_var% is NOT numeric
)

set test_var=001X
(
  (if errorlevel %test_var% break ) 2>nul
)&&(
  echo %test_var% is numeric
)||(
  echo %test_var% is NOT numeric
)

Another:
@echo off

:isInterer  input [returnVar]
setlocal enableDelayedexpansion
set "input=%~1"

if "!input:~0,1!" equ "-" (
    set "input=!input:~1!"
) else (
    if "!input:~0,1!" equ "+" set "input=!input:~1!"
)

for %%# in (1 2 3 4 5 6 7 8 9 0) do (
        if not "!input!" == "" (
                set "input=!input:%%#=!"
    )
)

if "!input!" equ "" (
        set result=true
) else (
        set result=false
)

endlocal & if "%~2" neq "" (set %~2=%result%) else echo %result%

Answer: :main
set /p input=text
if %input% equ 0 goto valid
set /a inputval="%input%"*1
if %inputval% equ 0 goto invalid
goto valid

:invalid
echo Input is not an integer.

:valid
echo Input is an integer.

Here is a game that uses this function.
@echo off
:main
set /a guessmin=1
set /a guessmax=100
set /a guessrand=%random% %%100 +1
echo.
:check
if %guessmin% equ %guessmax% goto fail
set /p input=- Pick a number %guessmin% - %guessmax%:
set /a inputval="%input%"*1
if %inputval% equ 0 goto invalid
if %inputval% gtr %guessmax% goto invalid
if %inputval% lss %guessmin% goto invalid
if %inputval% gtr %guessrand% goto high
if %inputval% lss %guessrand% goto low
if %inputval% equ %guessrand% goto mid
:invalid
echo   Please enter a valid number.
echo.
goto check
:high
echo   Your guess was too high.
echo.
set /a guessmax=%inputval%-1
goto check
:low
echo   Your guess was too low.
echo.
set /a guessmin=%inputval%+1
goto check
:mid
echo   Your guess was correct. The game will now reset.
set /p input=- Press enter to play again.
cls
goto main
:fail
echo   You actually managed to lose because there is only
echo   one number remaining. That number is %guessrand%.
set /p input=- Press enter to lose again.
cls
goto main


Cart shows removed products

Question: The user can remove his products from the cart. You will get the animation and it will be removed from it. However when the User clicks on links in my webshop the removed product will apear again. It won't show up in the checkout process and the cart will be empty. How can I fix this little bug that removed products apear again in the cart?
Comment: Potentially a cache issue. What version of magento? Are you using (3rd party) full page cache system?
Comment: Yes!  I used a third party page cache system! But how could this  affect my shopping cart. For others: Deactivate your 3rd party cache system - it can help.
Comment: well, the cache system is caching the display of the cart page. So instead of seeing the proper rendered page, you are getting the old, cached page.
Answer: Comments moved to answer, so as to complete the question.
Potentially a cache issue. What version of magento? Are you using (3rd party) full page cache system?
If cache is the issue, you should check the cache configuration to not cache the checkout pages. Contact your cache extension developers for help.

Cart shows removed products


Lanczos vectors

Question: I am trying to implement the Lanczos algorithm. If I implement it in Fortran or C, (i.e. in finite precision), will the vectors generated at each iteration still preserve their linear independence? Thanks.
Answer: Absolutely not. Krylov vectors will quickly loose orthogonality. This applies to all Krylov-type processes, including Lanczos, Arnoldi, Golub-Kahan, Lanczos bi-orthogonalization, etc. That is the one major difficulty with all Krylov-type algorithms (CG, MINRES, GMRES, QMR, TFQMR, Bi-CGSTAB, Bi-CG, CGS, etc, etc.)
Most implementations make provision for a reorthogonalization procedure. Full reorthogonalization (i.e., against all previously-generated Krylov vectors) is not only very expensive, it has also been shown to be unnecessary. Partial reorthogonalization is a very popular alternative that comes in different forms. Your question is very far-reaching and the negative answer has too many implications to list. I recommend reading some of the following excellent books. They point to research paper where you can find more details.

G. Meurant, The Lanczos and Conjugate Gradient Algorithms: From Theory to Finite Precision Computations
Y. Saad, Iterative Methods for Sparse Linear Systems
C. T. Kelley, Iterative Methods for Linear and Nonlinear Equations
A. Greenbaum, Iterative Methods for Solving Linear Systems

Michael Saunders has excellent class notes at Stanford that summarize the state of the art: http://stanford.edu/class/msande318/notes.html.
In finite precision, there is already an important difference in the Arnoldi process depending on whether you implement the standard Gram-Schmidt update or the modified Gram-Schmidt update. For a quick overview, google "modified gram schmidt giraud langou" in Google Scholar.
Comment: They loose both. In fact they can tend to all align.
Comment: Thanks. I want to just make sure here, do you mean these vectors lose linearly independence or orthogonality? Because if they are not linearly independent, I can't apply Gram Schmidt kind algorithms, can I?
Answer: They TEND to align -- they don't become completely parallel.  By all means, you can use Gram-Schmidt orthogonalization.  Dr. Underwood's classic program on netlib.org does exactly that.
Given the number of Lanczos programs available, why write another one?  Look into ARPACK, underwood.f, or LASO2 for a good solution.

Lanczos vectors


A filter to map lightness to hue of a pixel

Question: Is there a filter to map the lightness of source pixels to the hue value of a pixel?
I'm looking for some sort of effect similar to the "Colorama effect" in After Effects?
Comment: Is it a bitmap? I mean vector graphics only indirectly manipulate pixels.
Comment: In Inkscape? No.  When you want to modify pixels, you need to use a raster image editor. Inkscape is a vector image editor.  If you show an example of the effect, might be possible in Photoshop or GIMP.
Answer: Inkscape has some color modifying filters and extensions but I guess nothing creates what you want. There's simply no way to control all items in a complex vector drawing simultaneously to search a good total effect.
The idea fits much better to bitmap images. In Photoshop, GIMP and many other bitmap image editors you can twist color curves and apply gradient maps. You can also extract HSL values of a layer to RGB numbers of another layer and generate for ex. from L-numbers your new H-numbers.
I guess the gradient map is the easiest way to get started with good control over the result. Use blending mode "Hue" to transfer the new hue to your image if you want to keep the lightness and the saturation. Here's an example in Photoshop:

The used gradient maps black to blue and white makes green. The gradient can be built and edited freely or a preset can be selected. This gradient happened to look colorful and it was readily available.
If one wants to use original luminosities he can place a copy of the original image on the top and let it have blending mode Luminosity:

RGB color system has a limitation (due the screen technology). All color is lost near max and min luminosities. That can be reduced by decreasing the contrast. Just in this case it can be done by reducing the opacity of the top layer :


If Apache is configured to parse PHP can users see PHP source code?

Question: If Apache is configured to parse PHP and not allow to index files, are there other ways users can see PHP source code, either with or without intention?
Comment: Assuming your website doesn't have any command execution vulnerabilities, no.
Answer: If Apache is properly configured with the php module loaded and correct mime types, you should expect to not have any code disclosed to the client.
Example:
<code>AddModule mod_php.c
LoadModule php_module         modules/mod_php.so
LoadModule php5_module        modules/libphp5.so

AddType application/x-httpd-php .php
</code>
There don't seem to be any attacks against mime types in apache that would break this behavior that I know of. You should be more worried about poor coding practices, and disclosing the source code through other means such as file inclusion attack.
PHP does have a .phps extension that beautifies source code for sharing. If you use these files, make sure you strip them of any usernames and passwords before sharing them. It might be possible for a file to be incorrectly named .phps insteaf of .php -- unlikely, but possible.
Comment: Note: PHP doesn't _need_ to be an Apache module, but it does need to be configured. This was just an example, so another example would be a correctly configured php-fpm install instead of an apache module.
Answer: Here's an example of case that how hackers use file inclusion vulnerability to disclosure PHP source code. If not not properly configured, it can even lead to remote code execution vulnerability.
PHP security exploit - list content of remote PHP file?