Does tuning music to A = 432 Hz versus A = 440 Hz have a measurable effect on listeners?

Question: A brief internet search for "432 vs 440" will bring up a large number of chat discussions and videos discussing whether the tuning makes a real difference. These often seem to boil down to the question of whether people can perceive the difference in music tuned one way versus the other.
But I think the more important question is: does the tuning have an effect on the perception of music, regardless of whether that perception is conscious?
In other words, I'm not interested in whether someone, hearing music tuned one way or the other, can identify which is which. I'm just wondering whether there is objective evidence for a measurable effect.
Comment: On RationalWiki: [A440 - Conspiracy theories and woo](https://rationalwiki.org/wiki/A440#Conspiracy_theories_and_woo)
Comment: different but related: [Is there any objective evidence that different keys "feel different" or have different moods?](https://music.stackexchange.com/q/93535/37941)
Comment: @ElEctric but powers of two _what_?  The second has no intrinsic place in physics.  The duration of the second arises ultimately because of a fashion for dividing things into twelfths and sixtieths.
Comment: As I recall, this created a major uproar back in the 60s, when someone (was it the guy leading the NY Philharmonic?) decided to change the standard for his group.
Comment: There's a ton of pseudoscientific crud surrounding 432 Hz A unless you're talking about "scientific pitch" where all C notes' frequencies are powers of two.
Comment: @HotLicks the guy in charge of the NY Phil in the 1960s was Leonard Bernstein, but I can't find any mention online of a tuning uproar in that or any other American orchestra in the 1960s.  Many if not most of the major symphonic orchestras tune somewhere between A=442 Hz and A=445 Hz, however, and as far as I understand some of them have been doing it since as long ago as the middle of the 20th century, at least.  It wouldn't be surprising, though, for a change in the pitch standard to cause controversy.
Answer: Yes. When you tune music up or down people hear it differently. Everyone agrees on that. Pitch it down and it will sound warmer, pitch it up and it will sound brighter. This happens all the time when we decide to transpose a piece up or down a half step (say, from C to C#). If you transpose a piece by less than a half step (say 20 hz or so) then you get a less dramatic version of the same effect.
But despite what another post says there is nothing special about 432 hz in particular. Some people think so because of an (anti-Semitic?) conspiracy theory about the geographic resonance of the earth and some bad math. But they are wrong.
They might revoke my PhD for saying this but actually here's a youtube video by Adam Neely that does a MUCH better job of explaining the 432/440 debate than the bogus academic papers cited by another post.

Here's the basic issue. If you turn piece of music down by some amount it will sound "warmer." Maybe you like that, maybe you don't, but there is NO mathematical or psychoacoustic reason why 432 should be objectively "better" than 440 or 432 or 428 or whatever.
As for that paper. I'm a statistician as well as a musician and I can tell you that just because something is published in a peer reviewed journal (especially in an Elsevier journal) doesn't mean it's not bogus. I just looked at the first paper cited (from 2019) and it is clearly bogus (because I'm in academia I can actually read it even though it's pay-walled).
First of all, the study itself is tiny (only 30 or so subjects) and badly designed.
Second, note that they ONLY compared 440 vs 432. They didn't check whether what would have happened if they compared 440 to some other random "lower" tuning (say 428). And although they measured a bunch of stuff only a few of the results were statistically significant, which (to statisticians) is a marker that they engaged in what we call "p hacking," which is kind of like searching through every verse in the bible until you find one that seems like it predicted 9/11. So at BEST they only showed that "turning music lower means it's more relaxing." But we already knew that. And we don't always want our music to be "relaxing."
Thirdly, if you read between the lines of their introduction (and look at their citations), you can tell that the authors buy into the Lyndon LaRouche/Shiller institute's "the earth vibrates at 432 and there is a worldwide conspiracy to keep the truth from the masses" conspiracy theory.  So they probably designed this study specifically to build support for their conspiracy theory.
Maybe the other studies are better (although one of them is just someone's undergrad thesis), but I wouldn't bet on it. Unless they compared other frequencies aside from 432 to 440 (and it doesn't look like any of them did) then they haven't shown that there is anything special about that frequency in particular. They probably would have gotten the same results if they chose 431 or 433 or 435.
Comment: Any discussion of mathematical "elegance" in relation to Hz is problematic since the numbers you get are based on our arbitrary decision to divide a minute into 60 seconds, and the fact that we use a base-10 number system.  If we divided minutes into 100 seconds and used a binary number system then different frequencies would seem more "mathematically elegant." But none of this has any relation to how they sound.
Comment: Personally I think the elegant thing to do would be to base everything on the Planck frequency. This leads to roughly A=425 Hz (if we declare the Planck frequency to be an A) or A=451 Hz (if we declare it to be an Ab).
Comment: https://en.wikipedia.org/wiki/Schiller_Institute
Comment: Not sure I feel like your 1st paragraph says. Having played for 60 odd yrs, sometimes the same pieces in various different keys, the feeling of those transpositions didn't reflect what you say - to me. O.k. some orchestras prefer to tune higher for that sort of effect, but I wonder whether that affects strings, say, more than any others. I'm sceptical of the whole concept. Maybe if I was 'blessed' with AP it would be different.
Comment: I thought the question was asking whether A432 vs. A440 has any effect, not whether A432 has any more potent effect than, say, A428. If your answer addressed A428 vs. A440 instead but found A428 to have "A432-like effects" compared to A440, I'd actually ask you to rephrase but not scrap it.
Comment: "since the numbers you get are based on our arbitrary decision to divide a minute into 60 seconds, and the fact that we use a base-10 number system" As well as the fact that the duration of the minute is somewhat arbitrary in the first place.
Comment: Mathematically, I think there would be a certain elegance to saying that C4 is 256.0Hz, which would lead to an equal-tempered A being 430.5, but equal temperament isn't the most musical, and on many instruments even making octaves be perfect powers of two isn't ideal.
Comment: Where can I learn more about this "anti-semitic conspiracy theory?"
Comment: "Pitch it down and it will sound warmer" on the same instrument, yes.  On different instruments, probably not.  Tune a piano to A flat = 432, though, and play a piece a half step lower than notated, and it will no doubt sound brighter.
Comment: @GrahamWright right, but seconds aren't going anywhere, clocks will always be based on them, and that does mean if we're going to base something on any "universal temporal raster", then seconds are our best bet. Not for any physical reasons, but for a _convention_ one: it's a unit that is basically universally agreed upon.
Comment: Thank you so much for pointing out that studies are often total crap.  What a super answer!
Comment: https://en.wikipedia.org/wiki/Hearing_range#/media/File:H%C3%B6rfl%C3%A4che.svg might also be useful in that discussion
Answer: A definite NO.
The other answers miss the point and answer a different question altogether.
When you tune music up or down people hear it differently. Everyone agrees on that. Pitch it down and it will sound warmer, pitch it up and it will sound brighter.
But...
This has nothing to do with tuning. If you write a piece in A (=440) you can pitch it down to A(=432), and yes, it will sound "warmer". Does that make (A=432) tuning warmer or brighter? No, because you can pitch the same piece down further to (A=415.3), making it even warmer. But this "supersuperwarm" tuning is 100% the same as using our original (A=440) tuning, but simply transposing down by a semitone to G#.
In short, no argument about pitching up or down applies to discussions about tunings, because you can transpose melodies regardless of the tuning.
The thing that does matter is whether you use the equal-temperament or some other system. But this has nothing to do with the absolute pitch of A.
The absolute pitch of A might be baked into some instruments and perhaps even environments (due to resonance) but this makes the question still different: "do our tools impose constraints on the absolute pitch of A that we use".
TLDR (added after reading one of the comment)
Changing the root of tuning does not bring anything that wasn't already covered by transposition.
Moving melody up and down does change how it sounds - due to how our brains work and how instruments are built, but musicians have been using that trick for centuries, using semitone steps. There is no indication that using SMALLER steps will have BIGGER impact. And no logical reason why such impact, if any existed, would take form of a single value, universal across different instruments and brains.
Comment: Thank you! I was finding myself agreeing a lot with the other responses, but feeling that something was missing, and this was it. :)
Comment: @NuclearHoagie Proponents of the A=432 suggest that it's somehow "better", because it's lower - so it has a special "lower" quality. I say that making something "lower" does not require tuning - it's enough to transpose. There might me (I don't think there are) some arguments for the A=432, but if they say something along the line of "it's lower", then they are objectively wrong.
Comment: It's quite possible that A415.3 is actually "so warm that it's distressing", at least to those literates with absolute pitch who read the title of a piece such as "Minuet in G Major" and find that the piece is not playing in G Major. (Granted, I do typically find those downtuned Baroque pieces no warmer and the rare Baroque organ music uptuned by *a whole step* no brighter.)
Comment: I don't really follow the argument being made here. I'm not sure why you're accounting for pieces that are both retuned and transposed - tuning and transposition will both affect how a piece sounds, but I don't see why the fact that they could possibly "undo" one another is relevant. If you argue that tuning has no effect on listeners, I'd think you could make exact same argument that transposition has no effect, either - "no argument about pitching up or down applies to discussions about transpositions, because you can retune instruments regardless of the transposition".
Comment: I like the way you're thinking, but this answer only works under that assumption that *transpositions* of a piece (read: remaining w/in A=440Hz) are perceived identically to the original. Since the question is whether 432 is perceived identically to 440, I think you may be assuming the conclusion here. The notion that frequency-shifts by a constant ratio are imperceptible is to be called into question in a question like this.
Comment: @user45266: This is not how I see it, I will make an edit to make the point clearer.
Comment: After reading the edit, I think the devil's-advocate stance is that pitch memory can make 440 different from 432. It's not entirely trivial to prove that listeners have no ability to tell whether a piece is in 440Hz or not. Western society members spend practically their entire lives surrounded by A = 440Hz music. Could they not develop some memory (conscious or not) of what 440 sounds like? What you're saying makes a lot of sense to me personally, but it's hard to **prove** that humans (even barring perfect pitch) have absolutely **no** sense of what frequencies fit into the music they know.
Comment: There has been at least [one study](https://apexlab.uchicago.edu/docs/papers/Long-termPitchMemory.pdf) reaching the conclusion that people have some ability to pick the right pitch level for music. The extent of this is not clear yet, but it's evidence that perhaps non-440 tuned music could have some effect compared to A = 440Hz.
Comment: @user45266 the study seems to support my position. It shows that even for: 1) a well known melody, 2) a well known performance, 3) a whole semitone in difference - only some people can tell the difference more often than by chance. The original question was about: 1) a completely new melody, 2) arbitrary performance 3)  a much smaller difference in pitch, 4) "generally" as opposed to "some". And it was not just about the tune being "different than I remember", but about it having "a different perception".
Comment: @fdreger Those are fair points. I don't know if I'd say that study *supports* your position, maybe just that it *contradicts it less* than my initial thought. I'm still not convinced that people couldn't possibly have *any* idea of whether something is A = 440Hz or not. (I'm not even a believer in the stuff about 432 anyhow, I don't know why I'm taking this so far :P)
Comment: I still don't get it. You can re-tune your violin so that the A string now plays a G# while fingering normally, or you can transpose the piece and finger differently so that you play a G# instead of an A on a normally tuned instrument. Both should sound almost identical, so I don't get why one "counts" and one doesn't. They are physically distinct ways to achieve the same sound - you can transpose a piece and it'll sound different, or re-tune your instrument and it'll sound different. The fact that you could have transposed instead of retuning doesn't mean that the retuning had no effect.
Comment: @NuclearHoagie Both count exactly the same. The 440/432 debate is about claims that using 432 as an anchor point instead of 440 is somehow _more_ meaningful and _more_ pronounced than transposing. I think that this does not hold water.
Answer: Whenever, I read a claim that some values of any measurement (musical or not) are special due to mathematical properties of the numbers, a crackpot warning light turns on in my head but my first question is whether or not the measurement is dimensionless.  If it is then I will read on a little before assigning it to the crackpot category.  However, if it is not dimensionless then the claim is immediately dismissed.
A dimensionless quantity is not dependent on some arbitrary unit of measure.  If we met an alien civilisation then we could expect them to agree on the values of dimensionless quantities.  Examples are the mathematical constant pi or the number of protons in a carbon atom. If I saw an article claiming that atoms with prime numbers of protons had a special property then I might read on (but my crackpot warning light would remain on).
However, frequency is not dimensionless.  The 440 marked on my tuning fork is dependent on the definition of the second which is highly arbitrary.  The current definition is very technical and irrelevant in a music group but the original definition relates to the length of the day of this planet together with historical decisions to split it into 24 hours, hours into 60 minutes, and minutes into 60 seconds.  Our alien would be highly unlikely to share this definition and hence they would probably not agree that my tuning fork was 440.  If our civilisation collapsed and another human civilisation developed without access to our knowledge,they would probably not agree.  Even if they also decided on 24 hours per day etc, they would have a different length of day as the rotation speed of the Earth is not constant. When we learned this, we had to add to the definition of the second that it referred to the specific day 31 December 1899.
So, the particular numbers we assign to various frequencies are massively unlikely to have any special significance. If the French had succeeded in decimalizing time along with other measurements (mass, distance, etc) then we might be using the same tuning today but we would not call it 440.  If we had chosen a different reference year then the numbers would be close but still slightly different.
Comment: A good point but that seemed to be already well covered.  So, I just concentrated on whether 432Hz could be special.  My point was that both it and 440Hz are arbitrary.
Comment: Solid reasoning on why the number itself can't have much meaning. This addresses why 432 isn't special. However, I don't think your answer addresses why A = 432 cannot be any different from A = 440... *(in the sense that 431 and 433 or any other random Hertz value could also be different simply because they* aren't *a 12-EDO transposition from A = 440)*.
Comment: @user45266 twelve-tone equal temperament is also fairly arbitrary.  Why would A=415.3 Hz be any different from A=422.4 Hz or A=412.5 Hz?
Answer: A ratio of 3/2 still yields a fifth. A perfect cadence doesn't become deceptive by changing from 440 to 432. On the other hand, after a hard Saturday night, it may be easier for choir members to sing in C# or even C rather than in D.
Setting A to 417 has also been suggested as the "Solfeggio Frequencies" but how accurate was Guido's clock?
There are other pseudo-scientific claims made for various tunings (just, Pythagorean, various meantone tunings, Wendy Carlos recirculating, various Werkmeister suggestions, Vincenzo Galileo's 18/17 ratio...
Also 17, 19, 29, 31, 41, 53 etc. equal tunings. Not to mention the difference between the son clave and rumba clave.
Comment: What's the theory behind 417?  Anyway, clocks did not have minute hands until several centuries after Guido, let alone second hands, so however accurate his clock may have been, it certainly was not precise enough to measure audible frequencies.
Comment: Tuning to 417 is suggested by "Solfeggio Frequencies" which another pseudo-scientific music and health theory. I didn't bother to figure out why. I do know the 432 was used in the 1800s because it has lots of divisions and makes lots of intervals (not minor thirds though) into integer frequencies.
Comment: At 417 the note is much closer to what we consider Ab in standard A440 tuning. You might as well say you're tuning to 441.8.
Answer: Only if your playing along with original tracks or others tuned in a different key. Otherwise I've used all from 428 to 450 htz.
No htz changed myself, my sleep, my audience.
Answer: Yes, there is evidence to suggest that music tuned to A = 432 Hz induces both physiological and affective changes in comparison to A = 440 Hz, and that those effects point to a general "relaxation" of mind and body.
The journal EXPLORE, in 2019, published the article "Music Tuned to 440 Hz Versus 432 Hz and the Health Effects: A Double-blind Cross-over Pilot Study."1 That study found that

432 Hz tuned music was associated with a slight decrease of mean (systolic and diastolic) blood pressure values (although not significant), a marked decrease in the mean of heart rate (−4.79 bpm, p = 0.05) and a slight decrease of the mean respiratory rate values (1 r.a., p = 0.06), compared to 440 Hz. The subjects were more focused about listening to music and more generally satisfied after the sessions in which they listened to 432 Hz tuned music. (SOURCE)

2020 saw the publication of two studies.
A randomized trial of 42 dental patients2 demonstrated

Significantly lower anxiety level values were observed at 432 Hz (8.7±2.67) and 440 Hz (8.4±2.84) compared to the control group (17.2±4.60; p<0.05). The salivary cortisol level at 432 Hz (0.49±0.37 μg/dL) was significantly lower than 440 Hz (1.35±0.69 μg/dL) and the control group (1.59±0.7 μg/dL; p<0.05). (SOURCE)

And later that year, an Italian study3 of the sleep effect of tuning on 12 spinal cord injury patients found that

After listening to music at 432 Hz there was a significant improvement in sleep scores (+3.6, p=0.02), while there was no improvement in sleep scores listening to music at 440 Hz (-1.50, p=0.34). (SOURCE)

In 2021, International Journal of Human Sciences published "The magic of frequencies - 432 Hz vs. 440 Hz: Do cheerful and sad music tuned to different frequencies cause different effects on human psychophysiology? A neuropsychology study on music and emotions". That study concluded that

In the most comprehensive analysis with no reference to the cheerful or sad character of the sample, the participants who listened 440 Hz pieces reported rather negative mood after listening music compared to the participants who listened 432 Hz pieces. Moreover, men were observed to report even higher levels of negative mood after listening 440 Hz pieces, compared to their mood after listening 432 Hz pieces. All the findings thus reached imply that different tunes lead to variation in reported moods, even though they do not bring about changes in sympathetic and parasympathetic activation levels. (SOURCE)

An earlier study was made in 2018 by an undergraduate student in Sweden.3 That study concluded that there was no significant difference in emotional responses; it did not look at physiological responses.

1 Calamassi, Diletta, and Gian Paolo Pomponi. 2019. "Music Tuned to 440 Hz Versus 432 Hz and the Health Effects: A Double-blind Cross-over Pilot Study." EXPLORE, 15 (4): 283-290. https://doi.org/10.1016/j.explore.2019.04.001
2 Ravena, Pedro Christian, Camila Almonacid, and Marcelo Ignacio Mancilla. 2020. "Effect of music at 432 Hz and 440 Hz on dental anxiety and salivary cortisol levels in patients undergoing tooth extraction: a randomized clinical trial." Journal of Applied Oral Science, 28, e20190601. Epub May 11, 2020. https://doi.org/10.1590/1678-7757-2019-0601
3 Calamassi, Diletta, Alessia Lucicesare, Gian Paolo Pomponi, and Stefano Bambi. 2020. "Music Tuned to 432 Hz Versus Music Tuned to 440 Hz for Improving Sleep in Patients With Spinal Cord Injuries: A Double-Blind Cross-over Pilot Study". Acta Bio Medica Atenei Parmensis 91 (12-S), e2020008. https://doi.org/10.23750/abm.v91i12-S.10755.
4 Erdal, Barış, Yeliz Kındap Tepe, Serdar Çelik, Büşra Güçyetmez, Burhanettin Çiğdem, and Suat Topaktaş. 2021. "The Magic of Frequencies - 432 Hz Vs. 440 Hz: Do Cheerful and Sad Music Tuned to Different Frequencies Cause Different Effects on Human Psychophysiology? A Neuropsychology Study on Music and Emotions: Frekansların Sihri – 432 Hz 440 Hz'e karşı: Ayrı Frekanslara göre akortlanmış neşeli Ve hüzünlü müzikler Insan Psikofizyolojisi üzerinde Farklı Etkiler yaratır mı? Müzik Ve Duygular üzerine Bir nöropsikoloji araştırması". Journal of Human Sciences 18 (1):12-33. https://doi.org/10.14687/jhs.v18i1.6108.
5 Palmblad, S. 2018. "A = 432: A superior tuning or just a different intonation? How tuning standards affects emotional response, timbre and sound quality in music." Lisans bitirme tezi, Medya Sanatları, Estetik ve Anlatımı, Skövde Üniversitesi, İsveç. http://www.diva-portal.org/smash/get/diva2:1215149/FULLTEXT01.pdf
Comment: For those interested in the scientific credentials of "Explore" then [according to Wikipedia](https://en.wikipedia.org/wiki/Explore:_The_Journal_of_Science_%26_Healing) it has been described as a "sham masquerading as a real scientific journal" which publishes "truly ridiculous studies"
Comment: It matters because the timbre of a tone is an important part of what people react to.  So is the tempo of a piece of music.  Both would be changed by simply slowing down a recording.  Alternatively, playing music on an instrument designed for A=440 but tuned to a lower pitch means that you're using the instrument in a manner for which it was not designed.  Maybe that unconventional use of the instrument is responsible for the study's finding rather than the difference in frequency.
Comment: What is the difference between lowering concert A, and playing a piece written in, say, F, but playing it in E? If dropping the pitch a little has some effect, what about dropping a lot?
Comment: This may not be significant, but these studies don't all necessarily seem to mean the same thing by 'tuning' - in one study they mean pitch-shifting the recording in MAX, one study uses pieces prepared specially by a specific composer - Giorgio Costantini - who I imagine will have used a re-tuned instrument? And two other abstracts don't describe how the re-tuning was done.
Comment: @Aaron have you read the papers, and are you convinced by them?
Comment: None of this seems to say how the music was rendered at A = 432 Hz.  This matters.
Comment: @phoog How so? topo Reinstate Monica made a similar comment.
Comment: @Tim what other pitch would most guitars be designed for?  Of course some baroque guitars will be designed to play at 415, and some people will tune their guitars differently, and some people will put heavier or lighter strings on their guitars, and in all of these parameters guitars are more flexible than, for example, oboes.  But instrument designers don't pick the string length randomly.
Comment: (just my guesses) I suspect it would depend on the context.  For singers, a half step is a potentially whole new ballgame.  For listeners with perfect pitch, it will just be a transposition.  Part of it might be performer psychology that is projected to the listener-- for example, even if a listener doesn't have much pitch memory (i.e. they aren't particularly tuned to A=440), if performers feel their pitch is less bright (and they definitely WILL notice), it may subtly affect their performance, and THAT might translate to a difference in the listener.
Comment: @Bennyboy1973 - Regarding "For listeners with perfect pitch, it will just be a transposition", my personal experience and what I've read tend to match something different - the transposition downward is unnerving because it presents a less familiar version of the piece. The transposition is even more unnerving if the piece has its key in its name (e.g. "Minuet in G Major") and the piece is no longer playing in the key in its name (by modern tuning standards).
Comment: @phoog - thought-provoking concept! I wonder whether guitars are designed to be tuned to A=440Hz. There's been so many different tunings used on them, I somehow doubt it. And pianos made to be tuned to 440? Doubtful too. But an interesting thought.
Comment: @Tim Not so doubtful about pianos. A piano's scale (the mapping out of the exact placement and length of the strings) is extremely carefully designed. That would make an interesting question in its own right.
Answer: Certainly yes, and I believe, that I'll be able to prove it and give you the evidence. But your question in the bold font makes it a little complicated, because you have put a consciousness into it, and it could mean, that you ask for a specific evidence of when someone is aware or unaware of hearing music.
Anyway, the difference can certainly be measurable. Even a difference of 1 Hz in the pitch can have a psychological effect, which may be measurable, if you are able to measure it. I base these opinions on my current, ongoing research and listening tests, although I lack a real evidence at this moment. How I would explain it for now, is that a different tuning means different sound waves in the result. Be there the 1 Hz difference in the pitch, then there would also be a difference in perception of music, because different sound waves are created. Although, it can depend on several factors, such as resonant properties of an instrument and ability of hearing.
But I would like to "tell" you, that according to my tests, the optimal tuning pitch is lower than the 432 Hz. This tuning (A4 = 432 Hz) may be suitable only along with a Pythagorean temperament, which uses the 3:2 ratio of intervals. Most of music is however recorded and played utilizing the 12-TET system. So please be aware of it.
If you would like to know my recommendations for a tuning or tunings, you can write me an e-mail.
Comment: "Certainly" and "lack a real evidence" don't go together well. Moreover from this you move to an even stronger claim that some tunings can be more or less "suitable" depending on temperament, but you don't support it with anything.
Comment: This means that you persuaded yourself and no one else so far. This isn't great support for arguments in a field that is plagued with poor quality research, about which you can learn from other answers.
Comment: -1 This doesn't answer the question, since it doesn't present any evidence (which is what's asked for). If your research isn't far enough along to be compelling you could direct us to other work in the field instead.
Comment: Honestly, these links convince me even less… This looks too much like "pseudo science" where the basic assumptions are stated with no justification whatsoever~
Comment: @user1079505 I've used "certainly", because I'm persuaded of it.

The research is planned to be published, when it's finished, hence the admittance of the lack of a real evidence. Does it make more sense to you now?
Comment: I agree, that "certainly" and "lack of a real evidence" may not go well together. I wanted to use "most likely", but considering, that I already have some evidence, just not something, what I want to share yet, I used "certainly".
Comment: @helveticat PART 1: If it will be possible, I would update it when it's finished. And if Aaron isn't satisfied with my answer, it can be deleted. However, I wanted to you let you know, Aaron, that there are other possibilities. A lot of people seem to fantasize about the 432 Hz tuning, while being unaware, that you would get those nice numbers in the scale with the Pythagorean temperament, but not with the 12-TET.
Comment: @helveticat PART 2: And why should A4 be the tone, according to which tuning would be based upon? To understand it better, you can take a look here, for instance: https://128hertz.com/pythagorean-tuning/. And also you may look at this: https://128hertz.com/432-hz-scales/, and reading this: https://128hertz.com/432-hz-fakes/.
Comment: Source: "Just trust me bro"


How do you call an async method when the user is typing in a textbox (oninput)?

Question: I want to call an async method every time a change is made to a textbox.
I been looking at this for a while now googling and trying the syntax I find.  The below code seems like the most accurate.
Razor Page Code:

            <input class="form-control" @oninput="@(async () => await OnSearchAsync())"/>

Code Behind:
    public class ListBase: ComponentBase
    {
        [Inject]
        public IVpbDelegateAdminService VpbDelegateAdminService { get; set; }

        protected VpbDelegateListVm VpbDelegateListVm { get; set; }

        protected override async Task OnInitializedAsync()
        {
            VpbDelegateListVm  = await VpbDelegateAdminService.GetVpbDelegateListVmAsync(1);
        }

        protected async Task OnSearchAsync()
        {
            VpbDelegateListVm = await VpbDelegateAdminService.GetVpbDelegateListVmAsync(2);
        }
    }

Any help would be appreciated.
Comment: Note: This is for a Blazor app.
Comment: Your code is fine. If you have another issue, please create a new question.
Answer: Are you trying to call a method from your code behind?
If that's the case, this should work.

            <input class="form-control" @oninput="@OnSearchAsync"/>

@code
{
    private async Task OnSearchAsync()
    {
        var data = await GetYourData();
    }
}

Comment: Yes, I have a code behind file which inherits from ComponentBase. (see above).  The call to OnInitializedAsync() works fine. I tried your changes.  Still didn't work.  The processing will not go into the method.
Comment: I just reviewed the Developer Tools. Getting the following error: blazor.server.js:15 [2020-03-27T14:57:50.459Z] Error: System.FormatException: Cannot add value because header 'Authorization' does not support multiple values.
   at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
   at System.Net.Http.Headers.HttpHeaders.Add(String name, String value) which does not make sense since the first call to my method works fine.  Let me investigate futher.
Comment: You change worked. I had a break point down API so I assume the event was not working. Once I added the breakpoint in the event. I saw it was working. Now I have to figure out why I am getting an authority error.
Comment: Yes, it works now.  The problem was authority, which I fixed.
Answer: My solution is
@page "/Demo_domtree_input_typing"

@{ BlazorSession.Current["codename"] = "Demo_domtree_input_typing"; }

Your message :
<BlazorDomTree @ref="dt"></BlazorDomTree>

@code{

    BlazorDomTree dt;

    protected override void OnAfterRender(bool first)
    {
        if (!first)
            return;

        PlusControl inp1 = dt.Root.Create("input type='text'");
        inp1.OnChanging(delegate
        {
            BlazorSession.Current.Toast("Your are typing '" + inp1.Value + "'", 1000, "typinginfo");
        });
    }
}

Online live demo :
http://demo.blazorplus.com/Demo_domtree_input_typing
(It require import and setup the nuget package 'BlazorPlus')


This site is missing a valid, trusted certificate || Apache2 webserver, Windows root CA

Question: I'm learning about certificates, HTTPS together and after 4 days I'm out of idea how to set up to become trusted. In my lab env. I have a Windows server with a CA role.
Previously I installed a VM-Dell OpenManage for my server. It has a graphical interface for requests and an import certificate for HTTPS access. I successfully generated a Certificate Signing Request and get a cert from my windows CA server (https://x.x.x.x/certsrv/) It was done under 2 min.
I thought I can try this, on an apache2 webserver (Ubunut20.04). Well, now I am stuck and still don't know how to get it to work.
1. Currently (after ~50 openssl req) I requested certificate with these commands:
openssl req -new -newkey rsa:2048 -nodes -addext "subjectAltName = DNS:*.mydomain.local" -keyout serverkey.key -out serverreq.csr

2. I opened my windows CA server from browser https://x.x.x.x/certsrv/ and Request Certificate-->Advanced Certificate Request-->paste the serverreq.csr content-->WebserverTemplate. Download the cert.
3. Back to linux, my conf file (/etc/apache2/sites-avaliable/mysite.conf): look like this.
<VirtualHost _default_:443>
        Protocols h2 http/1.1
                ServerName  mysite.local
                ServerAlias www.mysite.local
                DocumentRoot /var/www/html/mysite
                SSLEngine on
                SSLCertificateFile      /etc/ssl/certandkey/myservercert.crt
                SSLCertificateKeyFile   /etc/ssl/certandkey/myserverkey.key
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:80>
    ServerName mysite.local
    Redirect / https://mysite.local/
</VirtualHost>

Do I need to configure the # Server Certificate Chain: and #   Certificate Authority (CA):?
Apache is running

4.
After this, If I open the webpage it says
Certificate - missing
This site is missing a valid, trusted certificate (net::ERR_CERT_COMMON_NAME_INVALID).

But if I open the OpenManage  it says
Certificate - valid and trusted
The connection to this site is using a valid, trusted server certificate issued by mydomain-DC-CA

Both certs are from the same windows CA server.
5. I tried to config /etc/ssl/openssl.cnf, but I do not really understand how. If I edit something, then nothing works.
What is wrong with my config, how can I config it? Is there any good tutorial? 90% of the time google shows only self-signed cert and browser magic. But I would like to config it with windows CA.
Thanks for help
Sorry for my english.
Comment: Can you show the outputs of: `openssl x509 -subject -in /etc/ssl/certandkey/myservercert.crt -noout` and `openssl x509 -checkhost mysite.local -in /etc/ssl/certandkey/myservercert.crt -noout`?
Comment: I have an error:  `Hostname myserver does NOT match certificate`.  How can I found out what is the hostname of the cert? `openssl x509 -in /etc/ssl/glpicertkey/glpiservercert.crt -text` with this I don't see the hostname within the cert.

`root@myserver:/home/user# openssl x509 -checkhost myserver -in /etc/ssl/certandkey/servercert.crt -noout
Hostname myserver does NOT match certificate
root@myserver:/home/user# openssl x509 -subject -in /etc/ssl/certandkey/servercert.crt -noout
subject=C = HU, ST = Hungary, L = City, O = mycompany, OU = IT, CN = mydomain.local`
Comment: mydomain.local is in the CN, and that doesn't match mysite.local, so that won't provide a match. Also you have to include the DNS entries in the Subject Alternative Names to see if it matches. I appended this info to my answer.
Answer: Generating
You can use a small extension file (utf-8) to preset the entries you want and generate a CSR more easily. DNS entries must be punycode if not ASCII. (https://www.rfc-editor.org/rfc/rfc3492)
[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
req_extensions = ext

[ ext ]
subjectKeyIdentifier=hash
keyUsage=digitalSignature, keyEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = mysite.local
DNS.2 = www.mysite.local

[ dn ]
O=ACME
OU=TESTING
firstname.lastname@example.com
CN = mysite.local

You can save this as sslcert.cnf for example.
Remarks about wildcards
You can use a wildcard like *.example.com. They work only on one level. foo.bar.example.com won't be covered by *.example.com. Also *example.com doesn't work, the asterisk has to be in its own domain component.
Then, if you have no private key yet:
openssl req -nodes -newkey rsa:2048 -keyout sslcert.key -out sslcert.csr -config sslcert.cnf -utf8
Or if you already have private key sslcert.key
openssl req -key sslcert.key -out sslcert.csr -config sslcert.cnf -utf8
sslcert.csr will be the output (and also sslcert.key in the first example)
You can also add a subjectAltName section with -addext
openssl req -nodes -newkey rsa:2048 -keyout sslcert.key -out sslcert.csr -addext 'subjectAltName = DNS:example.com' -utf8
Name checking
You can use an openssl command to check if a certificate potentially matches the domain you use in browsing
openssl x509 -in sslcert.crt -noout -checkhost example.com
Historically the CN entry in the distinguished name of the subject was used in SSL hostname checking. And it still is conventionally filled with one of the domains, but Chrome for example will not accept a certificate which doesn't also use the Subject Alternative Names (SAN) section. And this is also the section used for multiname certificates (even if you use just a domain with and without www, that is already a multiname certificate). According to CA/Browser norms, any name you set in CN must also be included in the altnames section.
You can see those in the output of
openssl x509 -text -noout -in cert.crt | grep -F 'Subject Alternative Name:' -A 1
Unfortunately there is no ready made output switch for just the SAN section.
It looks like:
            X509v3 Subject Alternative Name:
                DNS:cert.local, DNS:cert.example.com

Webserver check
To see if your webserver returns the certificates and chains (if you have intermediates) that you have set, you can also use an openssl commandline (possibly from the webserver machine itself).
openssl s_client -connect example.com:443 -servername example.com -showcerts

If you are using a CA that is not included on the machine that executes the openssl command, you will get verification error, but at least you can see the certificates returned.
In the connect you can also use an ip-address, so if the webserver is on the same machine and also listens on loopback, you could say
openssl s_client -connect localhost:443 -servername example.com -showcerts

-servername is for selecting the right vhost if the webserver has multiple vhosts on port 443.
Comment: I run the command: `openssl req -key sslcert.key -out sslcert.csr -config sslcert.cnf`
 But in the cert there is no SAN, and after I open the site (F12) It says: `Certificate - Subject Alternative Name missing The certificate for this site does not contain a SAN extension containing a domain name or IP address`
If I add this to you command, `-addext "subjectAltName = DNS:*.mydomain.local"` after that SAN appear, without it not. And I used the sscert.conf file, and It contains the SAN config. Then why it's not used?
And Certificate missing still a problem.
Comment: Could you try the amended config file in my answer? It seems I happened to depend on some base settings in my systems openssl distribution. Do you still get a certificate missing when you have the right CN and DNS entries?
Comment: Still no luck. Can You explain how the hostname works? I think that's where I fail. My server hostname is glpi.mylab.local. My DNS/AD is mylab.local.
`[ alt_names ]
DNS.1 = glpi.mylab.local
DNS.2 = www.glpi.mylab.local`
`[ dn ]
...
CN = glpi.mylab.local`
If I cheskhost for any combination it's always mismatched. What am I doing wrong?
Comment: And this: `openssl req -nodes -newkey rsa:2048 -keyout sslcert.key -out sslcert.csr -config sslcert.cnf -utf8` working but there is no SAN in cert file. Only if I add this to my command: `-addext "subjectAltName = DNS:*glpi.mylab.local"
`
Comment: *glpi is not right, or did you try some markup here? *.glpi.mylab.local can work for a www variant, but not for the variant without www.
Comment: Hy! Nope, still not working. My ssl config file look like this:
`[ req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
req_extensions = ext

[ ext ]
subjectKeyIdentifier=hash
keyUsage=digitalSignature, keyEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = glpi.mylab.local
DNS.2 = www.glpi.mylab.local

[ dn ]
emailAddress=no
CN = mylab.local`
Request command:
`openssl req -new -newkey rsa:2048 -nodes -keyout tsslkey.key -out tsslreq.csr -config sslcert.cnf -utf8`
Comment: DNS check:
`openssl req -noout -text -in tsslreq.csr |grep DNS
                DNS:glpi.mylab.local, DNS:www.glpi.mylab.local`

Adn still `This site is missing a valid, trusted certificate (net::ERR_CERT_COMMON_NAME_INVALID).`

the hostname is glpi.mylab.local

What is wrong?
Comment: I wonder if there is a second _default_ vhost_ on port 443 in Apache overriding your vhost.
Comment: You are checking the CSR. Did you also check the issued certificate?
Comment: You are right, I did not checked the cert. It's wrong: `X509v3 Subject Alternative Name:
                othername:` Why It's generated like this, when the request file is good?

No other default vhost `a2dissite default-ssl.conf
Site default-ssl already disabled`
Comment: The othername error might imply that the DNS name info has been stored by the CA in a format that is not supported by openssl. DNS names should be IA5STRING. But on second thought, the error seems to indicate that not even the DNS Name format is chosen or that another GeneralName is included that is not supported.. Maybe look at the "Subject Name" tab in your SSL issuing template. I have done signing with Windows CA of openssl CSR files, and that always went quite smoothly, but it may be that there are operational settings in the template used that add other info, incompatible with openssl.
Comment: Also as a precaution make sure that your openssl config file is stored in utf-8 or ascii and only has Unix newlines.
Comment: Success :). I I discarded the idea to make an own ssl.cnf file. I used the default one, but with -addtext SAN. Previously I dropped the "*" from subjectAltName.
`openssl req -new -addext "subjectAltName = DNS:glpi.mylab.local" -newkey rsa:2048 -nodes -keyout testkey.key -out testreq.csr`
After I imported the cert file there was a new error: `"Active content with certificate errors"` I just cleared the browser cache and the cert was accepted, all green.
Thank you for the helping and  patience.


bash: extract URLs from a string

Question: So, I am trying to get information out of OS X's "favorite servers" .plist so that I can then decide whether or not I want to add certain servers to it. Some of the information for how this can be done can be found here:
http://jacobsalmela.com/bash-script-set-favorite-servers-in-connect-to-menu/
The problem with this is that you can't, for example, just do
/usr/libexec/Plistbuddy -c "Add favoriteservers:CustomListItems:0:Name string server1.fqdn.com" com.apple.sidebarlists.plist
over and over, because Plistbuddy is not smart enough to do an insert into the array. You have to know how long the array is, and then add things to the end of it, such that when you go to add things you have already determined whether you need to use 0 or 5 or 7 between "CustomListItems" and "Name" up there.
The obnoxiousness of that aside, I'm having trouble just parsing the output from the Plistbuddy print command, which looks like this:
Array { Dict { Name = afp://or-fs-001/vol1 URL = afp://or-fs-001/vol1 } Dict { Name = smb://or-fs-001/vol1 URL = smb://or-fs-001/vol1 } Dict { Name = vnc://or-fs-001/vol1 URL = vnc://or-fs-001/vol1 } Dict { Name = ftp://or-fs-001/vol1 URL = ftp://or-fs-001/vol1 } }
So you have the same URL twice for each entry (I have no idea why there is both a "Name" and "URL" when you can't actually make them different), and they may start with any protocol supported by Finder, which means afp, http, https, smb, or vnc. The first thing I'm trying to do is just split them up into pieces by the "Name" substring so that I know how many entries are in the list, but that results in weird behavior when I use tr for that; it starts cutting out way too many pieces.
Does anyone have ideas for better ways to do this? Can I count the number of times "Dict" shows up?
Comment: You might want to use the `-x` option to get XML output instead of the JSON-like output used by default.
Answer: You can use grep -o to extract interesting parts of the input. An example:
#!/bin/bash
output='Array { Dict { Name = afp://or-fs-001/vol1 URL = afp://or-fs-001/vol1 } Dict { Name = smb://or-fs-001/vol1 URL = smb://or-fs-001/vol1 } Dict { Name = vnc://or-fs-001/vol1 URL = vnc://or-fs-001/vol1 } Dict { Name = ftp://or-fs-001/vol1 URL = ftp://or-fs-001/vol1 } }'

count=$(echo "$output" | grep -o 'Name =' | wc -l)
names=($(grep -o 'Name = [^ ]\+' <<< "$output" | cut -f3- -d' '))
echo $count = ${#names[@]}
for name in "${names[@]}" ; do
    echo "$name"
done

Comment: You, sir, are a golden god.

How does `echo $count = ${#names[@]}` work? What does the # do there?
Comment: See "Parameter Expansion" in `man bash`. `${#array[@]}` returns the size of the array.

bash: extract URLs from a string


Particular integral of $x^2 y''-xy'+4y=\cos(\ln{x})+x\cdot \sin(\ln{x})$

Question: I have found the complementary Function, but can't understand how to find the particular integral because with UC method. Please someone help me.

Transcript of image:
Q: $x^2 y'' - xy' + 4y = \cos(\ln x) + x\sin(\ln x)$ (labelled equation 1).
Let $x = e^z \Rightarrow z = \log x$
and $xy' = \Delta y$, $x^2y'' = \Delta(\Delta-1)y$ where $\Delta = \frac{\mathrm{d}}{\mathrm{d}z}$
so, equation (1) becomes,
$\Delta(\Delta - 1)y - \Delta y + 4y = \cos z + e^z\sin z$
$(\Delta^2 - 2\Delta + 4) y = \cos z + e^z \sin z$ (labelled equation 2)
Auxilliary equation of equation (2) is
$m^2 - 2m + 4 = 0$
$\Rightarrow m = \frac{2\pm \sqrt{4 - 16}}{2}$
$m = 1 \pm \sqrt{3}i$
Therefore Complementary function, $y_c = e^z c_a \cos \sqrt{3}z + e^zc_2\sin\sqrt{3}z$.
Comment: And now you need a particular solution for the right side $\cos z+e^z\sin z$. As that is not in resonance to the homogeneous solution, the method of undetermined coefficients should be easy to apply.
Answer: Particular solution we find in form
$$y=e^z(A\cos z+B\sin z)+C\cos z+D\sin z$$
Substitute this form in equation
$$y''-2y'+4y=e^z\cos z+\cos z.$$
We get
$$\left( 2 B\, {{e}^{z}}+3 D+2 C\right)  \sin z+\left( 2 A\, {{e}^{z}}-2 D+3 C\right)  \cos z={{e}^{z}} \sin z+\cos z,$$
$$A=0,\quad B=\frac12,\quad C=\frac{3}{13},\quad D=-\frac{2}{13}.$$
Then
$$y_p=\frac{e^z\sin z}2-\frac{2\sin z}{13}+\frac{3\cos z}{13}\\=
\frac{x\sin(\ln x)}2-\frac{2\sin(\ln x)}{13}+\frac{3\cos(\ln x)}{13}$$


Servlet hosting with peak capacity

Question: I am hosting a website that is currently run on Google Cloud Storage, and a completely static interface. I am considering upgrading it to allow for better plotting tools, which will require it to run a server, in this case a Java Servlet. The specific technology is Webmathematica, if it matters. My website hast mostly a steady demand averaging around 1K visitors at a time, but has had a peak of over 40K. My hunch is that a single server would not be enough to host such a service, that it would crash. Right now being hosted with a purely static website, I have been okay, but I'm worried about what might happen if I switch to a servlet system and I receive another huge spike in traffic.
What I would like to know is if there is a system in place that will allow me to host my website with java servlets that will scale as required. I would rather not pay for the high demand load all of the time, but I would like the option to turn on a few extra servers if the spare capacity should be required. I think I am okay if the site goes down for a minute while the servers turn on, but not much longer then that.
Is there such a host? What exactly is the name of this capacity so I can price things out? And is there anything else that I should know?
Answer: The rule of thumb would be to cache as much as you can. Preferably by one of the big CDN providers, like Akamai(expensive, but high quality), Cloudflare(free, but has it's issues), Fastly(I've no idea about this one).
How much of the content would be dynamic? Is it possible to have most stuff rendered client side via Javascript and provide data via cacheable JSON?
It's hard to say what would be the golden bullet here, with most of the stack being a big unknown.
If you're making money off of it, please at least get a second server to work as a cluster.
For the static site, it might be a good idea to move to s3 and host via cloudfront if possible.
Comment: It MIGHT be possible to support such traffic using that specific solution, but that won't be cheap.
Comment: Right now everything is rendered client side via Javascript. I'm using Google Cloud Storage, which is basically Google's version of S3 (They gave me $300 in free credit, hard to turn that down). Hmmm...
Comment: Ok, then skip the switch to S3 advice, as it's cheaper for you atm.

Regarding the stack, if you switch to servlets, you need at least two servers. I have no idea about Webmathematica, but as it's java it will probably scale better horizontally, than vertically.

It's possible to use AWS Autoscaling groups to achieve what you desire, with servers scaling with load, but that's not easy to setup corretly and there is a delay between load hitting and the increase in capacity, based on what's configured.
Comment: Yeah, the more I think about this, the more I'm realizing that Webmathematica isn't really my solution. It might have a few cool features, but...

Servlet hosting with peak capacity


Entity Reference View Widget problem with add selective

Question: I am using a content type which uses a field as "Views" Entity Reference View Widget. When I click "add selective" or "add .. and close" in form of this widget, it's just redirect to http://localhost/denwer.
How do I solve this problem?
Thank you for answer, kiamlaluno.
details of question:
1. I create a view with type display "Entity Reference View Widget" as table of taxonomy term
(after create view in this view besides display name of views "Entity Reference View Widget" no more information that it use "Entity Reference View Widget" - in Format just show that it's table (grid etc..)
2. Create content type
in content type create field:
- type filed "Entity Reference"
- widget "view"
after create field in description of module "Entit.. widget" says that "on the next page select your View from the dropdown" but there is no dropdown in which can choose my view (picture below)

if just click "save" created view chosen
(picture below)

then i use default settings and save settings of field.
Next step  - Add node of created type and here is problem:
- i see field with widget, can click add item
- then i see "widget form with created view"
But if click on buttom "add selected item" - it's just go to page "/localhost /denwer"
and of cause nothing add in "node add"
Comment: Welcome to Drupal Answers! It's not clear what `http://localhost/denwer` means, nor from where that URL is taken from. You should edit the question to make it clear.
Answer: I solved a very similar issue by changing the display type to "Entity Reference" (not "Entity Reference View Widget") and using using the ER Widget only for the view checkbox selection field.
Here is a detailed step-by-step guide to a solution which worked for me using the latest Drupal 7 dev version of the ER Widget module.


$1$ as a common root of a quadratic equation

Question: $$ax^2 + bx + c = 0\quad\text{and}\quad
bx^2 + cx + a = 0$$
have a common root.
In my book, it says that 1 is a common root for those equation?
Is this correct.
When we plug 1 in both the equations, we get $a+b+c = 0$, it says nothing about 1 being a root. Since we don't know if LHS is zero or not.
Where I'm going wrong here?
Comment: Without further information, we cannot say that $1$ is a root. For example, if $a=b=c=1$, the two quadratic equations are $x^2+x+1=0$ and $x^2+x+1=0$. These clearly have a common root (as they are the same equation), but $1$ is not a root. From answers below though, we know that a common root $x_0$ must satisfy $$a\left(x_0^3-1\right)=0,$$ or equivalently (if $a\ne 0$) $$x_0^3=1.$$ Therefore, if you are given that there is a common **real** root, then you can conclude that $x_0=1$ is a common root.
Comment: It's possible of course that this question came up in a context where the reader is not expected to know about complex numbers (just real numbers). In that case, when they said there is a common root, it automatically meant real root and you can more or less ignore my comment above.
Comment: Could you clarify if the common root is required to be a **real** root?
Comment: You can also upvote my answers.
Answer: From first one you have $$c=-ax^2-bx$$ so put this in second eqaution and you get:$$ ax^3-a=0$$ Since $a\neq 0$ we have $x=1$ or solution of $x^2+x+1=0$.
Comment: @zwim but then it is not a quadratic
Comment: rem if $a=0$ then $bx+c=0$ vs $bx^2+cx=0$, still has common root, not $1$ though.
Answer: Let $t$ is the common root,
$at^2+bt+c=0$
$bt^2+ct+a=0$
Solve for $t^2,t$
and use $t^2=(t)^2$ to eliminate $t$
and find $$0=a^3+b^3+c^3-3abc=(a+b+c)(?)$$
Comment: See also : https://math.stackexchange.com/questions/475354/how-to-show-that-a3b3c3-3abc-abcab-omegac-omega2ab-omega2
Answer: Let $t$ be the common root:
$$at^2+bt+c=0\\
bt^2+ct+a=0$$
Subtract and factorize:
$$a(t^2-1)+b(t-t^2)+c(1-t)=0 \iff \\
a(t-1)(t+1)-bt(t-1)-c(t-1)=0 \iff \\
(t-1)(at+a-bt-c)=0 \Rightarrow t=1$$


If $\forall x \in G, \exists k \in \mathbb Z^+ \backepsilon xa=a^kx $, then $\langle a \rangle$ is a normal subgroup

Question: In Pinter's A Book of Abstract Algebra, Chapter 14 Exercise E3 asks the reader to prove the following statement:

If $a$ is any element of $G$, $\langle a \rangle$ is a normal subgroup of $G$ iff $a$ has the following property: $\forall x \in G, \exists k \in \mathbb Z^+ \backepsilon xa=a^kx $

For this biconditional, I have no issue demonstrating the implication that:
if $\langle a \rangle$ is a normal subgroup, then $\forall x \in G, \exists k \in \mathbb Z^+ \backepsilon xa=a^kx $.
However, it is the other implication that I am struggling with...specifically:
if $\forall x \in G, \exists k \in \mathbb Z^+ \backepsilon xa=a^kx $, then $\langle a \rangle$ is a normal subgroup.
Here is the issue that I am running into:
Given the antecedent, I can premultiply by $x^{-1}$ to arrive at:
$a=x^{-1}a^kx$ , which is equal to $a = (x^{-1})a^k(x^{-1})^{-1}$
At first glance this seems just fine...but then I realized that due to the existential quantifier, I am pretty sure that I have no way of knowing if all elements of $\langle a \rangle$ will make it into $a^k$. At most, I can say that at least one element of $\langle a \rangle$ has all of its conjugates in $\langle a \rangle$...for example, if $k$ is the same integer for all values of $x$.
Any suggestions?
Comment: Now I've seen it! $\ddot\smile$
Comment: I have never seen it.
Comment: What is $\backepsilon$?
Comment: @JoséCarlosSantos oh, it's a notation I've seen for "such that"...is there a better one?
Comment: @JoséCarlosSantos https://math.meta.stackexchange.com/questions/22385/latex-symbols-for-therefore-and-suchthat...the first answer (in case you were wondering)
Comment: How do you prove the first implication in the case when $\langle a\rangle$ is infinite? When $\langle a\rangle$ is normal in $G$, $\langle a\rangle$ is closed under conjugates so $xax^{-1}\in\langle a\rangle$ for all $x\in G$. Thus, $xax^{-1}=a^k$ for some integer $k$, so $xa=a^kx$. But how can you guarantee $k$ will be positive when $\langle a\rangle$ is infinite?
Answer: Hint: $ xa^nx^{-1}=a^{nk}$ can you prove this?
Comment: Ohhhhh, but I guess the idea would be that all $\langle a^n \rangle$'s are necessarily subsets of $\langle a \rangle$...right?
Comment: $a$ is not just any element, it is the generator of the group
Comment: That idea is that every element can be written as $a^n,n\in\mathbb{N}$
Comment: I had thought about this, but my concern was that $\langle a \rangle$ does not necessarily equal $\langle a^n \rangle$...and therefore I would be talking about different groups.
Answer: I solved it in here, i cant write as you maths symbols with my phone so i solved it on paper sorry my english is bad :|
Solution


Different results for different order of computations with "i"

Question: I am really puzzled now:
$\bullet$ First way of thinking: $$(i^{8})^{1/4}=i^{2}=-1$$
$\bullet$ Second way of thinking: $$(i^{8})^{1/4}=(1)^{1/4}=+1$$
I can recall some weird things like these in complex analysis, but which is the correct? Do we pick either of two in a specific context?
Comment: Don't your parenthesis indicate the order of operations?
Comment: The second one is right, isn't it? Contents of parentheses -> Powers from left to right -> Multiplication and division from left to right -> Addition and subtraction from left to right.
Comment: There's also the fact that ${(b^m)}^n$ is not generally equal to $b^{mn}$ for non-positive $b$. This is responsible for many a "proof" that $-1 = 1$.
Comment: I thought so, but Oskar's comment is correct...
pjs Indeed, youre right..
Answer: The fourth-root is not a single-valued function, it is four-valued (except at $0$).  So $1^{1/4}$ is in fact the set $\{1,i,-1,-i\}$.
Comment: So, I keep the first value of the set in a computation? Does it have to do with complex phases?
Comment: Not necessarily. Think of $w=z^{1/4}$ to be a property of the number $w$ to satisfy $w^4=z$, for a given $z$.  In your example $z=1$ and there are four different $w$'s that satisfy this equation.  It is a standard topic in elementary complex analysis to find the $n$-th roots of the identity by using the polar factorization of complex numbers $z=\rho\exp(i\theta)$ for some real $\rho>0$ and $\theta\in[0,2\pi)$.
Comment: Thanks Oskar, I guess I have to recall these immediately


Creation of Position vectors in Convolution Neural Network for Relation Classification

Question: This question pertains to the use of position vectors in CNN for relation classification as described in multiple publications such as the following by Zeng et al: http://www.aclweb.org/anthology/C14-1220
I am trying to implement such a model in tensorflow. My questions are as follows:

Is there any benefit to using randomly initialized vectors for denoting positional information? For instance, why not use one-hot vector encoding with say 100 dimensions to denote the positions? Is it not recommended to combine one-hot vectors with dense word vectors?
Is there a minimum dimension the positional vectors should have, depending on the dimensions of the word vectors? For instance, suppose the word vector dimension is 500, will a dimension of say 10 for the position vectors be too small to be of value in the model? Is there a range of dimensions that is known to perform well with position vectors?
Does the distance between the randomly initialized vectors for encoding positional information matter?

Thanks a lot for taking the time to look into this!
Answer: Regarding question 1, I don't have an explanation why combining one-hot and dense representations is bad, but empirically, looking at results reported by other people, it seems to be better to learn embeddings for the positions as well.
Yoav Goldberg also notes this in his NLP Deep Learning book (p. 96):

In the "traditional" NLP setup,
  distances are usually encoded by binning the distances into several groups (i.e., 1, 2, 3, 4, 5–10,
  10+) and associating each bin with a one-hot vector. In a neural architecture, where the input
  vector is not composed of binary indicator features, it may seem natural to allocate a single input
  entry to the distance feature, where the numeric value of that entry is the distance.
However, this
  approach is not taken in practice. Instead, distance features are encoded similarly to the other
  feature types: each bin is associated with a d-dimensional vector, and these distance-embedding
  vectors are then trained as regular parameters in the network [dos Santos et al., 2015, Nguyen
  and Grishman, 2015, Zeng et al., 2014, Zhu et al., 2015a].

Maybe you can find more insights into why embeddings are better by looking into the cited papers.
With regard to question 2, I would say as long as the dimensionality is big enough for the model to learn different embeddings for each position you want to encode, it should be fine. So they could be quite small in practice.


How do you make a clickable dropdown menu that pushes rest of content on page

Question: I think it was a bit hard to explain what I mean in the title, but pretty much what I want to do is to have a text saying "View guild members", and whenever you press on this text, a list of all members fades in.
Thing is though, I have done research and found dropdown menus, but I don't want it to show the content over the content that are displayed.
Easier to explain with these two pictures:

As you can see, after pressing the button, the content (link 1-3) displays over "hello". I want to push "hello" further down the page.
How do I do this?
Comment: If you show your css and html, we're more likely to be able to help.  Without seeing it, I would say try setting the dropdown menu css position attribute to relative.
Comment: yea, that worked! :) Is there ways to make it transition in css? or do I need to use jquery for that?
Comment: html: https://pastebin.com/XWMa7tmg css: https://pastebin.com/P6igrhjB
Comment: You can use pure css, either via a transition or via keyframes.
Answer: In order to accomplish the fade-in animation you need to add these styles in your css:
<code>.show {
  display: block;
  animation: fadeIn 600ms ease-in-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
</code>
Here is also a codepen to play around with the code.


Field value of a content type is not saved

Question: I have a content type (created through a feature) which has different fields. One field is a text field. It used to save data before but now it doesn't save any value. I checked in the table, the value is not there. I checked in hook_node_update the field is empty.
I tried to write hook_field_is_empty in my module and also in feature but didn't help :(.
W
hat can cause this? Thank you.
Comment: I'm speculating, but it's probably because of the very broad nature of the question. There are dozens of things that could be wrong, without more information from you this is near impossible to answer, and as such not a good question for the site. You'll need to do some more advanced debugging and provide more details if you want an answer, otherwise the question will probably wind up closed as "too broad"
Comment: Thank you for downgrading it, any special reason for it?
Comment: How can we know what happened between "it used to save" and "it doesn't save", if you don't tell us? Also, you have some hooks that may affect your situation, but you didn't show the code. So from downvote button description "no research effort" and "unclear" may fit.
Comment: At least you can see the code. If you, having access to code and environment, cannot answer this, how can you expect we will, having even less data? See these links: https://www.drupal.org/node/260854 https://www.drupal.org/node/1846954
Comment: If I create another text field on that content type, it saves data but not that specific field.
Comment: What else I should do? I tried hook_node_update to see if value is there.  I have to work with someone else's code. I searched for hooks but couldn't find something special that may affect. I will search again.
Answer: Be sure to check you are accessing the field properly. I'd recommend adding
<?php print_r($node); ?> in one of your theme tpl files and then accessing it manually like $node->field_example['und'][0]['value']. It always helps me.


Prevent Application Shutdown iPhone

Question: I'm building a little dialing program for my kids so that only 4 "safe" numbers are available for them to dial. I'd like to start the app, hand them the phone and have the app be the only thing running until they come back home.
Is there a way to keep the application running and prevent the iPhone from shutting down the app?
Answer: The iPhone SDK does not allow this. Any application can be exited when the user presses the home button. In fact if your program takes too long to exit (e.g. infinite loop) it will forcefully close your application.
If you must have this behavior, your best bet would be to jailbreak the phone in which case anything could pretty much be done.
Comment: Bummer...that's what I figured but hoped there was a way around it.
Answer: Not with Apple's SDK, no.

Prevent Application Shutdown iPhone


let s be a binary set with a binary operation * and identity element e. let $a^{-1}$ be an inverse then $a^{-1}$ is the only element in S

Question: Question:
Let  be a set with a binary operation ∗ and identity element . Let $^{−1}$ ∈  be an inverse for some element  ∈ . Then $^{−1}$ is the only such element of  with this property in relation to
My answer
Suppose $x \in S$ and $y_1$ and $y_2$ are both inverses of $x$
$y_1=y_1*e$ because e is the identity
$=y_1*(x*y_2)$ because $y_2$ is the inverse of $x$
$=(y_1*x)*y_2$ bu associativity
$=e*y_2$ because $y_1$ is the inverse of $x$
$=y_2$
so $y_1 = y_2$
I assumed this is a uniqueness question. Correct me if I am wrong
Comment: Your proof is fine.
Comment: This is good *IF* it is understood that an "inverse" of $x$ is *both* a left inverse *and* a right inverse.  That is, if $w$ is the "inverse" of $x$ then $w*x = x*w =e$.  It's *quite* possible for there to be a right inverse of $x$ called $w_1$ so that $x*w_1 = e$ (but not necessarily that $w_1*x=e$) and a left invers of $x$ called $w_2$ so that $w_2*x = e$ (but not necs. that $x*w_2=e$).  There will be no way to prove $w_2 = w_1$ which need not be true at all.
Answer: This looks good! It is worth noting that you're assuming $y_1$ is an inverse on the left, and $y_2$ is an inverse on the right. In general, these might be different, and it's worth watching out for that! Since you said "inverse", we can assume that $y_1$ and $y_2$ are inverses on both sides, but in the interest of completeness, here is a condition for left and right inverses agreeing:
Whenever every element has an inverse, then left and right inverses agree. In what follows, write $x^{-1}$ for the left inverse of an element:
$(x * x^{-1})$
we first cleverly multiply by $e$
$= e * (x * x^{-1})$
now we expand $e$ as something times its left inverse
$= ((x * x^{-1})^{-1} * (x * x^{-1})) * (x * x^{-1})$
now we apply associativity, and simplify some
$= (x*x^{-1})^{-1} * (x * x^{-1})$
but notice this is $y^{-1} * y$, so w can condense again.
$= e$
Thus left inverses are also right inverses, as long as we can find a left inverse for everything. A similar proof shows that right inverses are also left inverses, provided we can find a right inverse for everything.

Your proof was fine, but I wanted to include something more in the answer, and I know I didn't realize left/right inverses could be different for a long time, so it felt worthwhile to bring this up!
I hope this helps ^_^
Answer: At one step in your calculation, you invoked associativity. But nothing in the question says that $*$ is associative. If $*$ were associative (and if, as others have pointed out, "inverse" means "two-sided inverse) then your proof is correct. If, on the other hand, $*$ can be non-associative, then not only your proof but the result you're trying to prove fails. The simplest counterexample seems to be a $3$-element set, $\{e,a,b\}$, with $e$ being the identity element and $a*a=a*b=b*a=b*b=e$.


Concrete 5 Domain change

Question: I changed the domain of a concrete 5 website according to this documentation
All I did was adding this code to config/site.php
<code>define('BASE_URL', 'http://www.domain.co');
define('DIR_REL', '');
</code>
The domain was changed from the server side & the homepage works fine. But when I clicking a link, say navigate to the about us page, the site generates a really long URL with 20 forward slashes.
ex: http://www.domain.co/////////////////////about/
When I reload the page, another 20 appears
ex: http://www.domain.co/////////////////////////////////////////about/
This happens with any link on the homepage & in Chrome shows a browser error "ERR_TOO_MANY_REDIRECTS".
The htaccess seems normal to me.
<code># -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
# -- concrete5 urls end --
</code>
Any concrete5 experts who can explain what needs to be done?
Thanks heaps!
Answer: Remove extra slashes because each backslash a new redirection.
Removing trailing slash
RewriteRule ^(.*)/$ /$1 [L,R]

Concrete 5 Domain change


Why am I losing a DataItemTemplate control in a column when I remove all other columns in an ASPxGridView?

Question: I have a 1 column grid.  During user interaction, more columns are built and added dynamically.  No matter how many columns are added or removed from the grid, the initial Print button column should always remain.  Here's the grid.
                <dx:ASPxGridView ID="gvAdvancedResults"
                    ClientInstanceName="gvAdvancedResults" runat="server" EnableRowsCache="False" KeyFieldName="ID" AutoGenerateColumns="True">
                    <Columns>
                        <dx:GridViewDataColumn Width="3%" VisibleIndex="0" Caption="Print">
                            <DataItemTemplate>
                                <dx:ASPxButton ID="btnDisplayMEC" runat="server" OnClick="btnDisplayMEC_OnClick" ClientInstanceName="btnDisplayMEC" CommandArgument='<%# Eval("ID") %>'
                                    CssClass="reportbutt" BackColor="Transparent" Border-BorderStyle="None" Width="16" Height="16">
                                    <Image Url="~/Assets/Images/printer.png" Width="16" Height="16"></Image>
                                </dx:ASPxButton>
                            </DataItemTemplate>
                        </dx:GridViewDataColumn>
                    </Columns>
                </dx:ASPxGridView>

On a button click, I use the following to clear and repopulate the grid columns from datatable dt
    'Remove all columns except the first (index 0)
    For gix As Integer = gvAdvancedResults.Columns.Count - 1 To 1 Step -1
        If gix <> 0 Then gvAdvancedResults.Columns.RemoveAt(gix)
    Next

    'Add new columns to the gridview
    For Each col As DataColumn In dt.Columns
        Dim xcol As Object = gvAdvancedResults.Columns(col.ColumnName)
        If xcol IsNot Nothing Then Continue For
        Dim newcol As New GridViewDataColumn(col.ColumnName, col.ColumnName)
        gvAdvancedResults.Columns.Add(newcol)
    Next

    gvAdvancedResults.DataSource = dt
    gvAdvancedResults.DataBind()

Now here's the problem.  The "Print" column remains through the column removal process (as it should), but the ASPxButton inside the column's DataItemTemplate disappears.  All the columns that are supposed to be added, are added.
Why am I losing my print button but keeping its column?
Comment: Add a the button to your colomn before addind the colomn to your gridview ?
Comment: The button has already been created, though.  And its column is skipped in the column deletion process.  If the column is not deleted (nor touched), why is the button not showing up?
Comment: Weird outcome, i admit, Maybe an error when re binding the source, what happens if you just don't do any   datasource=   and   databind() ?
Comment: the new data won't show up.
Answer: To answer your original question, it is probably due to having AutoGenerateColumns set to True. When you bind a dataSource it probably auto generates the columns at that point. You can test this by removing your code that adds the columns and I bet you will still see the columns that were in the dataSource. It might be as simple as setting AutoGenerateColumns to False.
For a few alternative ways of doing this if that doesn't work...
It would be a bit of work but you could try making the button column template in the code behind so that you can just clear and recreate all of the columns during each page load.
Or an easier method would be to use a custom command column like so...
This is c# code but it should be similar in VB:
gvAdvancedResults.Columns.Clear();

GridViewCommandColumn commandCol = new GridViewCommandColumn(" ");//Blank for no caption.
commandCol.Name = "command";
commandCol.Width = Unit.Pixel(30);
commandCol.ButtonType = GridViewCommandButtonType.Image;
gvAdvancedResults.Columns.Add(commandCol);
commandCol.VisibleIndex = 0;

GridViewCommandColumnCustomButton btnPrint = new GridViewCommandColumnCustomButton();
btnPrint.ID = "print";
btnPrint.Image.Url = "~/Assets/Images/printer.png";
btnPrint.Image.ToolTip = "Print";
commandCol.CustomButtons.Add(btnPrint );

//Then add the rest of the columns.

Then add a clientSide CustomButtonClick event to the gridView to handle the actual printing via the CustomCallback event:
<dx:ASPxGridView ID="gvAdvancedResults"
 ClientInstanceName="gvAdvancedResults" runat="server"
 EnableRowsCache="False"
 KeyFieldName="ID"
 AutoGenerateColumns="False"
 OnCustomCallback="gvAdvancedResults_CustomCallback"
     OR
 OnCustomButtonClick="gvAdvancedResults_CustomButtonClick"
 >
    <ClientSideEvents CustomButtonClick="function(s, e) {
        if (e.buttonID == 'print')
        {
           //Trigger a callbackPanel that is the parent to the gridView.
           someCallbackPanel.PerformCallback(gvAdvancedResults.GetRowKey(e.visibleIndex));
           //Or trigger a callback on the gridView and use GetRowKey on the server side.
           gvAdvancedResults.PerformCallback('print');//Handle it on the server.
           //Or some other way.
        }
    }" />

Or handle the server side ASPxClientGridView.CustomButtonClick Event. No example unless you really need it.
Notice that I changed AutoGenerateColumns to false since you are manually creating the columns.
Answer: Maybe if you make two gridviews, one that contain only the button column, and the other one for the rest of the data, that would surely solve the problem as you won't touch the first gridview and only bind your datas to the second gridview. Just a workaround... Not really an easy solution because you already coded the rest.


Create IPA iOS file for multiple testing devices with Free Apple ID

Question: I have a free personal Apple ID account, I made an IPA file successfully but only works for my own iPhone device, when other testers want to install the IPA on their own iPhone through iTools, they get an "Authentication failed" error at 99% of the installation, I guess it's because that the IPA contains only my device UDID. I searched on the internet that I should add the testers's devices UDID in the Apple Provisioning Portal but, I can't find this page on my account, and I get redirected the welcome page if I try to access directly to that page.
Comment: Do you have developer a/c or user a/c ?   https://developer.apple.com/
Comment: @Hasya like I said, I have a free Apple ID (Personal Team) Free
Comment: Did you paid $99 for same ?
Comment: I never paid a $, like I said it's FREE
Comment: Then you have to go on developer.apple.com and sign in to developer a/c and pay $99 , then only you can add other UDIDs and provide build to others for testing.
Comment: Is your problem resolved? then close this question.
Answer: If you are not enrolled on https://developer.apple.com/ with paid a/c then you would not be able to add UDIDs and provide build to others for testing purpose.


How to bind knockout checkbox to a material design lite?

Question: I am having problems in bind a Knockout array with Material Design Lite checkbox. Basically it doesn't show the checkbox checked.
How can that be fixed?

var ViewModel = function() {
  this.uniqueTabsNames = ko.observableArray(['one', 'two', 'three']);
}

ko.applyBindings(new ViewModel());
<link href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.3.0/material.css" rel="stylesheet" />

generated via KO, it doesn't work

          <input data-bind="attr: {'id': $data}" type="checkbox"  class="mdl-checkbox__input"/>

non KO checkbox

          <input id='testbox' type="checkbox" class="mdl-checkbox__input" />
          test box

Comment: It wont solve your problem, but i do see a typo:  <input data-bind="attr: {'id': $data" should have a closing bracket, like so: <input data-bind="attr: {'id': $data}" ...
Comment: Normally for checkboxes you'd also want to use the binding 'checked' on the input element.
Comment: See http://knockoutjs.com/documentation/checked-binding.html
Comment: @Paul0515, thanks it fixed.
Answer: The problem here is that material design runs a function on page load to bind event handlers and functionality to certain DOM elements (like the checkbox in your case).
Because knockout essentially needs to run (or will redraw when dependencies change) the elements you bind functionality to. In your case, the foreach can/will only run after knockout has been intialized, which is typically done on DOM ready. Hence, Material won't have had access to that element when it runs it's bindings initially.
You need to have a Custom Binding to run the Material "logic" on the readiness of the element. The process is dead simple.
Pseudo-code:

Create a custom binding called whatever you'd like.
In the custom binding init method, pass the element knockout gives you into the Material function that will attach the required event handlers.

Hopefully that helps you!

EDIT: From the Material Design lite webpage
Material Design Lite will automatically register and render all
  elements marked with MDL classes upon page load. However in the case
  where you are creating DOM elements dynamically you need to register
  new elements using the upgradeElement function.

Knowing this, in your Custom Binding you need to pass the element knockout gives you, to the aforementioned handler, like: componentHandler.upgradeElement(element)

EDIT EDIT: The code

ko.bindingHandlers.SomeBinding = {
    init: function(element) {
        if(!(typeof(componentHandler) == 'undefined')){
            componentHandler.upgradeElement(element);
        }
    }
};


Need help on making my Javascript unobtrusive

Question: So I have created an order form in HTML + Javascript, and what I am wanting to use Javascript for is when someone hovers over the "label" for the soup, a hidden div will be visible (later on I intend on getting the code that will display info about the soup whose label was hovered over). I have managed to get that working but i know the Javascript code I implemented is obtrusive and am wanting to put the same code (or equivalent) onto my external Javascript file to make it not obtrusive.
Here is a fragment of code from my form (with the "obtrusive" Javascript):
<form method="post" action="#" name="souporderform" id="souporderform" onsubmit="return validate()">
**

**

Item	Price	Quantity	Subtotal

Chicken Soup
$3.50<input type="hidden" id="chicken_price" value="3.50">
<select id="chicken_quantity" name="chicken_quantity" size="1">
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
<option value="0" selected>0</option>
</select>

I'm sure the obtrusive Javascript is obvious to experienced Javascript coders viewing this...
Here is the fragment of CSS code concerned with the "hidden" div:
#soupinfo{
position:absolute;
background-color:#ff0000;
color:#000000;
width:100px;
height:20px;
margin-top:-20px;
margin-left:0px;
border:1px solid black;
visibility:hidden;
}

I do have an external Javascript file and this is what I was trying to do to replicate what I want in an unobtrusive manner:
var soupInfoDiv = document.getElementById("soupinfo");
var formLabel = document.getElementsByTagName("label");

for(var i = 0; i < formLabel.length; i++){
formLabel[i].onmouseover = soupInfoDiv.style.visibility = 'visible';
formLabel[i].onmouseout = soupInfoDiv.style.visibility = 'hidden';
}

This code is placed in a function called "setup", which is executed when the page is loaded, with the following code:
if (document.getElementById) {
window.onload = setup;
}

So if anyone can help me out, I will be very greatful :). If supplying the code fragments makes the overall problem difficult to decipher, I can upload all the code to my site and share it on here.
Comment: To ease your development struggles, have you looked at a JavaScript library? I would suggest [jQuery](http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery).
Comment: Why are you checking for the existence of `document.getElementById`?
Answer: The main issue that I see is that mouseover and mouseout handlers need to be functions.
var soupInfoDiv = document.getElementById("soupinfo");
var formLabel = document.getElementsByTagName("label");

for(var i = 0; i < formLabel.length; i++){
  formLabel[i].onmouseover = function() {
    soupInfoDiv.style.visibility = 'visible';
  }
  formLabel[i].onmouseout = function() {
    soupInfoDiv.style.visibility = 'hidden';
  }
}

I would recommend you consider jQuery though because all of this, including the window.load could be be simplified to this:
$(function() {
  $('#souporderform label').hover(
    function() {
      $('#soupinfo').css('visibility', 'visible');
    },
    function() {
      $('#soupinfo').css('visibility', 'hidden');
    }
  );
});

Comment: `window.onload` is not `$(document).ready()`, its `$(window).load()`. But, the doc ready is preferred, as its much earlier than the window load, and totally stable for event binding.
Answer: As commented by Blender, I also recommend using a javascript libary for this, for example jQuery or MooTools. Now, if I understand you correctly, you simply want to make it so that when you hover over element x, you want element y to be shown. This can be done pretty simply by using the data-attributes of html 5 (which works in older browsers), and a javascript framework (I'll use jQuery here, but if you need mootools instead, just ask and I'll translate it).
First you should anote the element you want to hover over like so:

.......

It might be a div, a label, or whatever you want.
Then, in the external js file, all you need to do is this:
$(function() {
    var elms = $('[data-hover-elm]');
    $.each(elms, function() {
        var $this = $this,
            $itm = $('#' + $this.attr('data-hover-item'));
        $this.hover(function() {
            $itm.show();
        }, function() {
            $itm.hide();
        });
    });
});

Comment: Or simply `$('[data-hover-elm]').hover(function(){$('#' + $(this).data('hover-item')).show();}, function(){$('#' + $(this).data('hover-item')).hide();})`. No need to bind each `hover` event separately. The `data()` method can be used to get `data-` attributes. Also, you can use `$('[data-hover-elm]').each(...)` instead of `$.each($('[data-hover-elm]'), ...)`
Comment: Hey everyone,

Thanks for all your ideas :)...

@Logan F. Smyth - Your solution worked perfectly :). So with situations like this (and for other things e.g checkboxes, radio buttons etc) you have to use functions? I just thought by using a for loop that iterated through each "label" element in the form and using the mouse events would make it work, but I understand your solution and will take this as a learning exercise. Even though I have been doing php and Java for a year, Javascript is still very new to me but in a couple months I should have a good grasp of at least the basics...
Comment: @logan f.smyth - Forgot to add this to reply... So when you're implementing handlers in general, do they need to be integrated as functions? I already understand, it just would help to confirm my thoughts about it thats all :).
Comment: Just a tips Rob, you should accept one or the other as answer to get your acceptens-rate != 0%.


Combinations question

Question: Two numbers are equivalent if they have the same digits, for example $2271$ and $1227$ are equivalent. How many equivalent classes are there between $1000$ & $9999$?
I'm not sure I fully understand how this works, is the answer to this question $\dfrac{9\times 10\times 10\times 10}{4!}$? First calculating the total numbers formed and divindg by $4!$ to get rid of the repetitions.
Comment: Hint: The number of repetitions for the digits 1227 is not 4!.
Answer: Represent each equivalence class by the number which has it's digits sorted.
Now this is uniquely determined by the number of 0s, number of 1s, ..., number of 9s.
Thus you need to find the total number of tuples $(n_0, n_1, \dots, n_9)$ such that
$\displaystyle \sum_{i=0}^{9} n_i = 4$ such that $n_i \ge 0$.
This is given by $\displaystyle {13 \choose 4}$
Since this also counts $0000$, the answer for your problem is $\displaystyle {13 \choose 4}-1$.
In general, the number of disitnct $n$-tuples of non-negative integers which sum to $k$ is given by $\displaystyle {n+k-1 \choose k}$.
See here: http://en.wikipedia.org/wiki/Stars_and_bars_%28probability%29
Answer: One approach is to work by cases of the number of matching digits.  If no digits match and none is zero, there are in fact $4!=24$ permutations.  So this accounts for $\dfrac{9\times 8\times 7\times 6}{24}$ equivalence classes.  If no digits match and one is zero, the zero cannot be the first digit, so there are only $3\times 3\times 2\times 1=18$ permutations and $\dfrac{1\times 9\times 8\times 7}{18}$ equivalence classes.  If you have one pair of matching digits and no zero, there are how many permutations and how many equivalence classes?

Combinations question


How to declare an output with multiple zeros in VHDL

Question: Hello i am trying to find a way to replace this command: Bus_S <= "0000000000000000000000000000000" & Ne; with something more convenient. Counting zeros one by one is not very sophisticated. The program is about an SLT unit for an ALU in mips. The SLT gets only 1 bit(MSB of an ADDSU32) and has an output of 32 bits all zeros but the first bit that depends on the Ne=MSB of ADDSU32. (plz ignore ALUop for the time being)
entity SLT_32x is
   Port ( Ne : in  STD_LOGIC;
         ALUop : in STD_LOGIC_VECTOR (1 downto 0);
         Bus_S : out  STD_LOGIC_VECTOR (31 downto 0));
end SLT_32x;

architecture Behavioral of SLT_32x is
begin
  Bus_S <= "0000000000000000000000000000000" & Ne;
end Behavioral;

Is there a way to use (30 downto 0)='0' or something like that? Thanks.
Comment: Thanks That should also work:
`constant C: std_logic_vector(30 downto 0):=(others => '0');`
`begin
Bus_S <= C & Ne;
Ne_out <= Ne;`
Answer: Try this: bus_S <= (0 => Ne, others => '0')
It means: set bit 0 to Ne, and set the other bits to '0'.
Answer: alternative to the given answers:

architecture Behavioral of SLT_32x is
begin
  Bus_S <= (others => '0');
  Bus_S(0) <= ne;
end Behavioral;

Always the last assignment in a combinatoric process is taken into account. This makes very readable code when having a default assignment for most of the cases and afterwards adding the special cases, i.e. feeding a wide bus (defined as record) through a hierarchical block and just modifying some of the signals.
Comment: this needs to be done inside a process, otherwise it won't work. at least not on ModelSim-Altera 10.3d
Comment: This is incorrect; you have two drivers for Bus_S(0) here (independent of the simulator or synthesis tool!). As @iSWORD says, you need to wrap this in a process.


How to organize structured data in pandas dataframe

Question: Suppose I have a DataFrame which has a subindex structure like the following, with 'date', 'tenor' 'mat' and 'strike' and where the fields to be observed are stored in the column 'vol':
date     tenor   mat strike    vol
20120903 3m      1y  0.25      52.
                     0.50      51.
                     1.00      49.
20120903 3m      5y  0.25      32.
                     0.50      55.
                     1.00      23.
20120903 3m      10y 0.25      65.
                     0.50      55.
                     1.00      19.
20120904 3m      1y  0.25      32.
                     0.50      57.
                     1.00      44.
20120904 3m      5y  0.25      54.
                     0.50      50.
                     1.00      69.
20120904 3m      10y 0.25      42.
                     0.50      81.
                     1.00      99.

Say I want to reorganize this data by getting a new dataframe with subindexes 'date' + 'tenor' and with 'values' given by a 3d array composed by 'mat', 'strike' and 'vol' from the original dataframe in a manner like this:
date     tenor   values
20120903 3m      [[1y,5y,10y],[0.25, 0.50, 1.00], [52., 51., 49.],
                                                  [32., 55., 23.],
                                                  [65., 55., 19.]]
20120904 3m      [[1y,5y,10y],[0.25, 0.50, 1.00], [32., 57., 44.],
                                                  [54., 50., 69.],
                                                  [42., 81., 99.]]

I tried with various attempts of 'unstack', 'groupby' and 'pivot' but with no success. I could only reach my objective byusing a lot of python vector manipulation, but this was a slow and inefficient procedure. Is there any specific, more efficient pandas procedure in order to get the same result? I'm getting lost at this...
Thanks for your help,
Maurizio
Answer: How about something like this:
In [111]: df
Out[111]:
                mat  strike  vol
date     tenor
20120903 3m      1y    0.25   52
         3m      1y    0.50   51
         3m      1y    1.00   49
         3m      5y    0.25   32
         3m      5y    0.50   55
         3m      5y    1.00   23
         3m     10y    0.25   65
         3m     10y    0.50   55
         3m     10y    1.00   19
20120904 3m      1y    0.25   32
         3m      1y    0.50   57
         3m      1y    1.00   44
         3m      5y    0.25   54
         3m      5y    0.50   50
         3m      5y    1.00   69
         3m     10y    0.25   42
         3m     10y    0.50   81
         3m     10y    1.00   99

In [112]: def agg_func(x):
    mats = list(x.mat.unique())
    strikes = list(x.strike.unique())
    vols = x.pivot('mat', 'strike', 'vol').reindex(mats, columns=strikes)
    return [mats, strikes, vols.values.tolist()]
   .....:

In [113]: rs = df.groupby(level=['date', 'tenor']).apply(agg_func)

In [114]: rs
Out[114]:
date      tenor
20120903  3m       [['1y', '5y', '10y'], [0.25, 0.5, 1.0], [[52.0...
20120904  3m       [['1y', '5y', '10y'], [0.25, 0.5, 1.0], [[32.0...

In [115]: rs.values[0]
Out[115]:
[['1y', '5y', '10y'],
 [0.25, 0.5, 1.0],
 [[52.0, 51.0, 49.0], [32.0, 55.0, 23.0], [65.0, 55.0, 19.0]]]

Comment: I just pasted your snippet in. You can use `set_index` or `reset_index` to make some columns the index or vice versa. My df has a MultiIndex with "date" and "tenor" as levels.
Comment: Hi Chang, thanks for your reply: one last question, how do you get the 'df' in the first line? I mean, yours looks different from my original one, in the fact that you appear to have just three columns originally ('mat' 'strike' and 'vol') whilst mine has just 'vol' values, the others being part of the index


How to know which sections or rows show up or visible on listnewcontroller

Question: I want to make a program where people can switch from listviewcontroller and map controller.
At a time, out of 100 rows, there are about only 5 - 6 rows shown at a time
How do I know which rows are being shown?
Comment: When do you need to know this? If the user just taps on a cell, a delegate method containing the appropriate NSIndexPath will be called...
Comment: Sometimes the user can see the map version of this.
Answer: UITableView has a method called visibleCells that returns an array of the currently visible cells.


Is Drupal Commerce compatible with Drupal 10?

Question: Don't see this answered anywhere.
I have Drupal 10 installed, as a dev site cohabiting with a live Drupal 7 on the same server.  I don't use composer for the D7 install, but can't get it to work on the D10 install since the "php.composer.phar" (in an attempt to make modules installs and updates) command jumps to server root over which I have no control & can't update.
If commerce isn't compatible maybe I'm wasting my time.
Answer: Seems to be more of an issue of being on a compatible host server than D10.
You'll want an up to date composer too as well as being on PHP 8.1.
You should be using composer with D9/10, unless you want a world of pain.
If you are doing development, then I'd be starting on a local /staging stack.
I'd probably target D9 with CKeditor 5 to begin with.  Just to save you some hassle with dealing with compatible modules.  There's still a lot of D10 patches that need to be put into releases.
Using CKeditor 5, will enable a simpler D10 upgrade.
I'm using Commerce on D9 + composer no issues.
Answer: Commerce 8.x-2.36 is marked as Drupal 10 compatible: https://www.drupal.org/project/commerce