Example II.$3.2.6$ in Hartshorne (reduced induced closed subscheme structure)

Question: Consider a scheme $(X,\mathcal{O}_X)$ and a closed subset $Y$ of $X$. Let $X = \bigcup U_i, \, U_i \cong \operatorname{Spec}(A_i)$ be an open affine covering of $X$ and let $Y_i = U_i \cap Y$. Then $Y_i$ is closed in $U_i$ and it can be endowed with a closed subscheme structure via the ring epimorphism $A_i \rightarrow A_i / a_i$, where $a_i = \bigcap_{P \in\operatorname{Spec}(A_i) \cap Y} P$. Notice that $a_i$ is radical and so $A_i/a_i$ is reduced. This construction endows each $Y_i$ with a sheaf $\mathcal{F}_i$ of reduced rings. Notice that the $Y_i$ form an open covering of $Y$. Thus we want to glue the $\mathcal{F}_i$ to get a reduced sheaf $\mathcal{F}$ on $Y$. For this, and in view of exercise II.$1.22$, we want to demonstrate isomorphisms $\phi_{ij}: \mathcal{F}_i|_{Y_i \cap Y_j} \rightarrow \mathcal{F}_j|_{Y_i \cap Y_j}$ as well as that the cocycle condition $\phi_{ik} = \phi_{jk} \circ \phi_{ij}$ holds on $Y_i \cap Y_j \cap Y_k$. Hartshorne says that this task can be reduced to the following: given affine open $U= \operatorname{Spec}(A)$ and $f \in A$, show that the reduced structure on $D(f) \cap Y$ induced by the restriction of the reduced structure on $\operatorname{Spec}(A) \cap Y$ is the same as the reduced structure on $\operatorname{Spec}(A_f) \cap Y$. Can somebody please explain what exactly is the argument that leads to this reduction?
Answer: $\require{AMScd}$
$\newcommand{\spec}[1]{\mathrm{Spec}(#1)}$
This reduction to the case $A \to A_f$ appears quite often in functorial constructions related to a scheme in algebraic geometry. It follows from the fact, that for a scheme $X$ and and a covering $(U_i)_i$ with open affines $U_i = \spec{A_i}$ we can choose a covering consisting of the original $U_i$ and additional affine $U_{ijk} = \spec{A_{ijk}} \in U_i \cap U_j$, such that the $(U_{ijk})_k$ cover $U_i \cap U_j$ and we have diagrams
$$
\begin{CD}
A_i @>>> A_i\\
@VVV     @VVV\\
A_{ijk} @>>> (A_i)_{f_{ijk}}
\end{CD}
$$
and
$$
\begin{CD}
A_j @>>> A_j\\
@VVV     @VVV\\
A_{ijk} @>>> (A_j)_{g_{ijk}}
\end{CD}
$$
where the vertical maps induce the respective open immersions and the horizontal ones are isomorphisms.
To prove this, we begin with a lemma:
Lemma A
Let $U=\spec{A}$ and $V = \spec{B}$ and $j:V \to U$ an open immersion induced by $\varphi:A \to B$. Furthermore be $D(f) = \spec{A_f} \subseteq j(V)$ be an open immersion too. Then $\spec{A_f} = \spec{B_{\varphi(f)}}$.
I do not prove this, it is fairly obvious.
Now for an $x \in U_i \cap U_j$ choose an $f'_{ijk}$ such that for $B = (A_i)_{f'_{ijk}}$ we have $x \in \spec{B} \subseteq U_i \cap U_j$. Then choose a $g'_{ijk}$, such that $x \in \spec{(A_j)_{g'_{ijk}}} \subseteq \spec{B}$. If $\psi:A_j \to B$ is the map inducing $\spec{B} \subseteq U_j$, then $\spec{B_{\psi(g'_{ijk})}} = \spec{(A_j)_{g'_{ijk}}}$ by the Lemma A.
Now $B_{\psi(g'_{ijk})} = (A_i)_{f_{ijk}}$ for a certain $f_{ijk} \in A_i$. Concretely let $\psi(g'_{ijk}) = h_{ijk}/(f'_{ijk})^d$, then $f_{ijk} = f'_{ijk} h_{ijk}$ with $h_{ijk} \in A_i$. Setting $g_{ijk}=g'_{ijk}$ we have
$$x \in U_{ijk}:=\spec{A_{ijk}}:= \spec{(A_i)_{f_{ijk}}} = \spec{(A_j)_{g_{ijk}}} \subseteq U_i \cap U_j$$
So we have, depending on $x \in U_i \cap U_j$ constructed our $U_{ijk}$ that is a standard-open subset of $U_i$ as well as of $U_j$. Going over all $i,j$ and all $x$ we construct the totality of all the $U_{ijk}$.
In the covering $(U_i, U_{ijk})$ only the morphisms $\gamma_{i,ijk}:U_{ijk} \to U_i$ and $\gamma_{j,ijk}:U_{ijk} \to U_j$ exist and are by construction of the form $A \to A_f$. Gluing this data together gives the original scheme $X$.
Now for your specific case I would argue, that the functor
$$F(U) = (U \cap Y)_\mathrm{red}$$
respects isomorphisms $U \cong U'$ and (to be proved) we have $F(U_f) = F(U)_f$. So the glueing data from above gives gluing data
$F(U_i), F(U_{ijk}), F(\gamma_{i,ijk}), F(\gamma_{j,ijk})$ which glue together to give $Y$ with the reduced induced structure.


Should my language distinguish between single- and double-quoted literals?

Question: In most modern languages, string literals can use either single (') or double (") quotes. Are there any reasons to distinguish between the two, and if so what would the other kind be used for?
Comment: Gonna pre-emptively comment this: I think "should" in this title is fine, and doesn't make it any more subjective than "pros and cons" or "advantages" would.
Comment: "In most modern languages, string literals can use either single (') or double (") quotes." This requires both citations and definitions.
Answer: Character Literals
Rust, and several other languages, use single-quoted "strings" for literal character types.
Comment: Character literals **are not** a kind of string literal.
Comment: @KarlKnechtel I know that, hence my quoting of "string".
Answer: Avoid escaping nested quotes
This is what I do when programming in JavaScript:
let foo = "This doesn't need to be escaped";
let bar = 'Neither does "this"';

Is it a deal-breaker to not have this? Absolutely not! But it is something to consider, and it is (ab)used by many minifiers.
Comment: This is a large part of the motivation in Python, as I understand it.
Answer: Embedded variables/escapes
Some languages, especially shell languages, use single quoted literals as raw literals, where things like backslash escapes are disabled. This can be handy when doing things like implementing encoders and decoders for JSON, or language parsers, since '\r' can be used as a literal for \r instead of "\\r", and similar, preventing the headache-inducing nested backslash escaping you can run into.
Additionally, some languages allow things like embedding variables/expressions directly, and single quoted strings could disable this.
Comment: @SilvioMayolo One thing Rust does that I really like is that the `r` (raw) prefix can have `#`s after it, and it can only be ended by a quote followed by that many `#`s. So you can put arbitrary data in a raw string without escaping, just by increasing the number of `#`s until there's no ambiguity.
Comment: I'm personally a fan of interpolation-by-default, and then allowing you to turn *off* interpolation and escaping with a prefix like `raw"..."`. But using single quotes to disable these things is pretty common in the state of the art.
Comment: @RydwolfPrograms Lua has something similar: string literals can be written as `[[use ' and " without escaping]]`, and sequences of matching length of `=` can be included like so: `[==[now we can use [[, ]], [=[ and ]=] inside a string literal without escaping as well]==]`
Answer: It's a waste of a character to have both the same
Having two semantically identical quotation mechanisms sitting on two keyboard characters may not be worth the cost. If there isn't a substantially different meaning, one of them could be used for something else instead, and that something doesn't have to be paired around a string! Several existing languages already make use of the single quote for other purposes.
One plausible use for the apostrophe is as an identifier character: it's common in mathematics to name derivative variables with a prime x, x′, x′′, and the single quote approximates that well. This could be particularly useful for a language that prohibited shadowing of names. Haskell allows this.
It could be used for marking generic type parameters, as in ML-family languages:
let prepend (ls : 'a list) (value : 'a) = value :: ls

Another use is for other literal types. It's been used as a prefix for symbol literals 'a in Lisp and other languages, and the language may have other atomic values it wants to express. Character literals are a common use in C-like languages.
It could inhibit evaluation of a compound value, again like in Lisp:
'(print x)

It could be another scarce operator character to use: I don't know what a ' b should do, but the users of the language will figure it out.
All of these could well be more effective uses than a redundant way to write a string.
Comment: Similar to what I was thinking of: " code golf"
Comment: Being able to write strings that contain quote marks as e.g. `console.log('This string contains "quote marks"!');` can be handy, even if apostrophe-delimited and quote-delimited strings would otherwise be interchangeable.
Comment: Rust uses `'a` for "the lifetime a" in lifetime parameters.
Answer: Firstly, having more than one is always useful when you need to have quotes within quotes.
But beyond that it depends on whether you need any semantic distinction:

C-like languages use single quotes to delimit char values, while double quotes delimit array of char values. (In languages like C, the distinction between array and element types is important. Furthermore, C does not have a "string" data-type; it simply stores strings in array-of-char.)
Shell-like languages use double quotes around strings that may have various kinds of interpolations done to them; "$var" will expand var but then inhibit any further processing. Compare this with single quotes, which cause everything to be taken literally, and no quotes, meaning that values not only have interpolations, but then also are subject to word-splitting and globbing. (Having things this way around is a major source of bugs in shell scripts.)
SQL uses single quotes to indicate fixed string values, and double quotes to write object names that aren't simply alphanumeric. (Some dialects also use backticks for this.)
Python uses single quotes, double quotes, and triple-double quotes. The latter """ is used around multi-line strings.

I find having only two kinds of quotes seems rather limiting. In addition to the ASCII apostrophe ' and quotation mark ", I routinely use « guillemots » (french quotes), typographic 'single quotes' and "double quotes", and the distinct symbols for degrees ° minutes/feet ′ and seconds/inches ″ – and where necessary, thirds ‴.


Is there any particular reason to use Diffie-Hellman over RSA for key exchange?

Question: I often see RSA being recommended as a method of key exchange. However, the Diffie-Hellman key exchange method appears to be secure as well.
Is there any considerations one should take into account that would lead to using one algorithm over the other?
Comment: Well as of today (Logjam) there is one huge particular reason.
Comment: For one, it generalizes to Elliptic Curve Cryptography.
Comment: Related: https://crypto.stackexchange.com/questions/2867/whats-the-fundamental-difference-between-diffie-hellman-and-rsa
Answer: The situation can be confused, so let's set things right.
RSA is two algorithms, one for asymmetric encryption, and one for digital signatures. These are two distinct beast; although they share the same core mathematical operation and format for keys, they do different things in different ways. Diffie-Hellman is a key exchange algorithm, which is yet another kind of algorithm. Since the algorithms don't do the same thing, you could prefer one over the other depending on the usage context.
Asymmetric encryption and key exchange are somewhat equivalent: with asymmetric encryption, you can do a key exchange by virtue of generating a random symmetric key (a bunch of random bytes) and encrypting that with the recipient's public key. Conversely, you can do asymmetric encryption with key exchange by using the key resulting from the key exchange to encrypt data with a symmetric algorithm, e.g. AES. Moreover, Diffie-Hellman is a one-roundtrip key exchange algorithm: recipient sends his half ("DH public key"), sender computes his half, obtains the key, encrypts, sends the whole lot to the recipient, the recipient computes the key, decrypts. This is compatible with a one-shot communication system, assuming a pre-distribution of the public key, i.e. it works with emails.
So for the rest of this answer, I assume we are talking about RSA encryption.

Perfect Forward Secrecy is a nifty characteristic which can be summarized as: actual encryption is done with a key which we do not keep around, thus immune to ulterior theft. This works only in a setup in which we do not want to keep the data encrypted, i.e. not for emails (the email should remain encrypted in the mailbox), but for data transfer like SSL/TLS.
In that case, to get PFS, you need to generate a transient key pair (asymmetric encryption or key exchange) for the actual encryption; since you usually also want some sort of authentication, you may need another non-transient key pair at least on one side. This is what happens in SSL with the "DHE" cipher suites: client and server use DH for the key exchange, with newly generated DH keys (not stored), but the server also needs a permanent key pair for signatures (of type RSA, DSA, ECDSA...).
There is nothing which intrinsically prohibits generating a transient RSA key pair. Indeed, this was supported in older versions of SSL; see TLS 1.0, section 7.4.3. In that case, use of an ephemeral RSA key was mandated not for PFS, but quite the opposite: so that encryption keys, while not stored, could be broken afterwards, even if the server's permanent key was too large to be thus brutalized.
There is, however, an advantage of DH over RSA for generating ephemeral keys: producing a new DH key pair is extremely fast (provided that some "DH parameters", i.e. the group into which DH is computed, are reused, which does not entail extra risks, as far as we know). This is not a really strong issue for big servers, because a very busy SSL server could generate a new "ephemeral" RSA key pair every ten seconds for a very small fraction of his computing power, and keep it in RAM only, and for only ten seconds, which would be PFSish enough.
Nevertheless, ephemeral RSA has fallen out of fashion, and, more importantly, out of standardization. In the context of SSL, if you want PFS, you need to use ephemeral DH (aka "DHE"), because that's what is defined and supported by existing implementations.

If you do not want PFS, in particular if you want to be able to eavesdrop on your own connections or the connections of your wards (in the context of a sysadmin protecting his users through some filters, or for some debug activities), you need non-ephemeral keys. There again, RSA and DH can be used. However, still in the context of SSL, non-ephemeral DH requires that the server's key, in its X.509 certificate, contains a DH public key.
DH public keys in certificates were pushed by the US federal government back in the days when RSA was patented. But these days are long gone. Moreover, DH support was never as wide as RSA support. This is indeed an interesting example: DH was government approved, and standardized by an institutional body (as ANSI X9.42); on the other hand, RSA was standardized by a private company who was not officially entitled in any way to produce standards. But the RSA standard (PKCS#1) was free for anyone to read, and though there was a patent, it was valid only in the USA, not the rest of the world; and in the USA, RSA (the company) distributed a free implementation of the algorithm (free as long as it was for non-commercial usages). Amateur developers, including Phil Zimmerman for PGP, thus used RSA, not DH. The price of the standard is nothing for a company, but it can mean a lot for an individual. This demonstrates the impetus that can originate, in the software industry, from amateurs.
So that's one advantage of RSA over DH: standard is freely available.

For security, RSA relies (more or less) on the difficulty of integer factorization, while DH relies (more or less) on the difficulty of discrete logarithm. They are distinct problems. It so happens that the best known breaking algorithms for breaking either are variants of the General Number Field Sieve, so they both have the same asymptotic complexity. From a high-level view, a 1024-bit DH key is as robust against cryptanalysis as a 1024-bit RSA key.
If you look at the details, though, you may note that the last part of GNFS, the "linear algebra" part, which is the bottleneck in the case of large keys, is simpler in the case of RSA. That part is about reducing a terrifyingly large matrix. In the case of RSA, the matrix elements are just bits (we work in GF(2)), whereas for DH the matrix elements are integer modulo the big prime p. This means that the matrix is one thousand times bigger for DH than for RSA. Since matrix size is the bottleneck, we could state that DH-1024 is stronger than RSA-1024.
So that's one more advantage of DH: it can be argued that it gives some extra robustness over RSA keys of the same size.
Still for security, DH generalizes over other groups, such as elliptic curves. Discrete logarithm on elliptic curves is not the same problem as discrete logarithm modulo a big prime; GNFS does not apply. So there is not one Diffie-Hellman, but several algorithms. "Cryptodiversity" is a good thing to have because it enables us to switch algorithms in case some researcher finds a way to easily break some algorithms.

As for performance:

RSA encryption (with the public key) is substantially cheaper (thus faster) than any DH operation (even with elliptic curves).
RSA decryption (with the private key) entails more or less the same amount of work as DH key exchange with similar resistance. DH is a bit cheaper if it uses a permanent key pair, but a bit more expensive if you include the cost for building an ephemeral key pair.
In the case of SSL and DHE_RSA, the server must generate a DH key pair and sign it, and the signature includes the client and server random values, so this must be done for each connection. So choosing "DHE_RSA" instead of "RSA" kind-of doubles the CPU bill on the server for SSL -- not that it matters much in practice, though. It takes a very busy server to notice the difference.
A DH public key is bigger to encode than a RSA public key, if the DH key includes the DH parameters; it is smaller otherwise. In the case of SSL, using DHE_RSA instead of RSA means exchanging one or two extra kilobytes of data -- there again, only once per client (because of SSL session reuse), so that's hardly a crucial point. In some specialized protocols, ECDH (with elliptic curves) gets an important edge because the public elements are much smaller.

If you are designing a protocol in a constrained situation (e.g. involving smart cards and I/O over infrared or anything similarly low-powered), ECDH will probably be more attractive than RSA.

Summary: you will usually prefer RSA over DH, or DH over RSA, based on interoperability constraints: one will be more supported than the other, depending on the context. Performance rarely matters (at least not as much as is often assumed). For SSL, you'll want DH because it is actually DHE, and the "E" (as ephemeral) is nice to have, because of PFS.
Comment: There is one significant difference between DH and RSA-encryption: DH implicitly authenticates both sender and receiver, whereas RSA only authenticates the receiver. If you want to authenticate the sender in a non interactive scheme, RSA can't easily replace DH.
Comment: In that case, add another advantage: in full static DH (client and server both have a certificate with a DH public key in it, and both keys use the same parameters), then they can get away with poor or inexistent random number generation, replacing it with a mere counter. That's an edge case.
Comment: How exactly could you use a Key-exchange protocol for asymmetric encryption? Using RSA everybody can use the public key to encrypt something only the private key can decrypt. Using DH, everyone wanting to send a private message to the private key, would need to create a new public/private key pair and submit his public key with the message, right?
Comment: @dasf Indeed, DH is a _key exchange_ mechanism. To turn that into an _encryption_ mechanism, you couple it with symmetric encryption: Alice and Bob agree on a shared key through DH, then use it with something like AES to encrypt and decrypt data. That's how things are done, for instance, in SSL/TLS.
Comment: @JSG That's pretty much exactly what you do. ElGamal works the same way -- an encrypted thing has *two* components, one of which is essentially a public key (less the parameters of the group) and the other of which is the actual ciphertext.
Comment: Why has ephemeral RSA fallen out of fashion?
Comment: Since the identity of the key in DH depends on the independent choices of Alice and Bob, does this mean that neither party can predict what the key will look like? So if say Alice wants to share her Social Security number with Bob, is there anyway she can use DH to do that, or is RSA better suited?
Comment: Why can't the client generate a random key, encrypt it with the public key of the server, and then ask server to use that key for symmetric encryption? Since the client is generating a new key every time, we still get PFS. Then why do we need DH?
Comment: @saketrp: Because the entity in control of server's private key could recover the session key from a packet trace and decrypt the session at any point in the future—making it not *perfect* forward security. In true PFS, neither the client nor the server can decrypt the session after they close the session (assuming neither are compromised and both are correctly implemented).
Answer: DH ephemeral key exchange provides perfect forward secrecy, which RSA alone does not. This means that even if the long-term key is leaked at a later date, the session keys for individual connections are not compromised, even if the full data stream is captured.
Comment: Simply add "ephemeral" to RSA and you also get perfect forward secrecy.
Answer: In the context of SSL Polynomial is right: (EC)DHE suites use ephemeral key-exchange using Diffie-Hellman. Since the server forgets the private key used for exchange soon after using it, a compromise of the server's long term key doesn't allow an attacker to decrypt all past communications, i.e. it provides Perfect forward secrecy.
I recommend using ECDHE_RSA suites in SSL. They offer perfect forward secrecy, a high security level for confidentiality (128 bits if P256 is used) and allow you to use the same certificate for both legacy RSA connections and strong ECDHE_RSA connections.

The reason protocol designers use DH for ephemeral key-exchange is performance.

Generating a DH key is relatively cheap: It's simply a scalar multiplication with a fixed base (or exponentiation if you use multiplicative notation).
The total cost of an ephemeral key-exchange using ECDH is one scalar multiplication with fixed base (key-gen) and one scalar multiplication with variable (the actual key-exchange) plus an RSA private key operation using the long-term key signing the ephemeral public key.
Generating an RSA key is much more expensive, since you need to find two large primes. It's very expensive to generate a new RSA key-pair for each connection.
The RSA private-key operation is also a bit more expensive than a DH key-exchange with the same security level, but that hasn't stopped us from using RSA with long-term keys.

With ECC the performance gap becomes even wider, especially at higher security levels. 256 bit ECC is pretty common (128 bit security), for equivalent security using RSA you'd need a 3000 bit key.
Answer: Conversely, RSA key exchange involves the server's secret RSA key, which (EC)DH does not.
This means that even if the attacker obtains means of cracking your RSA key, he will have to expend the cracking effort for each server/key.
With (EC)DH, using a logjam-like attack, most of the cracking effort goes to breaking the entire, so-called, algebraic/elliptic group. After that, breaking individual connections is cheap.
So, while RSA key exchange motivates the attacker to crack only the keys of interesting servers, (EC)DH key exchange motivates him to attack as many connections as possible to get the best cost/attack ratio.
If you wonder, why is this property of (Im)perfectForwardSecrecy little known, it is probably because no logjam-like attack against Elliptic Curve Diffie-Hellman key exchange is currently known.
This is supposed to be a follow-up/comment to post https://security.stackexchange.com/a/35472/185953


What is feedback in electronics?

Question: I dont want to know that we have two types of feedbacks and why it was invented,I just want an explanation in simple words of what feedback is.
Answer: Feedback is nothing more than looking at the output of some system and using that information to control one of the inputs on that same system for the next time interval.
Answer: Feedback is a phenomenon by which the signal at input of a system is affected by change in output.
Answer: Try Google, there are lots of references on the web.
Here's a particularly good one: http://www.cds.caltech.edu/~murray/books/AM05/pdf/am08-complete_22Feb09.pdf
I think one of the first applications of feedback in a complex system was to regulate the speed of Watt's steam engine.
If my memory is correct there was a spinning device with 2 balls attached (called a governor).  As the speed increased the balls tended to spin outwards which opened a valve that slowed the engine.  The system reached equilibrium at the desired speed.  So the speed was measured with the spinning device, which fed control signal back into the engine to slow it to keep the speed constant.  Any load on the engine would cause the spinning to slow, which the governor would react to providing more power to the output.
Comment: I don't know if this is the first example of feedback in control, but it's certainly an early one.  Interestingly, it is the origin of the phrase "Balls out", though its tempting to place the origin on other things.
Answer: Just two?
Feedback is readout of the reaction of the system to your control.
Example 1: You drive a GPIO pin high. The pin activates an actuator. There is an edge switch that detects the actuator started moving and it works as input on another pin. When both conditions are met, a warning light is lit to inform the actuator is in motion. This is your feedback: light informing of the actuator in motion.
Example 2: You switch a heater on, and your feedback is the resistance of a thermistor attached to the heater, letting you determine the temperature and switch it off when it's hot enough.
Example 3: You drive an AC motor through PWM. You output a signal that gets converted to current at some duty cycle. You read in the current flowing to the motor to determine the motor's torque, and you read a rotary encoder that gives you the motor position. Your control is duty cycle = power provided to the motor. Your feedback is the torque and position of the axle. Knowing this you can position the motor precisely and drive it to desired state in optimal time.
Generally, any system has inputs and outputs. Any input whose state is determined by your output - be it directly or indirectly - is called a feedback,
If you use that feedback to determine the control (like, regulate temperature by switching the heater on and off), you have a feedback loop. If the feedback just provides information (like that warning light), it's monitoring - reading and providing the state of the system output without affecting it.
Answer: Just one sentence: We have feedback when the result of a certain process acts back to the source that has caused the process.
This is not necessarily restricted to technical systems. We also have feedback effects in biology, social sciences and other areas.
Answer: Suppose you have a system and you want something at the output, now the system is not ideal and it gets affected by its environment or surrounding like temperature, light or anything that can affect the behavior of the system, if you keep the input constant then there's no guarantee that you'll get the desired output due to certain things perturbing the system, so what you do is sense the output, feed it back to the controller whose controlling your system(providing input to the system, it could be a microprocessor controlling a servo motor or whatever) and the controller changes the input to the system accordingly to get the desired the output, that's feedback.

What is feedback in electronics?


Most general Lagrangian in CFT in 0+1D

Question: My question is about $CFT_1$. Page 18 of this says that $$L={\frac{\overset{.}{Q}^2}{2} - \frac{g}{2Q^2}}\tag{1.11}$$ is the most general Lagrangian that preserves time translation and scale invariance in $CFT_1$. How does one prove that?
Answer: Classically a theory is invariant under a transformation if its action is invariant (up to boundary terms). In our case a conformal transformation is given by
$$t'=\lambda t\\ Q'=\lambda ^{-\Delta}Q $$
where $\Delta$ is the scaling dimension of Q, which is just its energy dimension classically.
For now let's assume a Lagrangian with only the kinetic term and infer the dimension. To this end plug the transformed variables into the action
\begin{align}
S' &=\int \mathrm{d}t' \frac{1}{2}\left(\frac{\mathrm{d}Q'}{\mathrm{d}t'} \right)^2 \\ &=\lambda^{-2\Delta-1}S
\end{align}
We can read of that $\Delta = -\frac{1}{2}$.
We can now try to add more terms to our Lagrangian but we would not want to include additional kinetic terms so we restrict them to have the form $g_n Q^n$. Plugging these terms into the action we see that they transform as $$\mathrm{d}t'\ Q'^n = \lambda^{1+\frac{n}{2}} \mathrm{d}t \ Q^n $$
which implies $n=-2$ if we require conformal invariance. We thus showed that the most general Lagrangian is given by
$$\mathcal{L} = \frac{1}{2}\dot{Q}^2 - \frac{g}{2Q^2} $$
Comment: Regarding your first two equations: how do we know that a conformal transformation takes this form? For instance why $\lambda^{-\Delta}$ instead of $\lambda^{\Delta}$? ( I apologize if this is a basic question)
Comment: Think of it in terms of numbers in different units. I will give an example in 3D because I think it is more visual but the idea in 1D is the same. Say Alice measures things in inches and reports $x=1$ to Bob who prefers centimeters. He now knows $x'=2.54$ in his units. If Alice now tells Bob about some density for example particles per volume and she counts 100 particles per unit volume then in Bob's unit volume he will only find $Q'=2.54^{-3}\cdot100$ particles. It is no coincidence that the energy dimension of this density is 3.
Comment: However, this theory is not conformal right? I mean, given that any diffeomorphism is a conformal transformation in 1D.

Most general Lagrangian in CFT in 0+1D


Should Exceptions Be Expressed on the Domain Model?

Question: Let's say that we have a class PersonName and we throw an exception when some one try to create a instance of PersonName passing an invalid name to the constructor. Should the exception InvalidPersonName be expressed on the domain model? And if it should, how should it be represented?
Comment: Where else might you express it?
Comment: Due to some possible misunderstanding in the answers, could you please edit your question and clarify what kind of domain model you have in mind? A graphical UML model? Which kind of diagram & semantics?
Answer: Maybe. Domain model does need to express what errors exist and possibly how should they be handled. All that domain model needs to tell you is that "Valid name is XXX. And user needs to have a valid name at all times." It doesn't tell you how to actually implement it.
Exceptions are language/framework specific ways of expressing this kind of error and there are many other ways how to express invalid operation. It should be up to developer to decide what way to express errors. But that is different question of exceptions, error monads, etc..
Personally, I wouldn't use exceptions (unless using Checked exceptions). I would most probably use return value to indicate if ValidName structure can be created or that Name can be set. Eg. I would ensure calling code is fully aware of the case that name cannot be valid. When using unchecked exceptions, the programmer writing calling code might be unaware of this case and won't write code for handling it.
Answer: In general, throw an exception when a condition occurs that your code cannot recover from itself.
If you provide a constructor for an object, and the caller of the constructor can hand that constructor some data that makes it impossible to construct a valid and consistent object, then throwing an exception is the proper response in those languages that support exceptions.
If your question includes "should I create a custom exception for each such occurrence, the rule of thumb is "generally no.  Just use some general-purpose exception like an InvalidOperationException, or even just an Exception with a description."
Comment: @Euphoric: That's why exceptions have error descriptions.  I know that Java advocates checked exceptions and all sorts of complex exception hierarchies, but they're unnecessary and overly complicated.  The programmer can work out what the problem is by looking at the error message. If you're trying to build logic around specific exceptions, that means that the code could really handle the condition after all, and an exception is no longer the preferred handling mechanism.
Comment: While this is absolutely true, it does not answer the question about how to express it in the domain model
Comment: What does that mean, "express it in the domain model?"  The exception would be thrown in the constructor method.  Why would you throw it anywhere else?
Comment: _Just use some general-purpose exception like an InvalidOperationException_

I disagree. Especially in this case, the code handling the user name would need to handle "InvalidUserName" in some specific way. And this goes for most domain errors. IOE should only be used if only real way to handle the exception is to crash the application. Which is extremely rare.
Comment: Robert, I guess the OP is talking about something like a graphical domain model, like an UML model.
Comment: @DocBrown: What do exceptions have to do with a UML diagram?
Comment: @RobertHarvey: that is IMHO exactly what the OP was asking - having a domain model, maybe utilizing UML class diagram notation with method names, does it make sense to express the fact the ctor of a class can throw an exception in the graphical model? If so, how? (My personal opinon is simply "no", wrong level of abstraction). But maybe the OP had a different kind of domain model in mind, who knows?
Answer: You should always keep in mind that graphical models are created for the sole purpose of communicating specific information. In that regard, there is no such thing as "should" this model contain "this information" because it all depends on what information you are trying to convey to the reader in each specific diagram.
The only rule of thumb is that each model should contain the information you are trying to communicate in a clear manner. Nothing more, nothing less.
Frequently, this "rule of thumb" could lead to needing multiple diagrams describing more or less the same thing but from different viewpoints. For example, a domain model and a class diagram. On the surface, these might appear to be the same or very similar because they both usually use class diagram notation to represent them and the class names are sometimes the same. However, a domain model generally describes "real-world" domain objects whereas the class diagram shows the software implementation classes that are used to implement the "real-world" objects. While each model represents essentially the same thing, they each are trying to communicate very different kinds of information.
Having each diagram clearly depict the information it is trying to convey is far more preferable to force-fitting all the information in the same diagram and leaving it up to the reader to decipher all the tidbits of information hidden in the details.
So in answering your question about should Exception classes be in the domain model then that seems to be an obvious no. Should it be in the class diagram? You need to decide if that is an important concept for the class diagram you are drawing. Personally, I generally wouldn't show it in a class diagram for a subsystem. However, if I were to put it in a diagram at all it would be a class diagram of all the custom exception classes the system created or used.  On the other hand, if I were creating a subsystem library for use by others (on a totally different project) then I very well might consider showing the exception class on the subsystem class diagram, but probably only if there were something "special" about the exception class that I think the users should be aware of.
This is probably redundant but is important enough to reiterate explicitly. Your class diagrams don't need to show every single class if showing them doesn't provide useful communicative value. Sometimes, showing too much is worse than showing too little because too much information can easily hide the most important concepts that the diagram should really be trying to convey.
Answer: You need to create reusable code. E.g. PersonNameExpception can be applied only to PersonEntity. What if you want to add same validation logic for another entity? From this point of view exceptions should be more generic.
As common pattern there are separate domain entities and separate validation rules that can be applied to entities.
In java you can look for JSR303 Bean validation as example


Ancient Indian sites, where Jataka stories are illustrated through sculpture and painting?

Question: I know that many Jataka stories are illustrated, through sculpture and painting, in ancient Indian sites like Sanchi, Bharhut, Ajanta etc. I have found some of them in various books and websites. What I need is a comprehensive list of such illustrations. Can anyone please help me?
Answer: There's The Illustrated Jataka & Other Stories of the Buddha
Some are also covered in this documentary
A simple comprehensive list can be found here


Sharepoint 2016 Background Overlay

Question: I am fairly a novice when it comes to branding SharePoint.  We have have a SharePoint 2016 site that I have inherited and I am being asked to change the overlay of the built-in theme we are using to let more of the background image show through. I have read that the default overlay is .85.  I can't seem to figure out how to change this percentage. I can see in our custom masterpage where I believe it is being done in the s4-workspace calling the ms-core-overlay. When I look at it in designer it brings up the corev15.css. if i edit the .85 for the overlay nothing changes. Just not sure where to go from here. I seem to go in circles with the info i find online.   I hate to say this but exact instructions if possible would be super helpful. =)
Answer: There are a couple of ways to do this. If you want it globally you need to determine the exact id/class of the portions you wish changed in the css. Then you need make a renamed copy of that css for backup purposes. Then modify the file. If it does not take, there is another file somewhere that is overwriting the change. You can use F12 on MS Edge or IE 11 to check the classes, styling, etc.
Alternatively, if this is for a specific page and you are not trying to change everything globally, you can write a short CSS stylesheet using a Script Editor Web Part for the page and include the changes there using !important before the ;
Without seeing the exact css and knowing which part you are trying to change, I cannot offer code snippets for you to use.

Sharepoint 2016 Background Overlay


iMovie Update Questions

Question: Lately I've been working on videography, but I've been using iMovie on my MacBook Pro, and its about 8 years old, and I know for sure there's an update for the iMovie, but when I go to app store it says theres no updates?
Comment: Could you provide more details like OS version and iMovie version ?
Comment: I went to the app store and it said there was another app for imovie and i tried downloading it, but it said I needed to download OS X version 10.11.2 but my computer doesn't say I have anymore updates for my Os
Comment: Which OS are you running now ?
Answer: Since you have not provided OS version and from the age of your laptop, I consider that you are not running the required OS for the latest iMovie version. The latest iMovie version is v10.1.5 and the minimum system requirement is OS X 10.11.2 or later. When you open iMovie, it may inform you that there is a update on the MAS, but it also asks you to update the OS.

iMovie Update Questions


How to make omelettes extremely quickly

Question: When you hear of people making extreme quantities of omelettes in record time (think: contests), is there a special technique one needs to master in order to do this? Or is it simply a matter of being really good and efficient with the standard technique? If there is such a technique, what is it?
Answer: I can't say much for how professionals would do this, but I have found just about the quickest omelette is the Julia Child (French) version of one.
By her method, you cook the eggs (mixed with just a bit of water) over fairly high heat in a bit of melted butter, shaking the pan the whole time. At the end, you jerk the pan to get the eggs to roll up on themselves.
See a video here. It takes her about 30 seconds.
Comment: No.. scrambled eggs are looser. An omelette holds together in a (usually folded) disc. Filling is optional in an omelette.
Comment: +1 This is pretty much the same method that they use on "Saturday Kitchen" (Made for the BBC); although most of the shefs that do the challenge on there seem to be around 20 seconds (they don't add the water though)
Comment: This is a scramble not an omelette.  I always thought a scramble was just about the eggs, omelettes usually have stuff in them?
Comment: @Chris: I'm certainly no expert but I'm inclined to believe Julia Child.
Answer: I don't know about contests, but I have in the past cooked 100 18-20 inch omlettes in just over half an hour.
We used three pans working in parallel. Get the pans as hot as you can. Use oil, not butter, so you don't have to wait for it to melt each time. Pre-beat all the eggs together in advance.
After that, it's just a tablespoon of oil and a ladle of eggs. Flip when solid enough to survive flipping.
I'm not sure if the fact that the entire kitchen (galley actually) was gently rocking form side to side on the waves was a help or a hindrance.
Comment: I'm going to assume that Carmi had quite a few pans going at once, and that quality/appearance likely did suffer; military food is more like caffeteria food than fine-dining  ... that whole 'no color' thing is likely right out.  (and I checked Carmi's bio to confirm ... Israeli Navy, so the hint that it was on a boat wasn't because it was an upscale cruise ship)
Comment: I reackon the 200 omelettes in 30 minutes comment is rubbish. Or if it was possible then they would not be a very good shape size texture or quality. Regardless of weather they were classical french omelettes or simply the folded in half style. I had a business that made these for the food service industry for more than 10 years. My team individually could only produce 125 omelettes each per hour at best. These were classic french styled 2 egg omelettes cooked in parallel across 5 pans per chef.Oh of course no colour
and a creamy texture inside.
Comment: Like Joe said, we weren't striving for quality. It was just the most efficient way to get eggs into men. It also occurrs to me that we made 200 servings, which were half an omelette each, though these were 18-20" omelettes to start with. I'll amend my answer.
Answer: I find that this exquisitely instructional video about how to make an omelet is a great way to start.
You may try at least 2 techniques to cook the omelet faster. They do have disadvantages in the result that you will get.
Starting from here, in order to cut down the cooking time, you will need to use a larger pan / fewer  eggs so that you only get a a very thin layer of egg on it that cooks in just a few seconds.
The disadvantage here is that generally the omelet that you get will be somewhat dryer and less fluffy.
Alternatively .. or additionally, you may use a lot more butter / oil in the pan. This will transfer heat faster to the egg and you will be able to cook the omelet in a smaller pan. This method allows you also to have the pan hotter and reduce the cooking time even more.
The main disadvantage is that you will make it a lot more fatty than it is needed without adding flavor to the dish.
This are the main techniques that I see to make it faster. Personally, I prefer taking the extra 60 seconds that it takes to make it in the "standard" way described in the video as I tend to get a lot better results.
Essentially this is just a more detailed version of what Carmi suggested.

How to make omelettes extremely quickly


How do I obtain prediction intervals for fixed effects of Generalized Linear Mixed Model?

Question: Suppose I use R to fit a Generalized Linear Mixed Model from the binomial family and with a logit link. How do I obtain the prediction intervals (as opposed to the confidence intervals) for the fixed effects (as opposed to the random effects) in a way that incorporates the variability described by the random effects? Thank you.
Answer: We figured out a good way to do this that is good enough for our purposes (which is utilizing the predictive distribution to draw samples of empirically estimated fixed effects to calibrate an agent-based model). Here's the step-by-step process:

Simulate the $\beta_j$'s from the variance-covariance matrix output of the GLMM.
Sample the standard error of the standard deviation of the random intercepts from a chi-square distribution with $n - 1$ degrees of freedom. See this R-sig-ME post for details.
From the $\beta_j$'s estimated in step one, sample the $\beta_j$'s again from a normal distribution with mean equal to the $\beta_j$ and standard deviation equal to that sampled in step two.
Repeat steps 1-3 many times, saving the results at each iteration, to obtain an empirical predictive distribution of the $\beta_j$'s.
Comment: To expand on my comment: I'm not objecting to the basic concept, which I think is sound enough (I've done something similar to obtain prediction intervals for a GLM, and I've seen Ripley suggest the same procedure as I have used for GLMs), but I think it needs more explicit detail about the simulation, and a clearer justification of why it should be reasonable.
Comment: "*Simulate the $\beta_j$'s from the variance-covariance matrix output of the GLMM.*" --- from what distribution? The $\beta$s are fixed quantities. Do you mean to simulate some approximately pivotal quantity, about which you can make an asymptotic distributional argument?
Comment: Brash: Why wouldn't you just use parametric bootstrap? What you describe seems like a somewhat contrived version of it anyway. Also you give a wikipedia link, not a R-sig-ME one.  Step 3 confuses me; could you please give a reference where you saw this procudure? (Steps 1-3) @Glen_b: I think the OP wants to say that he takes account of the variability due to the VCV matrix of the random effects as well as the standard error - but I might understood wrong...
Comment: First thing's first: I fixed the link. It is now a R-sig-ME post.


How did my moon roof and all my windows open without anyone driving, touching or not being in the car in 2 -3 days?

Question: I have a 2009 Honda Accord EX 4 cylinder. Nobody had driven my car in 2 days, all windows were closed including the roof and the car was locked. On day 3 I left my driveway in another car and I noticed as we were pulling out that my moonroof and all windows were open. How did this happen? My remote doesn't even open my windows or moonroof. My doors were all locked also.
Who opened my entire car without even being near it ?
Comment: Had to have been a poltergeist. J/K! That's pretty crazy.
Comment: @Pᴀᴜʟsᴛᴇʀ2 my thoughts exactly or someone's playing a prank. i lean towards the ghost.
Comment: creeepaaayyyyy. Glad you got an answer.
Answer: According to the 2009 Honda Accord Owner's Manual, your car is capable of opening the windows and moonroof with the remote transmitter.

This is most likely the cause. The may have been pressed for accidentally in a fashion that triggered this feature.
Comment: I tried your suggestion and you are absolutely right! I was able to duplicate what had happened. You know your stuff. Thanks man.
Answer: Did you have the keys/remote in your pocket? Some cars (e.g. my VW Golf VR6) can open windows etc if you hold down the open button for several seconds. Did kids play with remote?
Comment: The OP stated "My remote doesn't even open my windows or moonroof." Also, this is more of a comment than an answer.
Comment: I didn't have a specific button on my remote for my golf for the windows, but, the functionality was there if you held the button down for long enough - some cars holding down the lock button for several seconds will cause any open windows to close as well.
Comment: That may be the case for your VW, but is that the case with a 2009 Honda Accord? Did you research is that capability is even available for that car? If so, by all means share it and it will validate your answer. We want to be careful we aren't making the assumption the OP doesn't know about their own car/remote. This is another example of why using comments is good for getting clarification before posting answers.
Comment: As you say "Do the research"... Perhaps the OP should read the manual before starting the engine...


Does combining two separate transformers double the voltage?

Question: Can I wire the outputs of two separate transformers to get twice the voltage? I have two separate, identical transformers from neon signs. Both put out 6000 volts at 30 mA. I would like to use 12000 volts for my project.
Comment: It's hard to do an internet search for transformers. You get all these robot things...
Comment: [Jim Lux](http://home.earthlink.net/~jimlux) has [an article on cascaded high voltage transformers](http://home.earthlink.net/~jimlux/hv/xfrmr1.htm) on his web page about this, which you should read.
Comment: Does your project require dc or ac and if ac do the transformers operate at the correct frequency for your needs? If dc what do you need at what current?
Comment: Try a voltage doubler circuit with a single transformer. Some sign transformers are center tapped to the housing, in which case 6kv could exist between the housings (danger) and breakdown to the primary windings will take place at some voltage.
Answer: In theory, yes. providing you get the phase correct. It would effectively be a 6kV - 0 - 6kV transformer.

Would I do it - NO. There is a good chance that the winding insulation will break down and the magic blue smoke will escape - even assuming a 50% safety margin they are not designed for that amount of voltage.
Comment: Suppose you ground the center of the secondary, so that you have two phases (180 degrees apart)  of 6kV output --- any worries about insulation breakdown in that case?
Comment: @Steven have you considered running the two in parallel (60mA) and then building a voltage doubler circuit (diodes/capacitors) designed specifically for 12kV.
Comment: @ThePhoton Yes - I'd still be concerned about the insulation between the primary and secondary coils breaking down (see Olin's answer also). There is still a 12kV difference between the ends.
Comment: the project requires 12000 volts 30 miliamps dc  , i suppose i coild scale down and use just one transformer , i am trying to use what i have to build a tesla coil ... i guess i could use just one and make the primary and secondary on the tesla smaller ???
Comment: @ jim i have not thought of that , how would i acomplish that task ?
Comment: @Steven rather than continue through comments ask another question. From what I can see of a tesla coil design you need AC not DC. You could just use the 6000V to excite the coil. Here's a tesla coil project that uses a 6.5kV transformer (near enough) http://www.instructables.com/id/Step-By-Step-Plans-to-Building-a-250000-Volt-Tesl/
Answer: Yes, it is possible.  However, note that there are two ways to "wire the outputs together", parallel and series.  In series, the voltages add at the same current.  In parallel, the currents add at the same voltage.  With your two 6 kV 30 mA outputs in series, you would get 12 kV at 30 mA.  In parallel you would get 6 kV at 60 mA.
Note also that the transformers will have a polarity.  The output is AC, but you can think of swapping the leads as causing a 180° phase shift.  If you connect the outputs in series but one of them is swapped, then you get 0 (to the extent the two transformers are identical and driven identically).
Yet another issue is that for the series connection to work as intended, the outputs need to be isolated.  A basic transformer secondary is isolated from the primary, but there could possibly be something like a ground connection between one side of the primary and one side of the secondary.  This is unlikely since the 6 kV would be much safer if it were completely isolated from the power line and ground, but it could be worth checking the transformers with a ohmmeter between primary and secondary.  Of course they must not be connected to anything except the ohmmeter at that time.
Then there is the issue of what the insulation between the primary and secondary can take.  There will be a 12 kV AC difference from one end of one transformer to the other end of the other transformer.  However, both transformers are driven from the same power feed, so the insulation capability between the input and output side needs to be bigger if you connect the two to add their output voltages.  That kind of insulation requires deliberate engineering, so very well may not have the extra margin to support a series connection.
Comment: @Steven: No, but it could cause something to catch fire.
Comment: i was worried about that ,if the insulation does break down there is the chance the high voltage could end up feeding back into the wall socket ???
Comment: Thank you for your help Olin i am a little worried about fires and what not so probably will not wire them in series
Answer: I have seen a friend of mine using five microwave transformers (2.1kV - 350mA) secondaries in series. The output did effectively become 10kV nearly, but the windings started to arc together.
To solve this issue, we he used the glue gun stick to fill all the gap between primary and secondary. It made the problem OK till 8kV transformer but the one with 10kV output still sparked.
I would recommend you re-wind these transformers ( if possible ) in the cascaded transformer shape or find alternate transformers.
Answer: I think two transformer rectifier output D.c can be connected in series together, howeever if the output rating of one transformer is more then reverse current can flow in the lower rated transformer resulting in damaging the insulation.
still the performance will improve abruptly.
Answer: Put the primaries in parallel with complimentary polarity. On the secondaries, both feed separate rectifier circuits feeding common filter capacitor bank. Make sure they are in-phase with respect to the rectifier circuits they are feeding. Both transformers must be identical.


How to install canon mf4720w printer in 14.04 LTS?

Question: Is it possible to install Canon MF4720W printer driver in Ubuntu 14.04LTS ?
Answer: If you are using linux right now, and open this link, you will find yourself at a canon page where your OS is detected and it will provide drivers for your printer.
Having said that, I feel I need to add that in the past year I've installed several printers of several brands under Ubuntu including but not limited to Canon, Epson and HP, and of these though Epson was the most difficult to install, by far, Canon was the LEAST FUNCTIONAL when installed.  It was a Canon WiFi Printer in which the wifi, though detected, refused to obey commands regardless of whether the orders came from Ubuntu, iMac or Windows.
So if you run into problems, please return it and get an Epson or HP.  I'm happy to make specific recommendations if you are interested.
Answer: Go to system settings -> printer -> and new printer.
Comment: *add instead of and
Comment: You can always [edit] your own posts, no need for comments.


Solar Cell to trigger Solenoid

Question: I would like to set up something where I use a miniature solar cell (like this) to power a push solenoid (something like this), so that when light hits the cell, the solenoid pushes. I know basically nothing about engineering, but I know that the 4 watts produced by the solar cell are not enough to push a 7 watt solenoid. How could I accomplish something like this?
Comment: Add another power source and use the cell just for trigger (relay or something).
Answer: It's much worse than you realize. First, the 4 you see is not 4 watts, it's 4 volts with no current. If you short-circuit the output you can get about 50 uA. Figure something on the order of 20 to 30 uA at something like 4 volts, or about 100 uW (microwatts).
There is simply no way do what you want with what you have. If you want to drive a 7 watt solenoid, you'll have to use a 7 watt solar panel. Or, if you're really desperate, you could use about 70,000 of those solar cells (I'm not recommending this, mind you, just tossing out suggestions).
If you have a separate source of power for the solenoid, you could use the solar cell to drive the gate of a power MOSFET which would turn on the solenoid, but that's really about as good as you're going to get.
Answer: It is easy enough to construct a solution to CONTROL a solenoid when light is detected by your miniature PV device or any other kind of light sensor.  However the POWER to pull in the solenoid must have a separate and independent source.
There are hundreds of example circuits like this online showing light-sensing circuits operating relays, solenoids, motors, etc.  The concept is the same for whatever kind of load.

Solar Cell to trigger Solenoid


What is the strongest way to fasten 8020 extrusions in this arrangement?

Question: I am making a project using 10mm aluminum extrusions. I am trying to connect all three extrusions like the picture below shows and I am going to make my own bracket (in red) out of aluminum since the variety of choices is very scarce for this 10mm size, but I will include a picture of something similar so you can get an idea of what I'm making. I am wondering which arrangement is stronger and more rigid- the left one, or right one? Or is there an even better way to do it?
Answer: If you consider the intersecting areas for the left side extrusions as being more evenly distributed, you should be able to expect that the load distribution will also be more even in that configuration. What's equally important is that you require equal strength over the three pieces. In the right side image, if the strength required on the angled portion is less, you can expect similar distribution of forces.
The gusset method you are considering is a common joining mechanism for extrusions primarily because of its ease and strength. You can increase the strength incrementally by adding straps on the inside of the angles attached with the channel nuts.
Comment: Would the brackets benefit from being straight edged instead of curved like in the picture?
Comment: It's not that you'd benefit from a curved edge. The removal of material along the stress lines means a weaker gusset. The equivalent would be as if you drew straight lines from the tangent of the curves to create new (smaller) triangles.
Answer: I would say the configuration on the right would be the best if you cut the top (vertical) extrusion at a 45 degree angle at the bottom where it meets the "45 degree strut". This way all the struts will be flush mounted together. Then you can add side straps and joining plates have the same geometry as the strut-intersection area.


Do AirPlay devices still work with iTunes on Windows?

Question: I use iTunes (ver 22.214.171.124) running on Windows 10 to manage my music library. I use AirPlay to stream music from that Windows machine to my Apple TV, which is connected to my home entertainment system. It works fine. I'd like to set up a separate AirPlay receiver so I can play songs into the sound system of a different room. Currently-available devices like the WiiM Mini AirPlay2 Wireless Audio Streamer claim to be AirPlay2 compliant (though I find no information about "AirPlay2" at Apple's website. Nevertheless, all the vague sales-oriented blurbs (from Apple as well as other vendors) say you can stream "from Apple devices" or "stream your favorite tunes from iOS and Mac devices". But does that still include iTunes running on Windows?
Answer: I ended up buying the WiiM device. The Windows version of iTunes connected to it without issue.


using a bump function

Question: I want to drift a $C^1$ function $g(x):\mathbb{R}^{+}\rightarrow \mathbb{R}^{+}$ to reach $"0"$ smoothly on some interval $[x_{1},x_{2}]$ and then drift it again to continue it's values on $(x_{2},\infty)$. I've found something about partitions of unity and bump functions but i'm a bit confused. Can i multiply $g(x)$ by the bump function that is $0$ on $[x_{1},x_{2}]$ and 1 outside it with just a small frame $(x_{1}-\epsilon,x_{1})$ in which it can fall from 1 to zero?
Answer: Yes, you can do exactly that.  It is the nice thing about bump functions.

using a bump function


How can I determine pressure inside contained cylinder when heat is added?

Question: I have a contained and thermally insulated cylinder of radius r. Inside this cylinder, there is water that reaches up to a certain height inside the cylinder (hw). There is a heater underwater that will supply thermal energy to the water at a certain wattage. The rest of the space is filled with air at atmospheric pressure (ha is the height the air occupies so that ha + hw = htotal).
I start supplying thermal energy at a given wattage to the water. My goal is to keep the water bubbling at a fixed rate for as long as I can control the pressure inside the vessel. I want to know:
How can I determine at what rate does the pressure increase? How do I determine the increase boiling point of water? How do I relate the input heat in wattage to bubbling rate? (evaporation rate?) I want to keep the water bubbling at a constant rate, how do I determine how the heater wattage should increase to match the increasing boiling point as the pressure builds up? Is there a reference for what a bubbling rate (evaporation rate?) looks like?
Comment: How will you control the pressure ? A safety valve sounds like it will be a good idea... Combined with a pressure switch that cuts the supply to the heater.
Comment: Is this something that you're actually doing, or a thought experiment?  If it's something real then you need to step back a bit and think about the design and fabrication of the vessel, including the design pressure, the materials of construction, and the safety features to be implemented - beginning with a relief valve and interlock as @SolarMike suggests.  Otherwise what you're building is a deadly bomb.
Answer: Nukiyama had a similar setup in his experiment, which failed to account for the leidenfrost effect. The net result is he fried his heater. This is why boiling with electrical wiring is such a tricky matter.
However, there are several equations that relate the heat transfer to the water. The main question you ask is how an enclosed vessel will react. This is pretty easy to see when you look at a Pv diagram for water:

The air above the container is never just air, but a mix of air and water vapor, or steam. Thus we will only be moving up in pressure as we heat to newer and newer constant temperatures. The temperature throughout the chamber can be roughly approximated as constant in both phases throughout this, if you're heating so fast this assumption isn't valid, then Lidenfrost effects will indicate that most heat is being transferred via radiation anyways and you're probably melting your heater with most materials.
The specific volumes of either phase change (as the liquid drops or more mass moves to the vapor phase), but the total specific volume of the entire water must remain the same. In other words, given any temperature as we climb, there is a specific saturation pressure that the vessel remains at, and:
$$v_gm_g +v_lm_l +v_am_a = V_{vessel}$$
This equation has two unknowns, the mass in the liquid phase and the mass in the gas phase, but the specific volumes of each phase are known at a given temperature, using steam tables. The mass of the air is known from the start, and the specific volume of the air at a given temperature is given via the ideal gas laws $v_a = \frac{RT}{MP}$ However, since $m_g + m_l = m_w$, which is known at the start, the masses of each at that temperature can be known.
Finding what time you will reach a specific temperature, and therefore pressure, is more complicated, but not terrible. This involves finding the enthalpy of each phase, subtracting the starting enthalpy, and dividing by the wattage.
Note that above the critical point, the liquid acts like a gas and the gas acts like a liquid and you can't find a line anymore. Then the line goes straight up. You may not reach the critical point - if your specific volume isn't identical to the critical point's specific volume than the path simply goes straight up from there until you reach maximum pressure.
Comment: Thank you, very helpful! I'm going through all the details you provided


Charge in the middle of a flat dielectric

Question: We know that due to external uniform fields, the dielectric atoms get polarized in the direction of the field, but what if the charge is inside the dielectric, the electric field of the charge is radial so will it be polarized upwards or downwards? In other words, will the bound charge density be positive downward or negative?
Answer: As you have noted "dielectric atoms get polarized in the direction of the field". This means that if there is a radial field coming from the center of the dielectric it will be polarized outward from the center (there is no upwards or downwards in this problem, there is inwards and outwards). Think of the dielectric a collection of dipoles and each dipole aligns itself with the field. If there is a charge in the center, all the dipoles will point outward and on all the external perimeter of the dielectric there will be a bound charge (positive if the central charge is positive).


What pump to use to pump latex?

Question: I am trying using pump to promote circulation of latex solution in a latex dipping tank. Is there any pump that suits this purpose? Also, is there any better ideas to promote circulation of the latex in the latex tank without handling the solution vigorously.
The explanation of main process can be found in this link.
https://www.youtube.com/watch?v=oTIADlYOkNc
Comment: Use a stirrer and regulate the speed.
Answer: You could consider using a flat plate stirrer or a helix depending on what you wish to achieve.
Controlling the speed of rotation will be useful as well.

What pump to use to pump latex?


How to move the main body content further down the page when it swaps to mobile design?

Question: When my website goes to 850px it swaps to mobile design, the issue is that I have a button that appears on both desktop and mobile mode but when it's at the beginning of mobile design which is 850 px the button is hidden under the header banner.  I want to push the whole website's main body content down.  I can do this in desktop mode with the CSS property as - margin-top: 200px and I am wondering if there is any @media or any other type of code that can change this just for the mobile design.
I have found that if I put the code of
 it does change it but surely there is a better way than just having a few
 in the button code and even that will just change it for desktop design.
Sorry if my explanation doesn't make much sense.
I will show my button code if this helps and if any other code is required to help can anyone just let me know.

    <a href="products.asp" <button class="button" style="vertical-align:middle">CLICK HERE FOR A NO OBLIGATION INSTANT QUOTE!</button>

Once again thank you for any help!
Screenshot of Desktop mode:

Screenshot of Mobile Mode with the button that is hidden under the top banner:
Comment: `it swaps to mobile design` how? Using media query?
Comment: can you provide an example produce your issue or screen shoot ...
Comment: Yes, I can provide a screenshot and yes using media queries to make it switch to mobile.
Comment: Added two screenshots of desktop design first and then mobile design second to my post.
Comment: just add margin-top to taht button on desire screen size using media query
Answer: Well, just put that top margin for your content wrapper into a media query below the other CSS rules, similar to this:
@media screen and (max-width: 850px) {
  .yourcontentdiv {
    margin-top: 200px;
  }
}

Comment: I tried this but it just changed it for desktop design, but I can try mess with it more to see if anything else I can think of might work.
Comment: seems like you are not addressing the right element (you didn't post enough code to see which element that could be). Use the developer tools in mobile simlulation mode and try there to find the right element
Comment: Right, just tried it again and I don't actually know what I was doing wrong as the code above was the same as mine just the pixel margin was set to 400px so that if it works It will be changed drastically to prove it worked sort of thing but it appears to be working now so, thank you haha


Change "Google.co.uk" to "Google.com"

Question: My Opera uses "Google.co.uk" instead of "Google.com" for searching. How can I change it to "Google.com" as default search engine? (with auto-suggest feature)
Answer: You can set a cookie so that your results are always global.
Just add NCR after the Google.com/  . this will set the cookie for global Google site. So next time the results will not be localized based on your country
http://google.com/ncr
Comment: That cookie is probably utilized by Google. But Opera is opening directly ```google.co.uk```, so it's not working.
Answer: I managed to change it on Windows 7 this way:
Edit the default_partner_content.json file located at:
C:\Program Files (x86)\Opera\(Version)\resources\
Or if you installed it in another place, then the resources\ folder is the same place where Opera.exe is located.
For the UK, the thing you are looking for is this sequence:
  "gb": {
    "other": {
      "list": [
        "google_uk",
        "yahoo",
        "bing",
        "amazon",
        "wiki"
      ],
      "speed_dial_index_list": [0]
    }
  },

just change "google_uk" to "google_com" there.
Everyone else, just look for your country on that list and edit it. I also changed the Wikipedia search, to look for articles in English.
Or, you could redefine what "google_uk" means. Look for www.google.co.uk, and switch it to www.google.com.
Everyone else, just replace the domains you have, with the ones you want to have.
Save, then re-launch Opera, and enjoy.
Comment: Mine was in C:\Users\(user)\AppData\Local\Programs\Opera\(version)\resources
Comment: Now I did this, and when I want to launch opera I get an error: `At least one file with recources (.pak) is corrupted. Please reinstall opera.`
Comment: Modifying this file in any way will result in the error
Comment: Opera has probably closed off their infrastructure even more. They've been losing transparency every year, which made me switch to Vivaldi.
Comment: Yeah well, I also tried this https://forums.opera.com/topic/2242/using-google-com-instead-of-google-xx and it didn't work, it suggested editing C:\Users\(username)\AppData\Roaming\Opera Software\Opera Stable
Comment: Because every time I changed anything in the json file it would get replaced with whatever it was before/
Answer: We are going to search for a file named Local State, it could be in a different location based on your installation (depending on where you installed the program).
Open up Opera, click on the O icon on top left sidebar, click on Help -> About Opera. On the opened window, under Browser Identification, you will see Paths. Copy and open the Profile Paths in Windows Explorer, and edit the Local State file with your favorite text editor:
Here's where I found mine:
C:\Users\user_name\AppData\Roaming\Opera Software\Opera Stable\Local State

Search for country and country_from_server and edit GB to US for both of them.
"location":{"country":"GB","country_from_server":"GB"}

Change it to:
"location":{"country":"US","country_from_server":"US"}

US will use google.com, but if you want to change it something else, here is a list with ISO country codes:
https://docs.oracle.com/cd/E53547_01/opera_5_04_03_core_help/iso_and_country_codes_23428_1.htm
Comment: Source: https://forums.opera.com/topic/7304/wrong-google-country/2
Answer: Country is based on your default Opera language.
To change it, click on "Preferred Languages" button in Settings / Browser / Language, choose your preferred language.
Preferred Languages screenshot
Restart Opera and this should work as expected.
Comment: I don't think so. I have it configured to use U.S. English, but it's still opening ```google.co.uk```. It's trying to detect your IP address and geo-locate it, so when you're using a VPN/proxy, it geo-locates it instead.

Change "Google.co.uk" to "Google.com"


About transitive subgroups of symmetric group $S_n$

Question: When I am studying Galois theory I came across some problems:
Let $S_n $ be the symmetric group on $n$ letters($|S_n|=n!$).How to determine all the transitive group     $G$ of  $S_n $ ( A subgroup $G$ of  $S_n $ is called transitive if for each $i,j\in \{1,2,\dots,n\}$,there is a $\tau \in G $ with $\tau(i)=j$).With some knowledge about group action, I can proof that if $G$ is a transitive group of  $S_n $ then $n$ divide the order of $G$.For $n=3$,I can easily find out all the transitive subgroups of $S_3$ because we can check each of its subgroup.But when $n$ is bigger ,for instance $n=4,5$ do we have to first find out all the subgroups of $S_n$ and then check which one is transitive.I want to know if we have a better method.\
Another question is given a transitive group $G$ of $S_n $ ,how to find a field $F$,and an irreducible polynomial $f(x)$ over $F$,so that if $K$ is the splitting of $f(x)$,then we have :
$$ G\cong Gal(K/F)$$
I even don't know how to get down to this question.Hope someone can help me.Thank you very much!
Comment: Hint for your second problem. Let $K=\mathbb Q(x_1,\cdots ,x_n)$ Then you can see a "natural" action of $S_n$ on this. Now if $G\subset S_n$ is a transitive subgroup, can you pick a suitable $F$?
Comment: I think the second problem is solved now, let $F$ be the fixed field of $G$,since $Gal(K/E)\cong S_n$,where E is the fixed field of $S_n$.
Comment: Upto isomorphism there are $5$ transitive subgroups of $S_5$.
(1) $\leftangle (12345) \rightangle$, (2) $\mathbb {AGL} (1, \mathbb F_5)$ of order $20$ , (3) $\mathbb {AGL} (1, \mathbb F_5) \cap A_5$ of order $10$ , (4) $A_5$ and (5) $S_5.$
Answer: Here's what Ian Stewart has to say on p. 268 of his book Galois Theory*:
The transitive subgroups [of $S_n$], up to conjugacy, have been classified for low values of $n$ by Conway, Hulpke, and MacKay (1998). … There is only one such subgroup when $n=2$, two when $n=3$, and five when $n=4,5$. The magnitude of the task becomes apparent when $n=6$: in this case there are 16 transitive subgroups up to conjugacy. The number drops to seven when $n=7$; in general prime $n$ lead to fewer conjugacy classes of transitive subgroups than composite $n$ of similar size.
In view of this I doubt if there is a simple formula or method to compute transitive subgroups or their conjugacy classes for general $n$. For $n\le30$ you could check out this page of the GAP data library.
*Ian Stewart, Galois Theory (Fourth Edition), 2015, CRC Press.


Is there a way to run a process every day in a .Net web application without writing a windows service or SQL server jobs

Question: We require that in a ASP.Net application, a .Net process should be invoked every day at a specified time automatically. This process needs to interact with the database (SQL Server 2005) and generate billing on a daily basis. We are using a shared hosting hence we are not able to create a windows service or create SQL Server jobs. How can this be achieved without user intervention?
Answer: You could try the technique described here, used at StackOverflow itself (or at least it was used here at one point). In a nutshell:

At startup, add an item to the HttpRuntime.Cache with a fixed
expiration.
When cache item expires, do your work, such as WebRequest or what have
you.
Re-add the item to the cache with a fixed expiration.

To get it to run at a specific time instead of an interval, you could lower the interval and simply modify your working method to check the time itself.

As the comments in the original article linked above note, this isn't a perfect solution, and no one should prefer it over a proper scheduling technique if one is available. See When Does Asp.Net Remove Expired Cache Items? for some additional qualifications.
Comment: Fixed expiration times are not fixed... they only *actually* expire when you attempt to ACCESS the cached item again. That's fine for a constant-traffic site like SO, but it is not dependable for sites where you can't depend on traffic to ping the site close enough after expiration (and hit the cache item so it expires) to perform the work when you need it.
Comment: @richardtallent: that is not correct, though the cache expiration mechanism is more complicated than I thought and requires more consideration before using blindly! See the link I've added to my answer for more details.
Answer: Yes, use Windows Scheduler. Depending on how it's configured you might need to be logged in for the scheduler to run.
Comment: on shared hosting no way to access windows schedule
Comment: But there is the option of placing a web service on the hosting environment and then having an external, always-on box invoke it.
Answer: You could always schedule a task to run a webservice..
http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx
The scheduler would run a VBS file with the following..
<code>Set oServerXML = CreateObject("Msxml2.ServerXMLHTTP")
oServerXML.Open "GET","http://my.hostedservice.com/myService.asmx/myService?aParam=Value
oServerXML.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
oServerXML.Send
Set oServerXML = nothing
</code>
Comment: The scheduled task would run on another server.
Comment: he said he is on shared hosting so no way to access windows schedule
Answer: Can't be done, unfortunately.
IIS only responds to requests, and SQL Server only wakes up for jobs.
The closest you'll be able to do is to put your routine in an ASPX page, not linked from the site and not with an obvious name, and trigger it by a request from some other machine out on the Internet.
The other machine could be a Windows, Linux, Mac, whatever you have available, and all of those platforms have ways of scheduling events (service, cron, etc.) that can make the request to trigger the update on the server.
Answer: There are ways to run "services" in .Net by using cache expiration to trigger the task.
More at CodeProject
Answer: You can use a Scheduled Task, but this might not work in a shared hosting environment either.
You could setup a webservice or page on your website to kickoff the process, then have a scheduled task on a desktop machine hit that page/service once daily to start the process.  Hacky, but it might work.
Answer: Being .NET ignorant, I would imagine there's some kind of .NET based scheduler framework available for this (much like Quartz for Java).
Or you could simply fire off a long running thread that spends the bulk of its time sleeping, wake up every minute, check the time, check it's list of "things to do", fire off the ones that need to be done. Level of sophistication being as far as you want to take it, but the primary goal of keeping the primary scheduling thread "alive", "at all costs".
Answer: What i can think about now are:

Create a dll which contain the
schedule logic you want, and make
sure that this dll schedule function
will not stop and will loop for ever,
then you will need a page on that
server this page will fire this dll
functions. "you will need to call
this page at least once to start the
scheduler".
Create an application "holds schedule logic" on another machine, may be your Home PC, and make your pc application call the functions on the server through webservices or pages


Conditional Expectation and Probability Density Function

Question: So given the joint pdf of $(X,Y) = 8xy$, as long as $0 < x < y < 1$ (and 0 otherwise). I got the conditional expectation to be $E(X|Y=y)=2y/3$ (if $0 < x < y <1$). Now I'm a little bit confused as how to get the pdf of the random variable $E(X|Y=y)$. Does this need a 1D change of variable (i.e. Let $Z=E(X|Y=y)$, then do a 1D change of variable as $Z=2Y/3$?) Or can I simply integrate this function from 0 to 1, with respect to the variable $y$? I'm practicing for an exam coming up and I'm struggling on this question. Any help is greatly appreciated. Thanks!
Answer: Note: $\mathsf E(X\mid Y=y)$ is not a random variable, rather $\mathsf E(X\mid Y)$ is.
But indeed $\mathsf E(X\mid Y)=\tfrac 23 Y$.   The probability density function of this random variable will be obtained by a change of variables transformation.$$f_{2Y/3}(z)=(3/2)~f_Y(3z/2) $$
And you should have found along the way that :$$\begin{split}f_Y(y)&=\int_0^y 8xy\mathop{\mathsf ds} \\[1ex] &= 4y^3\mathbf 1_{0<y<1}\end{split}$$
Comment: Oh ok I understand. So $f(z)=(3/2)(4(3/2z)^3)=81z^3/4$? Or should I express the answer in terms of y? (i.e. replace all the z with 2y/3?)
Comment: If you have $f_Z(z)$ on the left hand side, then the right hand side should be a function of $z$ too.  What you need to do is indicate the support interval.


what is cross compilation?

Question: what is cross compilation?
Answer: Cross-compilation is the act of compiling code for one computer system (often known as the target) on a different system, called the host.
It's a very useful technique, for instance when the target system is too small to host the compiler and all relevant files.
Common examples include many embedded systems, but also typical game consoles.
Comment: oh..so u compile code on one system..and deploy the executable in another system?
Comment: Yes. And the systems have different architectures.
Comment: Most smart phones use cross-compilation to the ARM architecture.
Answer: A cross-compiler is compiles the source code from one architecture to another architecture.
For example:  hello.c

gcc hello.c   (gcc  is a compiler for x86 architecture.)
arm-cortexa8-linux-gnueabihf-gcc hello.c
(arm-....-gcc  is a compiler for the arm architecture.) This you are compiling on the host pc for a target board (e.g rpi, beaglebone, wega board). In this example arm-cortexa8-linux-gnueabihf-gcc is called the 'cross compiler'.

This process is called cross compilation.
see the link for more info cross compilation
Answer: To "cross compile" is to compile source on say a Linux box with intent on running it on a MAC or Windows box. This is usually done using a cross compilation plugin, which are readily available from various web servers across the net. If one is to install a cross compilation plugin onto their Linux box that is designed to compile for Windows boxes. Then they may compile for either a Linux/*NIX box as well as have the option to compile and link a Windows-ready executable. This is extremely convenient for a freelance programmer whom has access to no more than a single Linux/Windows/MAC box. Note that various cross compilation plugins will allow for multitudes of applications, some of which you may or may not perceive as useful, thus a thorough perusal of the plugin's README file.
Did you have a particular project in mind that you would like to apply the method of cross compilation to?
Answer: In a strict sense, it is the compilation of code on one host that is intended to run on another.
Most commonly it is used with reference to compilation for architectures that are not binary-compatible with the host -- for instance, building RISC binaries on a CISC CPU platform, or 64-bit binaries on a 32-bit system.  Or, for example, building firmware intended to run on embedded devices (perhaps using the ARM CPU architecture) on Intel PC-based OSs.
Answer: A Cross Compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running.
For e.g. a compiler that runs on a Windows 7 PC but generates code that runs on Android smartphone is a cross compiler.
A cross compiler is necessary to compile for multiple platforms from one machine.
A platform could be infeasible for a compiler to run on, such as for the microcontroller of an embedded system because those systems contain no operating system.
In paravirtualization one machine runs many operating systems, and a cross compiler could generate an executable for each of them from one main source.

what is cross compilation?


NetStream.seek in "Data Generation Mode"

Question: I created a flv player using the method NetStream.appendBytes for entering data into the buffer.
For now, I perform the seek action in this way:
ns.seek (0);
ns.appendBytesAction (NetStreamAppendBytesAction.RESET_SEEK);
ns.appendBytes (seekPosBytes);
Like I've read here
I perform a seek(number) (which from what I've understood flushes the buffer) and beginning to incorporate the new bytes (those related to the position from which I start to play).
This means that even if the entire video is loaded, the buffer is emptied and everything has to be reloaded.
It is possible to seek using the data already loaded into the buffer using the method NetStream.appendBytes?
Answer: have you tried setting the netstream's inbufferseek property to true?


What is the effect of masturbation on weightlifitng ability?

Question: For years I'm listening from everyone that we have to stop masturbation and also limit sex as it let down process of gaining muscle. Also everyone in gym suggests me to completely stop masturbation.
Is there any effect of masturbation and sex on gaining muscle through gym workout?
If there is any effect, then is the effect and quantity of effect is same for masturbation and sex or they are different.(Because I'm more concerned about masturbation here, and not sex).
I read a on link Effect of Sex/Male Orgasm on Athletic Performance on this site about it, but it discusses on effect on Athletic performance, and I'm concerned about effect on muscle gain. Because I'm not athlete, I'm 29 years old weighting 69 kg who is not related with any sport and just want to gain muscle.
Comment: About this: **"Also everyone in gym suggests me to completely stop masturbation."** Why are you talking to **everyone in the gym** about this?
Comment: Not really an answer, but this is what Mark Rippetoe thinks about this question: http://startingstrength.com/resources/forum/showthread.php?t=9540&s=f7267b0882d4569ce7f47b6b69304286, http://startingstrength.com/resources/forum/showthread.php?t=8076&s=f7267b0882d4569ce7f47b6b69304286. He obviously doesn't think it affects you significantly.
Comment: @jp2code Why wouldn't he? Is masturbation a secret, something shouldn't be discussed, a prohibited topic?
Comment: On the other hand, you burn calories during the process; if you can last longer, you can work up a good sweat :)
Comment: @jp2code because here in India, everybody(including trainer) will definitely tell you, sooner or later, to stop masturbation(or sex), as they say it weakens you and brings lower back pain
Answer: Peer reviewed literature on testosterone appears to have inconsistent conclusions, however, the well designed studies all agree that abstinence raises T.
Some studies say that masturbation raises T, and some that abstinence does so. But the well-designed studies all conclude that abstinence raises the baseline amount of T in your body. Well designed studies measure blood T levels for at least ten days after a masturbation event. One frequently cited study only compared T levels a few hours before and after the masturbation event, which lead its authors into an incorrect conclusion.
It is true that there is a  brief spike in T during and after sexual activity that lasts a few hours at most, before returning to a baseline level, b. But 5 days after an ejaculation event, blood T levels begin rising, and flatline at about 1.5b on about the 7th day after masturbation (presumably, after any orgasm). They stay at this highly elevated level until you orgasm again.
Long story short: protracted abstinence dramatically raises your T level.
And the best part is, you don't have to take anyone's word for it. Just try it for yourself and you won't doubt it anymore. The effects of that extra testosterone are powerful. I assure you that you won't be able to mistake the difference. The strength, motivation, clarity, and drive that you feel after protracted abstinence has been noted by men throughout the ages, and all across the globe. To give an extreme example, the Spartiate warrior caste lived in barracks their entire lives, and only had carnal knowledge of their wives when they were able to sneak out (at the risk of formal censure). The warriors of the Maori, the indigenous inhabitants of New Zealand, widely famed for their ferocity in battle, engaged in rigorous, extended periods of sexual abstinence in preparation for war.

Sources
Endocrine response to masturbation-induced orgasm in healthy men following a 3-week sexual abstinence.
This current study examined the effect of a 3-week period of sexual abstinence on the neuroendocrine response to masturbation-induced orgasm. Hormonal and cardiovascular parameters were examined in ten healthy adult men during sexual arousal and masturbation-induced orgasm. Blood was drawn continuously and cardiovascular parameters were constantly monitored. This procedure was conducted for each participant twice, both before and after a 3-week period of sexual abstinence. Plasma was subsequently analysed for concentrations of adrenaline, noradrenaline, cortisol, prolactin, luteinizing hormone and testosterone concentrations. Orgasm increased blood pressure, heart rate, plasma catecholamines and prolactin. These effects were observed both before and after sexual abstinence. In contrast, although plasma testosterone was unaltered by orgasm, higher testosterone concentrations were observed following the period of abstinence. These data demonstrate that acute abstinence does not change the neuroendocrine response to orgasm but does produce elevated levels of testosterone in males.
Orgasmic frequency and plasma testosterone levels in normal human males.
Twenty males participated in a 2-month study examining the relationship between 8 a.m. plasma testosterone levels and orgasmic frequency. Within subjects, higher levels of testosterone are associated with periods of sexual activity. Over subjects, however, the direction of the relationship is reversed. Mean testosterone levels were higher for sexually less active individuals.
A research on the relationship between ejaculation and serum testosterone level in men.
The authors found that the fluctuations of testosterone levels from the 2nd to 5th day of abstinence were minimal. On the 7th day of abstinence, however, a clear peak of serum testosterone appeared, reaching 145.7% of the baseline (P<0.01). No regular fluctuation was observed following continuous abstinence after the peak. Ejaculation is the precondition and beginning of the special periodic serum testosterone level variations, which would not occur without ejaculation. The results showed that ejaculation-caused variations were characterized by a peak on the 7th day of abstinence; and that the effective time of anejaculation, is 7 days minimum. These data are the first to document the phenomenon of the periodic change in serum testosterone level; the correlation between ejaculation and periodic change in the serum testosterone level, and the pattern and characteristics of the periodic change.
Comment: I removed the downvote, although I still believe the answer lacks the conclusion (that masturbation has an effect) it is still a lot better that other answers I have not downvoted. As I normally don't downvoting if I disagree with an answers content. Your comment _"Go find your own sources"_ simply sounded like _"go fudge yourself"_ and made me mad. Sorry about that.
Comment: Even if abstinence raises testosterone your answer lacks to show that this really has an effect on muscle gain. As working out increases testosterone levels as well. So does the increased base testosterone through abstinence still have an effect compared to this or is it negligible?
Comment: T is well-known to raise lean mass gains.
Comment: And I don't doubt that, but working out increases testosterone levels, too. So, is the effect of abstinence still measurable after workouts?
Comment: Yes. Go find your own sources.
Comment: That's amusing. The best, and most important, answer that I've made on this site is the only one that's been downvoted. Why?
Answer: One of the reason why masturbation is believed to have an effect on muscle gains is because it influences the testosterone levels. Recent research suggest that natural levels of testosterone simply have no effect on muscle gains.

New research from scientists at McMaster University reveals exercise-related testosterone and growth hormone do not play an influential role in building muscle after weightlifting, despite conventional wisdom suggesting otherwise. […]
"A popular mindset for weightlifters is that increased levels of hormones after exercise play a key role in building muscle," explains Daniel West, lead author of both studies and a graduate student in the Department of Kinesiology at McMaster. "That is simply not the case."
In the first study, researchers examined the responses of both male and female participants to intense leg exercise. Despite a 45-fold difference in testosterone increase, men and women were able to make new muscle protein at exactly the same rate.
"Since new muscle proteins eventually add up to muscle growth, this is an important finding," says West.
"While testosterone is definitely anabolic and promotes muscle growth in men and women at high doses, such as those used during steroid abuse, our findings show that naturally occurring levels of testosterone do not influence the rate of muscle protein synthesis."

Source
Comment: Then why do men who work out a lot (or a little) tend to have greater muscle mass than women?  According to this study, men and women should be able to gain muscle at the same rate, which is just silly.  It might be true that the infinitesimal initial gains due to going from sedentary to active are the same in both populations (as this study maybe shows), but that tells you nothing about how those gains are going to change over time.  Maybe the males (due to higher T) will continue gaining at the same rate for months, while the females will start to taper off after a few weeks.
Comment: Then integrating the infinitesimal gains over time will yield a much greater muscle mass for the male.  The conclusion of this study is just bogus.
Answer: EDIT: Take this answer with a grain of salt. See masonk's comments below.
Short version: sex and masturbation are no problem for muscle gain.
Long version: several studies have looked at sex, including these:
link 1 -- found no relation between sex and maximal exercise performance
link 2 -- sex actually stimulates testosterone production
link 3 -- found no relation between sex and maximal exercise performance; furthermore, found no diminishing of mental concentration ability after sex
regarding masturbation specifically:
link 4 -- levels of testosterone (among other hormones) increased after masturbation, even though they do not increase if you merely think about masturbation
link 5 -- similar to previous one
I got this info from a post by Goldie at the AskScooby forum. I'm a member of that forum, and I have had a look at some of these links in the past.
I'd like to add a general advice: don't trust what you read on the Internet. While some sites usually post reputable information (like NYT, for example), the vast majority of websites post anecdotal evidence; this is especially true regarding fitness and nutrition. When you want to search for information, go to reputable places like PubMed (for anything) or Nutrition Data (for quick nutritional info) and search those sources directly.
Comment: This is incorrect. Links 2 and 3 above are not peer reviewed journals and don't properly cite any peer reviewed articles either, but three describes a study that only looked 10 hours past an orgasm event.
Comment: I can't get full text on 4. 5 is terrible study as well. It uses a survey followed by a single T assay to correlate sexual activity with high T. But there are many cofounding factors here. For one, people with naturally high T are probably more likely to have a lot of sex or masturbate. This doesn't mean masturbation raises T, which is the unfortunate conclusion that the authors have drawn.
Comment: @masonk: thanks for bringing it up. I'll edit the original post to draw attention to the possible inadequacy of these links; readers can then judge for themselves if they have access to the papers. Sadly, I don't have the time to go read these links carefully in the near future.
Answer: I have read that actually it is good to masturbate and doing sex because it release testosterone during one of 2 hours after you do it, and testosterone is good for gaining muscled.
So I don't really think it is good to stop for your own spirits and body you have to feel good in your body.
Comment: I have read a lot about it on net, and there are vary contradictory answers. Most of them say no or negligible effect, some suggest to completely avoid masturbating while some say positive effect. Totally confused. :(
Comment: I removed the unnecessary information (as it adds no value to the answer), if you feel unhappy with the changes feel free to revert them or edit again.
Answer: Would like to offer a few short statements:

Your testicles get 'dibs' on protein.  (debatable)
Those who ascribe to the concept of energy-flow Ki or Chi are likely to indicate that masturbation redirects your vitality and causes 'diffusion'. (debatable)
Frequent masturbation is a good work out for one arm at least. (empirical)