Why are measures (aka "bars") important?

Question: Just as an example, let's say we have 60 BPM. So every second there's a beat. Imagine nodding your head every second to this rhythm.
Now isn't that enough information to make a song? If I have a metronome at 60BPM then I can rap over it, or play a melody/harmony over it, without thinking about bars at all.
So why do we take an extra step to group 4 of these beats to make a bar, and then think in terms of bars. Also, say if I change it from (1 bar = 4 beats) to (1 bar = 3 beats), how does that change the song? Because the BPM didn't change.. in the above example, I was just rapping to the metronome.
Edit: When I asked this question it was mainly me trying to produce beats on a DAW and bars/beats/tempo are all over the place and I didn't understand why it was defaulted to four beats in a bar. But it's interesting to read all the different perspectives so answer any way you want.
Comment: Bars are strongly related to time signatures, so this might be relevant: https://music.stackexchange.com/questions/31745/why-are-time-signatures-needed/31748
Comment: To help understand it from a poet to a rapper, English is a stressed (and, indeed, stress-timed) language. Every word has stressed and unstressed syllables (and, actually, lots more subtlety). I don't mean big, rare stress, just roughly half of syllables are stressed, half not. "I object" and "The object" are different only in their stress, but different words. I'm sure you do this in rap, if you're not a robot! Try listening to your favourite artists (but which is which is not a science). Bars do the equivalent in music, notes in particular positions get accents, like stress in English.
Comment: You could rap along to a clock ticking (as described in the question). It wouldn't be very interesting music.
Comment: [Erik Satie wasn't particularly fond of them](https://upload.wikimedia.org/wikipedia/commons/6/6b/Houghton_Typ_915.14.7700_-_Sports_%26_divertisements%2C_Water-chute.jpg). Then again, [he was a bizarre fellow](https://en.wikipedia.org/wiki/Vexations).
Comment: @user6697063 Leonard Bernstein gave a series of lectures at Harvard about a linguistic analysis of music which is very edifying. In any case, as soon as music has lyrics of any kind, then the line between language and music is clearly blurred. When I'm writing songs, I have to think about the verbal rhythms all the time, and often the verbal rhythm and stress pattern gives me the idea for the musical rhythm. Finally Aaron Sorkin has said "dialog **is** music".
Comment: It's important to remember that much of both music theory and music notation are hundreds of years old and developed somewhat organically over time, much like languages. Thus, just like languages, there is a fair amount of ambiguity and redundancy.
Comment: @ToddWilcox I posted a comment, not an answer because it didn't primarily relate to music but to language.
Comment: Four beats in a bar is a convention in cultures descended from or influenced by European origins. It's just the way we most commonly write music. It's not the only way, even in western music. Check out classical Indian music. There is much more variation in time signatures there.
Answer: First, I think that it would be difficult to read a piece of music with no bar lines. The bar lines help to break longer streams of notes into regularized and easily digestible chunks.
But it is also not true that a stream of 16 quarter notes should represent the same thing as four bars of four quarter notes. For example, typically in 4/4 time the One and the Three get accented, but not the Two and the Four; but of the One and the Three, the One gets a slightly stronger accent. On the other hand, in 2/4 time the One gets accented, but not the Two. All Ones receive the same accent, and all the strong beats receive the same accent. Here the feel is different from 4/4 time. A similar thing happens with 3/4 time compared with 6/8 time. In 3/4 time the One gets the accent, and in 6/8 time the One and the Four get the accents, with the One receiving slightly more emphasis. This means that 3/4 time and 6/8 time have different rhythmic feels.
So bar lines convey some information about rhythmic feel as well as helping to organize notes into easily digestible chunks. Maybe you could preserve time signatures and rhythmic feel without bar lines, but it would be very difficult to read rhythms this way.
Additionally, music tends to have a regular underlying pulse. Musical phrases are played against this pulse. Sometimes the same phrase is placed differently in different passages, or even within the same passage, of the same piece of music. The result is that the same phrase can sound different when played in different locations with respect to the pulse. Players are usually very sensitive to this when performing; jazz players often talk about "playing across bar lines" or will play the same phrase starting on different beats or subdivisions. All of this is really about sound and feel. Bar lines provide a way to represent the regular pulse of the music so that the ways in which phrases fit around it can be more easily seen in written music. In the end, bar lines are really a notational device.
Comment: I once wrote a string quartet without a meter signature or bar lines because I wanted the musicians to play it "meanderingly", without any sense of ever arriving at "one".   The composition teacher made me put in meter and bars.   : )
Comment: Also, imagine trying to rehearse with "let's go from the 47th note of the second page" or "that 22nd F was a bit flat".
Comment: I saw this answer in the linked question: https://music.stackexchange.com/a/31751/48252 and I think the ruler analogy is the easiest to understand, referring to your first paragraph
Comment: Indeed, it is difficult to sight-read music without any bar lines. Depending on the style it doesn't even matter if they're regular, as long as there's some mark between musical phrases.
Comment: @OrangeDog -- "it doesn't even matter if they're regular": not sure I can agree with this. One nice thing about bar lines is that they make it easy to see that this collection of quarter notes, eighth notes, sixteenth notes, thirty-second notes, and various rests occupies the same time as that collection of quarter notes. But that only works when bar lengths are regular. I tend think of bar lines as a sort of grid that helps you see how phrases relate to the underlying regular pulse of the music. It is true that even irregular markings would make it easier to find the 47th note of the 2nd page
Comment: @DavidBowling I said "depending on the style". If you're working with music that doesn't have barlines, there's a good chance it doesn't have a regular meter either. Also there's loads of even modern music that doesn't have regular barlines, because the "time signature" changes so frequently.
Answer: Please count 1-2-3-4,1-2-3-4, then at the same tempo (speed/ bpm) count 1-2-3-1-2-3.
If you can't feel or tell the difference, then, you're right, there's no need for bars. If you can, then how will someone else know which is which?
Comment: Ok, so I guess it's mainly for accenting purposes. like it helps us decide which beats to emphasize.
Answer: One bar tends to be the smallest time after which there is some repetition in multiple voices. This is quite a bit of an oversimplification, but it is often observable, in approximate form, in many very different genres.
Examples:

Baroque
X:1
C:Johann Sebastian Bach
T:Orchestral Suite #3, 3: Gavotte
L:1/8
M:C|
K:D
%%score T1 T2 A B
V:T1           clef=treble
V:T2           clef=treble
V:A            clef=alto
V:B            clef=bass
% 1
[V:T1] A2 af | g4     A2 ge | f4    A2 ec | d2
[V:T2] F2 fd | e4     E2 ec | d4    D2 E2 | A,2
[V:A]  D2 D2 | A4     A2 A2 | A4    A2 C2 | F2
[V:B]  (D,4   | D,2) C,B,, C,2 A,,2| D,2 D,,E,, F,,2 G,,E,, | F,,2

Here, the melody voices sequence down the motiv with minim on the 1 and quavers on the 4, the middle voices repeat the simple minim-crotchet-crotchet pattern, and the bass puts quavers on the 2.
Classical/Romantic:
X:1
C:Felix Mendelssohn
T:Symphony #1, 4: Trio
L:1/4
M:6/4
K:Ab
%%score O T1 T2 B
V:O            clef=treble
V:T1           clef=treble
V:T2           clef=treble
V:B            clef=bass
% 1
[V:O ] [Ec]6            | [FA]6            | [Fd]6            | [Fc]6
[V:T1] z3       (A c e) | z3       (A d f) | z3       (B d f) | z3                   (A c f)
[V:T2] (A, C E) z3      | (A, D F) z3      | (B, D F) z3      | (A, C f) z3
[V:B]  A,, z2    z3      | D, z2     z3      | B,, z2    z3      | F, z2                         z3

Blues / Rock'n'Roll accompaniment pattern
X:1
L:1/8
M:4/4
K:A
%%score D G B
V:D            clef=perc
V:G            clef=treble-8
V:B            clef=bass-8
% 1
[V:D] (3[Ee]ze (3[Be]ze (3[Ee]ze (3[Be]zE |  (3[Ee]ze (3[Be]ze  (3[Ee]ze (3[Be]zE
[V:G] [A,EAce]2 [A,EAcf]2 [A,EAcg]2 [A,EAcf]2 | [A,EAce]2 [A,EAcf]2 [A,EAcg]2 [A,EAcf]2
[V:B] A,,2 C,2  E,2 (3F,zE, |  A,,2 C,2  E,2 (3F,zE,

Reggae groove
X:1
L:1/8
M:4/4
K:Bm
%%score D G B
V:D            clef=perc
V:G            clef=treble-8
% 1
[V:D] ze [Be]2 [Ee]e [Be]e | ze [Be]2 [Ee]e [Be]e
[V:G] z2 [B,FBdf]2 z2 [B,FBdf]2 | z2 [B,FBdf]2 z2 [B,FBdf]2

...
It's also common to only find repetition after two bars, or already after half a bar. However, one bar is pretty much the shortest delay after which a complete repeat of an accompaniment pattern will sound "proper".
Comment: Though correct, that strikes me as a thoroughly inappropriate answer to an (as yet, and no offence intended) musically illiterate rapper!
Answer: To offer a different perspective from the other excellent answers here, I'll draw an analogy between a piece of music and a piece of prose.
Barlines are separators, just like paragraphs and chapters. You can write a perfectly fine essay in one massive paragraph, without losing any semantics conveyed by the individual words within. The existence of paragraphs and chapters however, make it much easier on the reader. It gives an indicator of when a new idea, a new scene or a new argument begins, thereby demarcating the structure of the essay. Similarly, barlines make the pulse of the piece very clear to the musician at a glance. The placement of barlines depends on the music in question; just as you wouldn't cut this sentence
into two with a paragraph break, you wouldn't change the barline placement from (1 bar = 4 beats) to (1 bar = 3 beats), if your music rhythmically repeats once every 4 beats. Barlines assist musicians by providing a guide to the rhythm of the music.
Barlines also aid in referencing. Just as it is convenient to refer to a passage in the book by its chapter number, musicians often refer to music by the bar number. This comes in useful especially in a group rehearsal setting, in order for everyone to begin rehearsing from the same point midway through the piece.
Comment: I understand that this analogy is not perfect and it breaks down in a lot of ways. But it is still excellent! Sheet without barlines would indeed feel the same as the wall of text without paragraph breaks.
Comment: A piece of metrical poetry might be a closer anology
Answer: Well, in a way, you don't need bars. Not for the sort of thing you were describing. If you just set a metronome up and start rapping away, you probably won't have any problems. But if you want to rap with a band, or anyone else, or if you want to write your music down, bars are necessary.
There are several reasons for the concept of bars:

Communicating metrical information. With your 60 BPM example, changing the meter actually does affect a lot about the song. Think about a waltz vs. a march. In a waltz, which is in 3, you count

1 2 3 |1 2 3...
With an assumed metrical accent on the first beat of each measure. A stead pulse from a metronome does not carry this information.
What if you had it in groups of four? Then, in most western circles, you would get:
1 2 3 4 |1 2 3 4...
In these examples the BPM did not change, however the feel of the song would dramatically change.
Once again, this is not communicated by a steady pulse from a metronome. Now, if you were rapping or singing or playing by yourself, you would almost undoubtedly use one of these, or another simple/compound meter, though you may not realize it. This is fine. But if you want to play with a group, especially if they're sight-reading something that you wrote, having the concept of bars coupled with time signatures is necessary.

Sight reading. You might be wondering why we can't just write out which beats are stronger without measures, and technically, we can. It's just really hard to read. Bars break the information down. It's much easier to feel measures than it is to theoretically know that certain beats are stronger than others. In a way, when playing as a group, nobody's really thinking that hard about measure, measure, measure, but counting becomes a lot easier when the numbers stay smaller.
Rehearsal. In orchestral settings, rehearsing one long stream of music would be quite challenging. First of all, if you got lost, it would really suck. Second of all, there's a lot of stop and go in rehearsals, and having measures as reference points, which give each beat their own unique feel in relation to the others (more having to do with meters) is profoundly useful. Thirdly, conducting is a lot more helpful when the conductor can show each beat in a measure by waving his hands in a different direction. For our 4 beats example, the conductor might show

DOWN right left up
With measureless music (which, actually, does exist) this isn't an option.
At the end of the day, measures are descriptive of the way we hear music and rhythm. They are also helpful for studying music as a group or even an individual because they allow places of reference.
Answer: Bars also make it easier to find and communicate reference points :

"Let's start again on bar 34"

Someone might count "1…2…3…4…" of bar 33 and everybody in the band will know exactly which note they should start with, and when to play it.
Answer: You'll actually find that more often than not, bars then occur in multiples of 8.  Music is structured by rhythm.  Where it gets interesting is when stuff works "against the beat" but just cannot escape it.  Usually this works by having a "rhythm section" establishing the framework that melody instruments (or voices) then move comparatively freely in without losing their reference.
It's also common for the rhythm section to change harmonies on dependable positions within the meter.
By the way: most dancers would be pretty unhappy not having larger structures than single beats since it makes getting into a dance's meter and impetus gain and arrest much harder to work with if you don't have anything to depend on.
Answer: Music is counted in beats, it is also counted in bars.  Count a march - Left right Left right, One two, One two.    Now count a waltz - One two three, One two three. That is why we sometimes group the beats in twos, sometimes in threes.
(Other bar lengths are also used, but they lack similarly neat illustrations.)
Comment: I'm confused by the same person providing this answer and criticizing another answer as being less useful to a "musically illiterate rapper" (a characterization that is unfair, unnecessary, and borderline on the 'be nice' policy, at best). Clearly this answer was not written with the "musically illiterate" in mind, why should any other answer be?
Comment: @GalacticCowboy it's a sincere question because bars are used in DAWs. So I guess in a way I am writing music. but I was talking about not wanting to write or read traditional sheet music. mccartney didn't either.
Comment: @foreyez - picking up on your first comment connected with this answer. I'd argue that those 'limits' are not being looked at properly. You have 80 songs. Each one, using your tactics, has/had to be 'learned'. What I try to get across to students - and now to you - is that when one can actually *read* music, the whole process of new stuff is incredibly quicker. In fact, there's no need to 'learn' any more stuff. I work in a couple of bands that will get the charts for a new song, and simply read it - usually note perfect. Think of the time saved by everyone here. O.k., we can go over bits >>>
Comment: @ToddWilcox I appreciate your comment very much. that said, I'm not offended by his comment as I'm illiterate in music by design. I don't read or write music and will never do so as I prefer everything by ear. I know about 80 songs now and working on them in all different keys and doing everything by ear and by theory I learn on this site. reading music I found limits me.
Comment: @foreyez I was interpreting "illiterate" in the figurative sense of "doesn't understand anything about music theory", not in the literal sense of "the only missing knowledge is how to read or write music". I guess your attempt at learning theory without reading music explains the difference between the two answers, since this answer does not include any notation. But now I'm confused about why Mr. Payne would criticize the other answer since until your comment, there was no content in the question or your profile indicating you have no intention of ever reading music.
Comment: @ToddWilcox I think he knows since I've hinted at it in other posts I've written. but for the record I'm not just a rapper. my main instrument is a celeste, followed by acoustic guitar, followed by an op-1 synth.
Comment: @foreyez Given your comments here, I fail to see how this is a sincere question. What you're asking is essentially, "Why are the accent marks on some Spanish letters important? I have no intention of reading or writing Spanish, only in speaking it. And I can speak Spanish just fine without the accents."
Comment: @foreyez In McCartney's case, he clearly had a wealth of natural talent, but he also had at least rudimentary musical instruction in the form of both piano and trumpet. Session recordings from the Beatles also demonstrate he knew the 12-note scale, different keys, and so on. So I think there's a distinction between "didn't" and "couldn't" or "wouldn't". And the Beatles were intimately aware of time signatures, because they played with them constantly, such as jumping back and forth between 3/4 and 4/4.
Comment: >>> a few times to try out phrasing, dynamics, etc., but for players like you ( I used to be one!) after spending (wasting?!) all the time learning something, it's much harder to change bits on the fly. I'm not denigrating being able to play by ear - I have to do that every week in certain situations, and am glad I can - but eschewing the reading/writing part will waste an awful lot of time and effort. Which could (should?) have been put into learning music on paper. Once one can read, there are tens of thousands, not 80+ songs at one's fingertips - literally! Serious point, worth considering!
Comment: @Tim meh, takes me like 10 minutes to learn a new song by ear. it's not THAT hard. my teacher can play by ear real-time (anything he hears) on any key. I'm working my way up to be like him. when you sit on a random piano it's not like you have sheet music with you. I'd rather just play whatever I have in my head. but granted, if you play in a band or orchestra then sheet music helps. but it's not for me. I did the sheet music thing for 4 years as a kid, hated every bit of it. so it's not like I didn't try.
Comment: @foreyez - not denying how useful it is by ear. I have to do exactly that when students turn up with a song they want to play - now. What about if you can't hear it first, though..?
Comment: @Tim that's impossible. not in today's world where you can look up anything in an instant on youtube or spotify on a mobile phone. we virtually can hear anything we want in a split second. the only reasoning behind sheet music is when multiple musicians come together and they need to play something with 100% accuracy. but for what I'm using music to do, that just doesn't factor. too many teachers teach students to read before they teach students to hear. and I'm completely against that. see my new question in this forum.
Answer: When the music is a song set to words, the accentuation implied by the bar lines is usually closely related to the rhythmic meter of the lyrics. For example:

We all know that this is stressed as
God save our gracious Queen /
Long live our noble Queen
But it would be quite possible to set it to a different tune as
God save our gracious Queen /
Long live our noble Queen
and this would need different bar lines to reflect the different stress in the music.
Answer: It's understandable that rap might not be as dependent on a division of beats into bars as other types of music. Rap can flow a lot more freely, and the words might or might not be arranged in phrases, verses or stanzas of the same length.
In other types of music the way the emphasis and phrasing are repeated is more important. In some cases there is a relationship between the music and the dancing that was popular at different times. A waltz is a dance step that repeats the same three steps over and over again, and the music that was played for a waltz did the same thing, repeated three beats over and over again. Bars were a way of keeping those three beats organized. Everybody danced the same three steps and the music helped them keep together.
So, while some types of music might not need such a strict structure, others are dependent on it for their identity.
Comment: I don't know if that's why the answer was downvoted, but: it's considered good behaviour in this site to edit a post if a clear problem has been pointed out in the comments. Blues really is not "usually" organised into 16 bars at all but into 12. Also, I think Blues is a bad example to begin with because it was originally played in a _very_ free manner that often didn't exhibit much of a bar structure at all. (Conversely, rap actually tends to stick to a very strict underlying rhythm as far as I know, which isn't much though.)


How to use a pdf.js promise in an own class?

Question: I like to write a custom PDF Viewer based on pdf.js in es6.
I have a viewer Class which calls a PdfLoader Class to get a pagebuffer filled with canvases but I'm stuck with the promises:
The PdfLoader Class:
const pdfjsLib = require("pdfjs-dist");
pdfjsLib.GlobalWorkerOptions.workerSrc = "./pdf.worker.bundle.js";

export default class PdfLoader{

    constructor(pdfPath, owner){
        this.pdfPath = pdfPath;
        this.customPdfViewer = owner;
    }

    loadingTask;

    getPageAsCanvas(pageNum){

        this.loadingTask = pdfjsLib.getDocument(this.pdfPath);
        this.loadingTask.promise
            .then(function (pdfDocument) {
                if(pdfDocument.numPages >= pageNum){

                    return pdfDocument.getPage(pageNum).then(function (pdfPage) {

                        const viewport = pdfPage.getViewport({ scale: 1.0 });

                        // There will be more canvases, this is just prototype stuff
                        const canvas = document.getElementById("pdfCanvas");
                        canvas.width = viewport.width;
                        canvas.height = viewport.height;
                        const ctx = canvas.getContext("2d");
                        const renderTask = pdfPage.render({
                            canvasContext: ctx,
                            viewport,
                        });

                        return renderTask.promise.then(function(){
                            this.customPdfViewer.insertPageToBuffer(pageNum, canvas);
                        })
                    })
                }
                console.log('Page ' + pageNum + ' does not exist!');
            })
            .catch(function (reason) {
                console.error("Error: " + reason);
            });
    }
}

And the CustomPdfViewer:
import PdfLoader from "./PdfLoader";

export default class CustomPdfViewer{

    constructor(pdfPath = "./assets/pdf/test.pdf", pageBufferSize = 4) {
        this.pdfLoader = new PdfLoader(pdfPath, this);
        this.pageBufferSize = pageBufferSize;
        this.pagesBuffer = new Array(pageBufferSize).fill({});
    }

    init() {

        for(let i = 1; i <= this.pageBufferSize; i++){
            this.pdfLoader.getPageAsCanvas(i);
        }
    }

    insertPageToBuffer(pageNum, canvas){
        this.pagesBuffer[pageNum - 1] = canvas;
        // ... and so on
    }
}

In my main script I just call

// Document Ready stuff and imports...

var pdfViewer = new CustomPdfViewer("./assets/pdf/test2.pdf");
    pdfViewer.init();

// ...

This even works so far but everytime (even if my pagebuffer is only 1) I get the message:
Error: TypeError: this is undefined
This comes from the catch part of my promise. It seems that my then and my catch part will be executed after each other in a single call.
What am I doing wrong?
Answer: It seems I finally figured out a solution, by using arrow functions.
Something like this, brings the "this" back into the right context:
Before:
return pdfDocument.getPage(pageNum).then(function (pdfPage) {
After:
pdfDocument.getPage(pageNum).then((pdfPage) => {


Extra Content Appears Below Footer

Question: I have an issue where I have the page for a specific role showing up on every page and additionally an error message.  These show up below the footer on the pages.  I've gone through the theme files and the blocks and I can't figure out what is causing them to appear.  I think the best way to show it is probably from the DevTools and inspecting the page.  You can see where the footer-bottom is and the EOF: #footer is for the theme.  Everything below that before /body and /html shouldn't be there.
Has anyone ever experienced something like this before?  I'm on Drupal 7, using Corporate Clean Theme.
Update:
The extra content also appears to append itself at the bottom when editing certain pages, so if I saved it without deleting it, it would appear within the main content and at the bottom of the page again.
Update 2:
It's definitely something that changed within the database and not the theme files.  When I import the last database before this happened, the extra content goes away, when I import the new one, it comes back again.  Additionally, there are a few pages when looking at in edit mode that are not showing up with the wysiwig editor, it looks like I'm editing them in plain text.
Answer: This was being caused by Cron run failing to complete for some reason.  We were able to solve the issue by installing the Cron Debug module and Cron would run successfully from there and clear up the extra text.

Extra Content Appears Below Footer


Integrating non-elementary functions

Question: An elementary function is a function that can be represented by a finite number of exponentials, logarithms, nth roots, and constants through composition. Clearly, an non-elementary function that is not elementary.
There are plenty of elementary functions such that integrating said function results in a non-elementary functions. Some quick ones that come to mind are $e^{x^2}$, $x^x$, and $\frac{1}{\ln{x}}$.
My question:

Is it possible to find a non-elementary function $f(x)$ such that $\int f(x)dx$ is an elementary function?

My intuition tells me no, but he's been wrong plenty of times before.
Comment: Think it for a little while. What operation undoes the integration? How does it act on elementary functions?
Comment: Got it. The derivative of an elementary function _is always_ an elementary function. Thus, if $\int f(x) dx$ is elementary, $f(x)$ must be elementary.
Comment: I'm not sure I follow. Differentiating any function finds the infinitesimal change in f(x) with respect to x. On an elementary function, this is no different.
Comment: $(\int f(x)dx)'=f(x)$. How ugly does it look the derivative of an elementary function?
Comment: @Bonnaduck it is encouraged to answer your question by yourself once you got it and accept your answer. Once you do it, your question will disappear from the list of unanswered questions, which is designed to contain questions that should be answered, which is not the case of your question anymore.
Comment: It is possible to express an elementary function $f$ with the help of non-elementary functions. But nevertheless, $f$ remains an elementary function.
Answer: The derivative of an elementary function is always an elementary function. Thus, if $\int f(x)dx$  is elementary, $f(x)$  must be elementary.

Integrating non-elementary functions


Postfix sending mail as root@example instead of firstname.lastname@example.com

Question: I'm trying to send mails from my server using postfix and it works perfectly except for one thing; it sends the mail as root@example instead of email@example.com.
Here's my config file, what did I miss?
# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = example.com
mydomain = example.com
smtp_generic_maps = hash:/etc/postfix/generic
virtual_alias_domains = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = example.com, localhost.example.com, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 188.8.131.52/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
#myorigin = /etc/mailname
myorigin = example.com

# My config
home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
virtual_alias_maps = hash:/etc/postfix/virtual

In case you need to take a look at my virtual file and generic file here they are respectively:
Virtual:
firstname.lastname@example.com    root

Generic:
root    firstname.lastname@example.com

Answer: check /etc/mailname and add a line 22.214.171.124 example.com example to /etc/hosts. Possibly your need to uncomment the myorigin line in your main.cf config. This should be the most common places, where the FQDN is derived from.
Comment: You were right, I had to change my hosts file from `22.214.171.124 example example` to `188.8.131.52 example.com example`. Thanks!

Postfix sending mail as root@example instead of root@example.com


The $5n+1$ Problem

Question: The Collatz Conjecture is a famous conjecture in mathematics that has lasted for over 70 years. It goes as follows:
Define $f(n)$ to be as a function on the natural numbers by:
$f(n) = n/2$ if $n$ is even and
$f(n) = 3n+1$ if $n$ is odd
The conjecture is that for all $n \in \mathbb{N}$, $n$ eventually converges under iteration by $f$ to $1$.
I was wondering if the "5n+1" problem has been solved. This problem is the same as the Collatz problem except that in the above one replaces $3n+1$ with $5n+1$.
Comment: It's false as stated since, e.g. 13, 66, 33, 166, 83, 416, 208, 104, 52, 26, 13, ...
Comment: A more interesting version of this question may be "How can we generalize the $kn+1$ problem to higher values of $k$ ?" since the naive way obviously doesn't quite work.
Comment: @Adrian: if $k=2^j-1$ we have "trivial cycle" at *1* and if $k=2^j+1$ at *-1*. The only "nontrivial" cycle that I've found besides $k=3$ and *n* in the negative and $k=5$ and *n* in the positive numbers is with $k=181$ where it gives two short cycles, each with smallest element below *100* - I think one has $n=33$ and the second one has $n=83$ , have it not at the top of my mind. *(It seems that $k=181$ solution is not widely known so far - using the common literature and internet search)*
Comment: @AdrianPetrescu: To complete my previous comment: in his 1978 paper R.E.Crandall reports, that for a large number of $k$ the existence of cycles for the $kn+1$-problem was tested, finding none except one for the $k=181$ problem (he was missing the second cycle). I'd recomputed such a program and ended up in: no cycle in $a_{\min} \lt 10000$ testing many lengthes for $k \le 1000 000$ except two cycles for $k=181$ with smallest elements $\lt 100$ .
Comment: @AdrianPetrescu even more generalised, if we have $n -> an + 2b + 1 for n odd; n -> 1/2 n for n even$, will $n$ end in a 4 2 1 loop?
Answer: You shouldn't expect this to be true. Here is a nonrigorous argument. Let $n_k$ be the sequence of odd numbers you obtain. So (heuristically), with probability $1/2$, we have $n_{k+1} = (5n_k+1)/2$, with probability $1/4$, we have $n_{k+1} = (5 n_k+1)/4$, with probability $1/8$, we have $n_{k+1} = (5 n_k+1)/8$ and so forth. Setting $x_k = \log n_k$, we approximately have $x_{k+1} \approx x_k + \log 5 - \log 2$ with probability $1/2$, $x_{k+1} \approx x_k + \log 5 - 2 \log 2$ with probability $1/4$, $x_{k+1} \approx x_k + \log 5 - 3 \log 2$ with probability $1/8$ and so forth.
So the expected change from $x_{k}$ to $x_{k+1}$ is
$$\sum_{j=1}^{\infty} \frac{ \log 5 - j \log 2}{2^j} = \log 5 - 2 \log 2.$$
This is positive! So, heurisitically, I expect this sequence to run off to $\infty$. This is different from the $3n+1$ problem, where $\log 3 - 2 \log 2 <0$, and so you heurisitically expect the sequence to decrease over time.
Here is a numerical example. I started with $n=25$ and generated $25$ odd numbers. Here is a plot of $(k, \log n_k)$, versus the linear growth predicted by my heuristic. Notice that we are up to 4 digit numbers and show no signs of dropping down.
Comment: [Related](http://math.stackexchange.com/a/470519/) (I was not aware of the existence of your post when writing that).
Answer: In Part I of Lagarias' extensive, annotated bibliography of the 3x+1 problem, he notes a 1999 paper by Metzger (reference 112) regarding the 5x+1 problem:

For the 5x + 1 problem he shows that on the positive integers there is no cycle of size 1, a unique cycle of size 2, having smallest element n = 1, and exactly two cycles of size 3, having smallest elements n = 13 and n = 17, respectively.

It is unclear from the notes whether the paper shows that these are the only cycles of the 5x+1 problem or whether there may exist longer cycles.
Comment: Does n=7 cycle or is it divergent?
Comment: It's not clear from the excerpt I quoted, but in that article the "size" of a cycle refers to the number of distinct odd elements in the cycle, not the length.
Comment: $n=7$ gives a pretty long cycle I believe.
Comment: 7 is element of a sequence which begins at 35 and has no more predecessor. It seems, that most of the sequences which begin at odd numbers, divisible by 5, have divergent trajectories (except, for instance, 65). It is also easy to prove for many short lengthes that there cannot be cycles of that lengthes.
Comment: $n=17$ gives a cycle of length 10.
Answer: Using a Python program, I calculated the orbit starting at 7. It seems to diverge to infinity with exponential speed. I calculated till the numbers exceeded $10^{1000}$. So probably, not every number will end up at 1. And not all numbers will end up in a cycle.
Initially, my program returned to 7 after a large number of steps. However, it turned out that the program made small errors when the numbers became very large. Using the decimal module resolved this problem.
Here is the code that I used:
from decimal import *
getcontext().prec=1001

def collatz5(n):
    if n%2 == 0:
        return Decimal(n)/Decimal(2)
    else:
        return Decimal(5)*Decimal(n)+Decimal(1)

n=7
for i in range(100000):
    if n>10**1000:
        print("bound exceeded")
        print("number of steps: ",i)
        break
    n=collatz5(n)

Comment: [A267970](https://oeis.org/A267970) is relevant, it gives a conjectured list of numbers that never loop

The $5n+1$ Problem


Show there exists a solution in $\mathbb{N}$ to $x^4-y^4=2z^2$ with $\gcd(x,y,z)=1$

Question: I am allowed to assume that $x^4-y^4=2z^2$ already has one solution in $\mathbb{N}$. From this I have shown that there exists a solution in $\mathbb{N}$ with $x,y$ both odd.
I am now trying to show that there exists a solution with $\gcd(x,y,z)=1$. My guess is that if $x,y,z$ already have a common divisor, then I can find another solution by cancelling/dividing $x$ by something dependent on $d$, and similar for $y,z$.
I started by assuming that $d$ is a common divisor of $x,y,z$. That is $x=da,y=db,z=dc$. Then $d^4(a^4-b^4)=2d^2c^2 \implies d^2$ divides $2c^2$. Here is where I am stuck. It feels like the natural thing to do here is to show that $\gcd(2,c^2)=1$, so that in fact $d^2$ divides $c^2$, but I cannot. And even then I don't know where to go from that point.
Comment: I'm assuming you won't accept $x=1,y=1,z=0$?
Answer: As you stated, you've shown there exists a solution with $x$ and $y$ both odd. Thus, you have that the common factor of $d$ must be odd as well. This means when you have $d^2 \mid 2c^2$, that $\gcd(2,d^2) = 1$, so $d^2 \mid c^2 \implies d \mid c$ (e.g., this is explained at If $a^2$ divides $b^2$, then $a$ divides $b$). As such, for some integer $e \ge 1$, you have $c = ed$, which means $z = (ed)d = ed^2$. When you plug this into your equation you get
$$x^4 + y^4 = 2z^2 \implies a^4d^4 + b^4d^4 = 2e^2d^4 \tag{1}\label{eq1A}$$
You can divide both sides by $d^4$ to get
$$a^4 + b^4 = 2e^2 \tag{2}\label{eq2A}$$
If $\gcd(a,b) = f \gt 1$, then $f \mid 2e^2 \implies f \mid e^2$. However, this means at least one prime factor of $f$ divides $e$, so it would have divided $x$, $y$ and $z$ initially, but that's not possible since the gcd value of $d$ was divided out. As such, $f = 1$, so $a$, $b$ and $e$ are relatively prime to each other, i.e., $\gcd(a,b,e) = 1$.
Comment: @AzamatBagatov You're welcome. Yes, an alternative is what you suggest, i.e., that you can repeat the procedure over and over again to end up at an eventual contradiction. It's rigorous and I have used that same procedure here to answer other questions, plus I've seen others do so as well. FYI, it's an example of [Proof by infinite descent](https://en.wikipedia.org/wiki/Proof_by_infinite_descent). I instead proceeded as I did above to continue from what you did since with the gcd removed, you can just end it in one step as I showed above.
Comment: Thanks, this was very helpful. Instead of everything in the final paragraph, is it not sufficient to say that if our 'new' solution $(\frac{x}{d},\frac{y}{d},\frac{z}{d})$ has some other common divisor $d' \neq 1$, then we can just derive a new solution by the exact same method? And that we can repeat this for all common divisors, until the only remaining common divisor is $1$, or is this not rigorous?


Transform the sample to make it more similar to a given

Question: $X=\{x_{i}\}$ and $Y=\{y_{i}\}$ are numeric samples: $y_i \ge 0, x_i \ge 0, i \in [0..N]$.
I need to find the mapping $F(X)=\{F(x_i)\}$ with fairly simple formula such that:

Euclidean distance $\rho(F(X),Y)$ between samples is minimal: $\sum_{i=1}^n(F(x_i) - y_i)^2 \rightarrow min$;
Expectations of the samples F(X) and Y are equal: $E[F(X)] = E[Y]$, i.e. $\sum_{i=1}^nF(x_i) = \sum_{i=1}^ny_i$;
Standard deviation of the samples F(X) and Y are close: $\sum_{i=1}^n(F(x_i) - E[F(X)])^2 - \sum_{i=1}^n(y_i - E[Y])^2 \le \varepsilon$
In addition:

$F(x_i) \ge 0$;
$\rho(F(X),Y) \le \rho(X,Y)$;
Answer: For
$$F(x)=\sum_i\prod_{j\neq i}\frac{x-x_j}{x_i-x_j}y_i\;,$$
all three conditions are satisfied identically.
Comment: [Lagrange interpolation](http://en.wikipedia.org/wiki/Lagrange_polynomial)


Getting error "The folder is already a source folder" when linking source in Eclipse

Question: In Eclipse, I am wanting to link an external source folder into my current project. To do so, I did the following steps:

With the project open, go to the menu bar and choose Project -> Properties
On the left side, choose "Java Build Path"
In the source tab, click "Link Source..."
Navigate to the other source folder (e.g. "OtherLocation/src")

However, whenever I do this, I get the following error in the link source folder window:

The folder is already a source folder.

I'm really not sure what to make of this. I know that it is a source folder, that's why I'm trying to link to it!
What is the real meaning of this error message and how can I go about resolving it?
Answer: Turns out that the error is referring not to the folder that you pointed to, but rather the name that you are giving it in Eclipse:

What the error message is really saying is that the project already has a folder called "src". You are currently telling the linked folder to appear in the project as another folder called "src", which would create a conflict. Just change the second field to something else and it will work.
In other words, it is not an issue with the name of the directory (there is no need to change that), it's just that you are giving it a name within Eclipse that matches the name of something that already exists in your project.


How do I use field_view_field() to print a user profile picture?

Question: I'm trying to print a user profile's picture in a block that gets displayed on a node page. I have the nodes author be loaded as in the following code:
<?php
$node = menu_get_object('node');
$user = user_load($node->uid);
?>

This is the code I have come up with for the block:

Meet the author

  <?php print drupal_render(field_view_field('user', $user, 'picture', 'user-pic-style'));?>

This isn't working and doesn't print anything.
I want the user's picture be loaded if users have one, or the default user picture if they don't.
I have other custom user fields that are printing just fine using the field_view_field(), so I am wondering why I am not having luck.
Comment: Please don't use $user = user_load(... it can conflict with global $user. Use $account = ... instead.
Comment: May I suggest that you re-title the question to be less specific to a particular function? Just "How do I programmatically render a picture", perhaps?
Comment: If you have the image url, you could do this -
print theme('image_style', array('style_name' => 'user-pic-style', 'path' => $user_picture_path));
Answer: Try this

Meet the author

  <?php print drupal_render(field_view_field('user', $user, 'picture', array('settings' => array('image_style' => 'user-pic-style'))));?>

Comment: Any ideas how to set a class to image?
Comment: You'd have to add a class using a preprocess function separately I believe - https://api.drupal.org/api/drupal/modules%21image%21image.module/function/theme_image_style/7
Comment: Thanks! I think so too, but didn't try yet.
Answer: I'm not entirely sure why the field isn't returning any data, but I think it has something to do with it being an image, and you not setting a style. Here's how I've done similar things with images before.
Please note that I have altered the code below both to protect my original customer, and to hide the fact this was done as a Ctools plugin, instead of a block. So there could be minor issues like misspellings and the like. My apologies if that's the case.
// Create a shortcut to the image we want to render
$image_data = $image_node->field_images[LANGUAGE_NONE][0];

// Image rendering data
$variables = array(
  'style_name' => 'blurb_208x208',
  'path' => $image_data['filename'],
  'alt' => '',
  'title' => '',
);

$styles = image_styles(); // Get all available styles
$style = $styles['blurb_208x208'];

// We are responsible ourselves for ensuring the derived image is available.
$derivative_uri = image_style_path($style['name'], $path_to_original_image);
if (!file_exists($derivative_uri)) {
  image_style_create_derivative(
    $style,
    $image_data['uri'],
    $derivative_uri
  );
}

$markup = '
' . theme('image_style', $variables) . '
';


Proof that coordinate lines are lines of curvature

Question: Prove that the coordinate lines of a surface patch are lines of curvature if and only if $f=F=0$.
Lines of curvature being defined as follows: A unit-speed curve $\gamma:I\rightarrow S$ in an oriented regular surface S is called a line of curvature if $\gamma'(t)$ is a principle direction for all $t∈  I$
I started with the equation for Gaussian curvature $K=\frac{eg-f^2}{EG-F^2}$, and with $f=F=0$, I have $K=\frac{eg}{EG}=\frac{e}{E}*\frac{g}{G}$
And Mean curvature $H=\frac{eG-2fF+gE}{2(EG-F^2)}=\frac{eg+gE}{2EG}=\frac{e}{E}+\frac{g}{G}$
Principle curvatures $k_1$ and $k_2$ as $k_1 +k_2=2H, k_1k_2=K$.
I'm having trouble understanding how to incorporate $\gamma$ as a principle direction and beginning the proof. Any direction of help would be great, thanks.
Comment: You're failing to use the definition of a principal direction.
Answer: Note that for a patch $x\colon U\subset \mathbb{R}^2\to\mathbb{R}^3$, the vectors $x_u$ and $x_v$ are the tangent vectors of the $u$- and $v$-lines. A $u$-line is parametrized by $\gamma(t)= x(t,v_0)$ with $v_0$ constant; $v$-lines are parametrized by $\gamma(t)=x(u_0,t)$ with constant $u_0$.
What do you now have to show? Well, you need to show that, at every point, $x_u$ and $x_v$ are eigenvectors of the shape operator. For this, you have to show that the matrix of the shape operator (w.r.t. the basis $x_u$, $x_v$) is diagonal.
Can you take it from here?
Comment: I'm not familiar with shape operators. They have not come up when dealing with this kind of problem
Comment: Well, which definition of a a principal direction do you use?
Comment: The eigenvectors {v1,v2}  are an orthonormal basis of TpS with respect to which the Weingarten map is represented by a diagonal matrix of the eigenvalues k1 and k2. The eigenvectors v1 and v2 are called principal directions of S at p.
Comment: I guess the shape operator is the same thing as the weingarten map after some reading
Comment: I got it now thank you for the direction


Change Omega4 Layout Based on Content Type via template.php

Question: I want to set Omega4 Layout defaults based on Content Type. I am trying to use the following code, but the hook_omega_layout_alter doesn't seem to use the $node variable. What am I missing?
I have already referenced Omega override simple-layout.tpl.php for content types but, once I try and and a switch statement based of $node->type it stops working.
What can I do to set the default Omega4 Layout based on Content Type using the hook_omega_layout_alter function?
function THEME_omega_layout_alter(&$vars, &$layout) {
  $node = $vars['node'];
  switch ($node->type) {
    case "article":
        $layout = 'article';
        break;
    case "blog":
        $layout = 'blog';
        break;
    case "market":
        $layout = 'market';
        break;
    case "merchant":
        $layout = 'merchant';
        break;
    case "product":
        $layout = 'product';
        break;
    case "update":
        $layout = 'update';
        break;
  }

}

Answer: As per referenced question I would go with something like the following:
function THEMENAME_omega_layout_alter(&$layout) {
  if (arg(0) == 'node' && is_numeric(arg(1))
      && $node = node_load(arg(1))) {
        switch ($node->type) {
          case 'article':
            $layout = 'article';
            break;
          case 'blog':
            $layout = 'blog';
            break;
          default:
            $layout = 'default';
        }
   }
}

Answer: So this works for me...
function THEME_omega_layout_alter(&$layout) {

  $default = 'basic';

  $layout = $default;

  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    $node = node_load($nid);
    if (isset($node) && $node->type == 'page') {
      $layout = 'basic';
    }
    if (isset($node) && ($node->type == 'project_page' || $node->type == 'project_front')) {
      $layout = 'full-page';
    }
  }
}

Hope that helps someone.
I personally think it is overkill to have to create new layouts in omega 4 to create minor changes... but hey, it is a quick and simple process!


Distribution of 2X - Y when X and Y are known

Question: I have been given a question:
<code> If X ~ N (3, 2²) and Y ~ N(1, 2²) what is the distribution of 2X-Y ?
</code>
The answer is given as N(5,20)
I assume the value for 5 is = 2x-y = (3 x 2) - 1
but where does the 20 come from ? I am very new to statistics and any help would be appreciated.
Comment: Then whoever (book, teacher) provided the question is deficient and doing students an injustice by "teaching" you to implicitly make assumptions, which in many real-world problems are not true and greatly affect the real-world answer.
Comment: Is it stated that $X$ and $Y$ are independent?  That is being assumed. Do you know these properties of variance https://en.wikipedia.org/wiki/Variance#Properties ? Learn them and use them.
Comment: Do you know how often I see people make completely unjustified assumptions of independence, in situations in which that has a tremendous effect on the answer?  A whole heck of a lot out in the real world.
Comment: well thankfully I have the brilliant minds of internet to actually teach me about statistics and not have me assume things :D
Comment: If X an Y are independent and normal then Var(2X-Y)=4Var(X) +Var(Y) and since Var(X) =Var(Y)=4  the answer is 4x4+4=20.  However as Mark Stone has pointed out if X and Y are correlated (in this case negatively correlated the Cov(X,Y) would be negative and so the variance for Z=2X-Y will  be less than 20. Now the means add together whether or not X and Y are independent.  So E(2X-Y)=2E(X)-E(Y)= 2x3-5.
Comment: This has the `[self-study]` tag & what the OP understands thus far. It doesn't seem unclear to me, although the question makes an unstated assumption of independence. I see no need for this to be closed.
Comment: No other information besides the question has been given
Answer: For two variables $X$ and $Y$, the variance of $aX-bY$ is:
$$Var(aX-bY)=a^2Var(X)+b^2Var(Y)-2ab·Cov(X,Y)$$
Where $Cov(X,Y)$ is the covariance between $X$ and $Y$. (source)
Usually the problem statement should say whether the variables $X$ and $Y$ are dependent or independent. Since this one apparently doesn't, I'm taking a guess and claiming independence—only because that matches the expected problem answer: first, the linear combination of two independent Normal random variables is a Normal random variable; Second, the covariance between two independent variables is zero.
So:
$$\begin{align}Var(2X-Y)&=2^2Var(X)+1^2Var(Y)-2ab·Cov(X,Y)\\
&=4 · Var(X)+Var(Y)-0\\
&=4·4+4\\
&=20\end{align}$$
Comment: @giusti I think it's also prudent to note that the answer is also a normal random variable and explain why the linear combination of two normal random variables is itself a normal random variable.
Comment: Good point. Please feel free to edit and add that to the answer.
Answer: There are a few important results that are required here. Based on the provided answer, I think an assumption of the question was that $X$ and $Y$ are independent random variables.
Let's try and start by proving an important result
$$X\sim N(\mu,\sigma^{2})\Leftrightarrow aX\sim N(a\mu,a^{2}\sigma^{2})$$
We can do this many ways, but let's use the moment generating function of the normal distribution. Let
$$M_{X}(t)=\mathbb{E}[e^{tX}]=e^{\mu t+\tfrac{1}{2}\sigma^{2}t^{2}}$$
and $$X\sim N(\mu,\sigma^{2})$$
So,
$$M_{aX}(t)=\mathbb{E}[e^{atX}]=e^{a\mu t+\tfrac{1}{2}a^{2}\sigma^{2}t^{2}}$$
and $$aX\sim N(a\mu,a^{2}\sigma^{2})$$
Another important result is the sum of two independent normal random variables.
If $$X\sim N(\mu_{x},\sigma^{2}_{x})$$
and $$Y\sim N(\mu_{y},\sigma^{2}_{y})$$
then $$X+Y\sim N(\mu_{x}+\mu_{y},\sigma_{x}^{2}+\sigma_{y}^{2})$$
Once again we can prove this using the moment generating function:
$$\begin{align}
M_{X+Y}(t)&=\mathbb{E}[e^{t(X+Y)}]\\
&\overset{*}{=}\mathbb{E}[e^{tX}]\mathbb{E}[e^{tY}]\\
&=e^{\mu_{x} t+\tfrac{1}{2}\sigma_{x}^{2}t^{2}}e^{\mu_{y} t+\tfrac{1}{2}\sigma_{y}^{2}t^{2}}\\
&=e^{(\mu_{x}+\mu_{y})t+\tfrac{1}{2}(\sigma_{x}^{2}+\sigma_{y}^{2})t^{2}}
\end{align}$$
So $$X+Y\sim N(\mu_{x}+\mu_{y},\sigma_{x}^{2}+\sigma_{y}^{2})$$
$^{*}$Due to independence between $X$ and $Y$.
Comment: @Hacklavya $X-Y=X+(-Y)=X+aY$ where $a=-1$ which is all covered in the above.
Comment: Please include (subtraction) in your answer as shown below:
 -  ∼ (+,2+2


Problem of Real Analysis

Question:
If $a \gt 0$, show that $$a^{x} \le 1 + (a-1)x ; \quad 0 \le x \le 1.$$
Comment: Lookup [Bernoulli's inequality](https://en.wikipedia.org/wiki/Bernoulli%27s_inequality). If you need to rediscover / independently prove that, then you should post more context.
Comment: post what you have tried when you ask a question on this site.
Answer: HINT One way is to consider
$$
f(x) = a^x + (1-a)x
$$
and show that $f(x) \le 1$ for $x \in [0,1]$. Another is to look at
$$
(1+x)^k = 1 + kx + \ldots
$$
e.g. via continuous interpretation of the Binomial theorem.

Problem of Real Analysis


Branches of mathematics not having a general method to solve

Question: I studied applied math, so each course (except abstract algebra) was dedicated to solution of a similar problems. After those courses it seems that every branch of mathematics has a developed theory with a few unsolved problems. I believe that is wrong. I found out that there is no general approach to Diophantine equations (the 10th Hilbert problem), to problems like "Collatz conjecture" and to nonlinear differential equations.
And so the question is: what is the other branches of mathematics (collections of similar problems) without a general method to solve them?
Comment: There's still no unified way to represent solutions to transcendental equations in closed form, IIRC.
Comment: You are mixing two things: being «underdeveloped» and «not having a general method to solve» are completely different things!
Comment: @Mariano Suárez-Alvarez, thank you I've change the title.
Answer: Diophantine equations are not special; any branch of mathematics in which it is possible to ask sufficiently strong questions will suffer a similar fate due to the existence of problems like the halting problem and the possibility of asking a question equivalent to the halting problem (or something similar).  For example, group theory has such problems: it is generally impossible to decide from a presentation of a group whether it is trivial or not.  See this list of problems on MathOverflow.
Comment: This is not "undeveloped" so much as "undevelopable."  Mathematics is much less complete than the average undergraduate education would have you believe!
Answer: There is no general method for solving differential equations.  There are general methods for proving existence and uniqueness of solutions, but not for computing solutions (if that's even possible) or for studying detailed properties of solutions.
You can make a tiny change to a differential equation and it can go from being well understood to being an area of research.  Or it can go from something one group of mathematicians study to something another group studies.
Comment: Even from the numerics viewpoint, it only takes a tiny change in the initial conditions for some DEs to see a change in the behavior of the solutions. Lorenz's set comes to mind.
Comment: If there are general methods for proving existence and uniqueness of solutions, why is [Navier–Stokes existence and smoothness](https://en.wikipedia.org/wiki/Navier%E2%80%93Stokes_existence_and_smoothness) problem still unsolved?
Answer: Irrationality of certain numbers is still though problem for mathematics. Even though irrationality of some numbers like square roots of integers that are not perfect squares and irrationality of $\pi$ and $e$ has long been known, it is still unknown whether $\pi + e$, $2^e$, $\pi^{e}$, $\pi^{\sqrt{2}}$,  $\pi \cdot e$ , $\pi / e$, Catalan's constant, Euler-Mascheroni constant, etc. are irrational or not, even though all are highly suspected to be.


How to connect multiple sockets in a single vuejs project?

Question: import VueSocketIOExt from 'vue-socket.io-extended';
import { io } from 'socket.io-client';

const socket = io('http://localhost:3200/');
const socket1 = io('http://localhost:3100/');

Vue.use(VueSocketIOExt, socket);
Vue.use(VueSocketIOExt, socket1);

I tried using the above code. But only only socket is working. Is it possible to connect both the sockets simultaneously.
Comment: This might help you https://stackoverflow.com/questions/51726558/vue-socket-io-how-to-connect-to-multiple-websocket-servers
Comment: have you tried adding the *forceNew* flag on the options, for example: `io("", { forceNew: true })`
Comment: yes. I did and it didnt worked
Comment: I need to connect multiple sockets at the same time. In this case when I am calling socket() socket ID of only the first socket is receiving.
Answer: Vue.use(VueSocketIOExt, socket1) is probably overriding Vue.use(VueSocketIOExt, socket), hence only the last one is taking into account IMO.
What if you try the following?
Vue.use(VueSocketIOExt, socket)
Vue.use(VueSocketIOExt2, socket1)

Comment: I need to connect multiple sockets at the same time. In this case when I am calling socket() socket ID of only the first socket is receiving.


Qual seria um bom algoritmo de cálculo hash para usar em uma tabela de espalhamento?

Question: Na pergunta Por que o hashCode() de String em Java usa 31 como multiplicador? fala-se do uso do número 31 como multiplicador. Foi posta uma controvérsia sobre a motivação deste número. De fato ele não é considerado tão bom. Qual seria um número bom? Por quê?
Mais ainda, o que uma função de cálculo hash deve ter para ser considerada boa para uso em uma tabela de espalhamento? Eu sei que ela deve gerar poucas colisões de códigos hash, eu queria saber o que deve ser observado nela para ser considerada boa. Eu já vi muita gente alegando que sua função hash é muito boa, mas são bem diferentes umas das outras, fico pensando se isto é subjetivo, mas não deveria ser, me parece algo bem matemático.
Comment: Considerando que poucas colisões é uma coisa boa, você precisa perguntar se precisa de reprodutibilidade ou de garantia de não colisão. Se o hash não precisar de reprodutibilidade, fazê-lo em uma função com fator aleatório (que muda a cada evento arbitrário), você impede um ataque baseado em degeneração da tabela de hash.
Comment: Mas como garantir não colisão? Aí deixaria de ser um *hash*.
Answer: Bom você precisa saber com que valores está trabalhando primeiro, meu hash vai receber uma palavra ou um numero?.
Digamos que seu hash receba uma palavra.
Você precisa transformar está palavra em um numero.
Para fazer isso você precisa calcular o valor de cada caractere.
Alguns exemplos:

Calcular valores usando a tabela ASCII;
Calular valores usando uma pré tabela similar customizada tipo um override da ASCII;
Calcular valores usando hex da UTF-8;
Calular valores usando Base64;

Algumas coisas que você pode fazer enquanto retorna os valores de cada carectere:
Imagine que na função lercaractere(char c) retorna um inteiro.

Operações comuns (Dividir, Multiplicar, Subtrair ou Somar por k)
Operações avançadas como Potencia, Fatoração de um Numero Inteiro.
Operação de conversão de base ex: x10 para x16.
Você tambem pode elevar a n e pegar um pedaço do resultado.

Importante gravar a posição de cada caracter de uma palavra.
Imagine o seguinte caso:
Se você pegar o valor de cada caracter usando por exemplo ASCII e apenas somar eles.

el = 8 + 10 = 18
le = 10 + 8 = 18

| le | el |  => terão o mesmo resultado.
uma solução pode ser :

calc = (c1)2 * (c1 / c2) * k;
k = algum numero primeiro como 27,31..7243 (no exemplo uso 31);
c1 = character posição 1;
c2 = character posiçao 2

le = (10)2 * (10 / 8) * k = 3875
el = (8)2 * (8 / 10) * k = 1587

Valores Inteiros Gerando os Indices
Bom nesse momento sua string deve retornar um resultado no exemplo acima:
Imagine que estamos trabalhando com a palvra el cujo valor é 1587, então agora vamos enviar este valor para nossa função hash.
Podemos utilizar alguns metodos:

Resto da Divisão -> (( el Bitwise AND 0x7FFFF)   % Tamanho_da_tabela));

Multplicação -> ( (el * Random(1))   * Tamanho_da_tabela));

Expontencial

Fatoração de Inteiros
Aqui você pode trocar a base dos Numeros mais uma vez talvez. XD

Tratamento de Colisão
Para tratar colisões você pode rodar um função que reserva um pedaço do hash evitando a colisão... exemplo:

AB45Z
AB45Y

Esses dois hash não colidiram por uma casa, nesse caso a disperção do algoritmo é ruim pois os hash gerados são muito parecidos, mas e se tivesse como reservar um pedaço do hash imagine o no mesmo exemplo que reservamos AB4.
Antes de gerar o hash então faremos um leitura verificando espaços reservados e se todos fossem ocupados poderiamos por exemplo dobrar o tamanho da tabela isso nos daria outro valor e possivelmente outro hash.
O java faz algo parecido no hash map porém ele dobra quando todas as casas da tabela forem preenchidas.

Tratamento de Colisão 2.
Uma outra maneira de evitar colisão é usar mais parametros na hora de gerar o hash exemplo:

Data e Hora atual com nano segundos.
Algum Dado como nome do usuario + senha.
Pi, E, ou PHI * Random(1);

Observaçoes :

Random(1) = numero randomico entre 0 e 1;
0x7FFFF = ao binario 1111111111111111111
Bitwise AND  = função para retornar um novo valor atravez de dois valores.

Legal dar uma olha em:

Princípio da casa dos pombos.
Congruência Linear.
Teorema chinês do resto
Pseudoaleatoriedade
Comment: O último parágrafo tem potencial, mas só o que foi postado é uma dica sobre o assunto não uma resposta que responde de fato o que foi pergunto.  O resto é enrolação.
Comment: Eu acho legal o esforço, mas me pareceu um compêndio de idéias esparsas, mais como "tentativas de solução" (que acabam ficando piores do que tirar o hash e por simplesmente um ID) do que realmente uma resposta para a pergunta. Mas vou reler com calma e boa vontade depois pra tentar enxergar o fundamento de cada coisa, antes de chegar numa conclusão definitiva. A parte de transformar em número realmente não me fez sentido, pq tudo "é número" no final, ou tudo é byte, dá na mesma. As representações são só para humanos.
Comment: Reformulei minha resposta para ser mais concreta.. Não sou nenhum perito no ramo então posso ter falado bobeira, mas espero ter ajudado.


Windows Update showing "Some settings are managed by your organization" on Azure Windows Server 2019 VM

Question: This is a Windows Server 2019 created in May 2020 on Azure.. It is a standalone server.
In Settings > Update and Security > Windows Update, I see the message 'Some settings are managed by your organisation.' When I click 'View configured update policies', I see that there are Policies set on my device:
Automatically download updates and install them on the specified schedule
Source: Administrator
Type: Group Policy

Set Automatic Update options
Source: Administrator
Type: Group Policy

I have opened Local Group Policy Editor and navigated to Computer Configuration > Administrative Templates > Windows Components > Windows Update. All of these settings are set to 'Not configured'.
Next, I checked if the computer was on a domain of some kind.

systeminfo says that DOMAIN is 'WORKGROUP'.

I ran dsregcmd /status and saw that AzureAdJoined, EnterpriseJoined, DomainJoined are all 'No'.

Using gpresult /r with elevated command prompt, I can see that in both Computer Settings and User Settings, no Group Policies have been applied.

So where are these Windows Update policies coming from?
I have seen the similar question here, but it is unanswered.
Comment: More setting values can be seen from: https://docs.microsoft.com/zh-tw/windows/deployment/update/waas-wu-settings
Comment: Policies are stored in the registry. Have you checked the registry location?  `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU` `HKLM\Software\Microsoft\Windows\WindowsUpdate\AU`
Comment: @GregAskew Hi Greg, I've checked this and indeed, there is a registry key 'AUOptions' which is set to 4 meaning 'Automatically download updates and install them on the specified schedule', and a 'NoAutoUpdate' key set to 0 which means 'automatic updates are enabled'. So this matches up. I wonder if this is a system default? These are the only two keys and there are no ScheduledInstallDay or ScheduledInstallTime keys, so I presume this AUOption isn't even functioning?
Answer: These are set in the Registry under HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU as mentioned by @GregAskew. The two keys you mention seem to be the default for the public Server 2019 Datacentre VM image (certainly is for the 10 or so I've deployed in Azure so far) leaving the Server OS free to download and install updates at whim out of the box.
In the initial 'un-configured' state Group Policy will show all these settings as 'Not Configured', despite the fact there are at least two matching Registry Keys configuring parts of it as you've identified. As far as I can tell any settings that are not configured in the Registry or Group Policy are able to be manipulated by the user from the Control Panel interface. This is support by the Help text for 'Configure Automatic Updates' option in Group Policy editor

If the status is set to Not Configured, use of Automatic Updates is not specified at the Group Policy level. However, an administrator can still configure Automatic Updates through Control Panel.

Conversely as you would expect, only those that are specified in either Registry or Group Policy are locked out from the Control Panel.
As soon as you start to edit the settings via Group Policy, the registry keys are modified and/or added to (relative to the specific Group Policy settings you manipulate in GPEdit).
Windows Update will still function despite apparent lack of configuration of some of these settings in either Registry or Group Policy. For example to address your question in comments about whether the AUOption is even functioning, again looking carefully at the Help for 'Configure Automatic Updates' option  in Group Policy editor it states:

If no schedule is specified, the default schedule for all installations will be every day at 3:00 AM. If any updates require a restart to complete the installation, Windows will restart the computer automatically. (If a user is signed in to the computer when Windows is ready to restart, the user will be notified and given the option to delay the restart.)

In my own Azure Tenancy I've set 'Configure Automatic Updates' 3 via Group Policy, set 'Install updates for other Microsoft Products' to TRUE and left everything unconfigured. I'm then using Azure Update Management to handle maintenance windows for install/restart and monitoring of update state, while I'm still testing it seems to be working well for me so far.
Comment: Very detailed response. This makes sense, thanks. I appreciate it.
Comment: I struggled with this for quite a while trying to get my Azure VMs to only install/restart in the maintenance window specific in Azure Update Management. Took me quite a while to realise that you had to configure the VM to not try and install things on it's own. Currently I'm working on seeing if I can create a Runbook that will apply the correct Group Policy settings are enforced on every VM Tenancy wide.


Has 'Administer content' permission always been required to expose publishing, authoring etc options?

Question: I've been using Drupal full-time for over six years and I always thought you could use the [content type] create, edit and delete permissions to allow users to create, edit and delete nodes AND use the 'Publishing options', 'Authoring information' etc settings on the node/#/edit page.
Looking at my most recent build today, this is not the case. Additionally, the 'Update options' dropdown and corresponding checkboxes are missing on the admin/content page.
I know there are third party modules like Override Node Options but I'm sure the above was possible.
Additionally, using the 'Administer content' permission is too aggressive because the user can then administer all content types, not just the ones you specify.
Has 'Administer content' permission always been required to expose publishing, authoring etc options? And is there a way around this other than using third-party modules?
Comment: This was poorly implemented by Drupal, IMO, hopefully it was fixed in 8/9
Answer: This is from node_form() in Drupal 7.0:
$form['author'] = array(
  '#type' => 'fieldset',
  '#access' => user_access('administer nodes'),
  '#title' => t('Authoring information'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#group' => 'additional_settings',
  '#attributes' => array(
    'class' => array('node-form-author'),
  ),
  '#attached' => array(
    'js' => array(
      drupal_get_path('module', 'node') . '/node.js',
      array(
        'type' => 'setting',
        'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))),
      ),
    ),
  ),
  '#weight' => 90,
);

Note that #access is set to user_access('administer nodes'). The revision and options fields have the same access set. So yes, it's always been required, at least as of Drupal 7.
You don't necessarily need a 3rd party module, but you'll need at least a custom module to make changes. You can implement hook_form_alter() (or hook_form_FORM_ID_alter()) to change the #access key of the desired elements in a few lines of code.


Delete custom metric and custom namespaces from cloudwatch

Question: Hi is there any way of getting custom metrics defined on cloudwatch log group be deleted along with its namespace. This is quite weird that we can create a custom metric/namespace using API/Console but cannot delete it either using API or Console from cloudwatch custom metrics/namespaces.
Answer: That's correct. You can't delete them. You have to wait till the associated metrics expire. From docs:

Metrics cannot be deleted, but they automatically expire after 15 months if no new data is published to them.

It could be worth nothing, that you are not charged for them. You are only charged when you put new data into them.
This is ongoing issue for years now, starting from 2011:

How could I remove custom metrics in CloudWatch?
Comment: this is what happens if you keep on building new services and don't improve your existing services first


Level of Rigor in Mathematical Physics

Question: I am a physics/math undergrad and I have recently become familiar with some more rigorous formalisms of mechanics, such as Lagrangian mechanics and Noether's Theorem.  However, I've noticed that the writing on mathematical physics (at a level that I can understand) that I've been able to find is not nearly as rigorous as math writing.  It often relies on heuristic reasoning or assumptions.  I understand that this is sort of how physics is often done (at least this is how it is taught at my uni), but I was wondering if more advanced physics/mathematical physics is as rigorous as pure math?  Or is this lack of rigor something I will just have to accept as I move on in physics?
Making assumptions in physics doesn't bother me, but I feel that sometimes I see arguments in mechanics that are very hand-wavy.  I feel I'd get a better understanding if the author would explicitly state whichever assumptions are needed: then the argument could take the form of a proof instead of heuristic reasoning.
I appreciate any insight into the subject.  Thanks for any help and sorry if this question is too vague.
Comment: Please, please, please do not just accept it. Make a difference!
Comment: depends upon what your notion of `rigor` is. Physics is about exploring and building upon it, continuously. Making theories and breaking them. Physicists accept this fact. More fundamental comes later in physics. This is different in mathematics. From late 18/19th Century, mathematicians, saw a necessity to give strong foundation to certain things first. This is where `rigor` originates from, in the sense you mention. Physicists do not prove everything like mathematicians do. Now, if we talk about mathematical physics (a term itself rather broad),  depends on who does it? If it is (ctd..)
Comment: This question has been asked [here](http://physics.stackexchange.com/questions/27665/the-role-of-rigor) on physics SE.
Comment: mathematicians, they will see the need to make it rigorous. Mathematical Foundation of Mathematical Physics should be well founded (`rigor`). Theory (Physical Foundation) will be speculative and explorative.
Comment: I think this [fantabulously beautiful lecture(the character of physical law, part 2)](https://www.youtube.com/watch?v=zesyeIvbjLQ), by Richard Feynman, will answer your questions.
Comment: If you need a rigorous treatment of mechanics and some other areas of theoretical physics, you might check out Abraham and Marsden's *Foundations of Mechanics*.  I's available off the web from Caltech for free.  Just google around a bit and figure out the exact URL from which to download.
Comment: There are two books I like a lot that you might be interested in.  One is Lieb and Loss "Analysis", which is focused on physics applications from a quite rigorous point of view.  The other book is Frankel's "Geometry of Physics", which covers a wide range of interesting topics, e.g. a comparison of Lagrangian and Hamiltonian mechanics from a mathematical point of view.
Comment: I don't know how rigorous most advanced physics is, but _nothing_ is as rigorous as pure math.
Comment: @Stefan: Your comment seems to mostly be an expression of faith by an initiate in the field.  "Rigor" is a rather slippery concept, but by any reasonable definition I can come up with, computer science and philosophy are both more rigorous than mathematics in certain aspects.  Anyone who has ever written down an "effective proof" and then gone to write code to implement it knows a sense in which coding is more rigorous.  In philosophy one needs to worry about things that simply are not of concern to working mathematicians, e.g. "What are numbers, really?"
Comment: You may find [this](https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHilbert%27s_sixth_problem&ei=S-tHVPzvBcfkuQSr-IC4BQ&usg=AFQjCNEBQrnp1r28u0-HP0PIsDYPGTQatA&bvm=bv.77880786,d.c2E) interesting.
Answer: It varies. A lot. The vast majority of physics you are likely to encounter at undergrad will be in the category of "things which can be formulated into theorems and rigorously proved". There are notable exceptions. For example, the foundational assumptions of statistical physics (around mixing and ergodic theory) are used fairly unjustifiably.
Things can be much more shaky closer to the forefront of physics research. In particular, quantum field theories, string theories and their ilk are treated rather more confidently than their foundations allow. Yet certain results about them are proved rigorously, with and without assumptions that everything is suitably well behaved. If you are a rigorous, meticulous person there are many many areas of research which are very thorough.
There is a difference between the above and things like "assuming that the solution to this equation is continuously differentiable" in mechanics, or (in some cases) "assume that this PDE has a differentiable solution" perhaps (with standard but tedious proofs, or difficult and off-topic proofs) where it's simply that it would be a completely different course to discuss the foundations. (Though this would also be the case for the above anyway.) I agree that providing references or quoting theorems would be nice here. It's not done often because it's considered unnecessary or boring or off-topic...
The simple point is that the answers to the above issues are not known but at the same time are almost certainly expected not to be pressing issues because making these handwaving assumptions gives good physics. There are plenty of corner cases and exceptions of course, which is why one major type of physics research amounts to finding exceptions to rules. Even when (to some extent at least) rigorous results are proved, it may not immediately be obvious what the loopholes are (supersymmetric theories come to mind, as related to Coleman-Mandula).
Ultimately, I feel strongly that teachers should make clear the distinction between known but off topic and unknown but physically plausible; but do be prepared to find a community which has to make assumptions because it is grounded in experiment rather than axioms. It would be insane to refuse to listen to anyone in particle physics in the last century simply because axiomatic QFT is hard.
Comment: Regarding the foundational assumptions of statistical mechanics, [this Physics SE question](http://physics.stackexchange.com/q/27402/4463) is probably worth a read.
Comment: Point (a) is a separate issue which I would usually classify as a problem of nonequilibrium statistical mechanics, which I believe most physicists would agree is poorly understood. Point (b) is roughly what the question I linked to is alluding to.
Comment: I think perhaps a more accurate or at least precise description of what I was alluding to is: (a) equilibration, mixing times, etc. are poorly understood; (b) the connection between ensemble properties and physical observables (e.g. via time averages) requires ergodic theory which doesn't necessarily exist.
Comment: I agree. I made a parenthetical remark saying "around" ergodic theory to avoid having to expand on this. This clearly backfired.
Answer: Unfortunately, the space between words in the construct "mathematical physics" is just half as stretched as in "mathematical art". Both things exist but what a professional mathematician would create as "mathematical art" and what a professional painter would do differ enormously and there are all shades in between. Both the level of rigor (the thing you noticed) and the relevance of the model to the material world (the thing you didn't mention) in the math. physics books can be anything from $0$ to $1$ completely independently of each other and many authors never tell you the exact point in $[0,1]^2$ they stand upon. "Feynman's lectures", say, are mostly at $(1,1)$ despite it is a pure physics book. I'll abstain from bringing up a $(0,0)$ example but you should be aware that it also exists.
You do not need to accept anything your mind revolts against. You can always change the textbook (or even the field of study). A book (or a lecturer) pursuing rigor will not always present a rigorous derivation of something, but will always either mention a reference to such derivation, or make a clear statement that at the current stage it is impossible to make perfect sense of this mathematically either at all, or without some particular leaps of faith, with full understanding that those leaps of faith seem to be correct as far as all our experience is concerned but if a counterexample arises in some range, it will invalidate the model and may invalidate the conclusions in that range as well. That's as much rigor as you can possibly expect there.
At last, it is worth mentioning that pure math. at high level is not as "rigor oriented" as one might think. It is true that you cannot claim a result until you have a watertight proof, but when mathematicians discuss how one could possibly approach a problem, the imagination, associations, and intuition play huge role. If you allow me a simple metaphor, the frontier of mathematics is not a set of theorems cut in stone but a cloud of ideas (many of which are half-baked). It is the ability to ride this cloud, which makes you a top mathematician, not just the skill of carving and masonry. Unfortunately, nobody knows how to take anyone else on this cloud ride without having him fall down or getting him lost in the mist within a minute, but it is known how to cut the cloud shapes out of stone and teach people to climb these shapes and to build them themselves. That's why we make students learn proofs and solve problems paying attention to every detail. The hope is that they'll eventually figure out how to fly. But until they are able at least to climb to the top of a simple brick pyramid of medium height, there is no chance they'll be able to stay in the lofts for long on any type of more advanced craft. Needless to say, no educationist will ever mention that...
Comment: This is a great answer.  Your comment that high level pure math is not "rigor oriented" is also a key one.  For several years now I have noticed that students and teachers talk a lot about "rigor" but discussion of this concept is almost entirely absent among mature mathematicians.  I am not sure I know what "rigor" really is!
Comment: This is precisely what is happening, except that physicists are flying on completely different clouds, and they learn to do it just jumping off airplanes without a parachute and smashing on the ground again and again and again. You produce results when you happen to fly a couple of times. The method of flying is by calculating precise results using computationally well-defined methods, rather than by proving theorems using logically defined axiomatic systems. The two methods are complementary, because axiomatic systems are too stupid about statistics to know about the computational methods.
Answer: The way I see it is that physicists use "hand-wavy" or "proof by intuition" because it is precisely that intuition that originally led them to use that mathematical model to describe the physical phenomenon in question. Physicists don't often concern themselves with which technical assumptions are needed because they are only interested in cases that arise in application, rather than pathological scenarios. As a crude example, Newton used calculus to describe basic mechanics without thinking about whether the relevant functions were differentiable everywhere, or whether the integrals converged absolutely, etc.
That we can, after the fact, rigorously prove many of the claims that physicists merely have intuition for is in many ways an affirmation of the incredible power of mathematics.
If you are interested in learning mechanics from a mathematical point of view, I suggest Mathematical Methods of Classical Mechanics by Vladimir Arnold.
Comment: Newton is infamous for his lack of rigor in mathematics.
Comment: @Stefan Infamous to us or to his 17th century peers?
Comment: @RR : To us.  I would guess that his 17th century peers didn't notice or care, but that is just a guess.  I would be curious if anyone knows whether any of Newton and Leibniz's peers objected to their sloppiness and hand-waving or if they were too grateful for their invention/discovery of calculus to complain.
Comment: @Stefan There is so much wrong with your analysis that I don't know where to begin.
Comment: your description actually sounds like the relationship between mathematicians and logicians; the latter fill some of the rigor holes the former leave behind
Comment: @Stefan: https://en.wikipedia.org/wiki/The_Analyst
Answer: I was also raised by physicists. Many mathematical discussions in my major (physics) courses left me dissatisfied. In particular, the treatment of vector calculus and variational calculus seemed mystical. Since then, I've seen what was hidden then and I understand why my teachers and texts did not show me the deeper aspects of that math.
Another topic that comes to mind is that of point charges in electromagnetism, the plethora of dirac delta functions and formulas such as $\frac{d}{dx}\theta(x) = \delta (x)$ stood in stark contrast to my real analysis course. On the one hand, in electromagnetics, we were teased for not knowing the derivative of a discontinuous function was a distribution called a function. On the other hand, I lost points in my math course for failing to say $c \in \mathbb{R}$ at the point in the proof where it matters. The dissimilarity of the disciplines was manifest in those semesters of my undergraduate. What I see now is this: if the physics courses really did the math then they would never get that far into physics. They have a way of doing math with notation which is unreasonably successful in the majority of instances. So, why should they teach math in their courses which distracts from the physical content of the course? I'm guessing the underlying reasoning is something like that, but I will admit it is a popular opinion that the professors just don't know the math so they can't teach it rigorously. Arrogance of youth or truth? I suppose it depends on your school.
Ok, so to summarize, the standard core topics in physics can be made rigorous with study of advanced calculus, variational calculus, perhaps a course covering the theory of distributions. And, a good PDE course. Much of what is hand-waved could be fixed with known math. You'll find these things as you go on because you care.
The other case is the edge of things. I think Sharkos and Fedja's answers are fantastic, really think about what they say. There are aspects of physics which will remain hand-wavy because at the base of it all the equations which frame physics do not
entirely describe physics. It is an art, there is some common intuition which goes
beyond the mathematical description (in my opinion, this is obviously not the sort of thing we can prove). This is especially apparent in classical mechanics where you meet some of these creatures with a deeper intuition than your own. But, it's not just mechanics. There is a difference between physics students and a physicist. For the real physicist it's hard-wired in some sense. I've met a few, I'm not one. The reason in part we don't say all those parameters which clarify the problem is that our thinking in physics is a bit fuzzy. Physical intuition keeps us on point so a lack of mathematical clarity is not as dangerous as it might seem.
To answer your question, I don't think it's usually the case that graduate physics is more mathematically rigorous. On some points, perhaps. On other points, the mathematical heresy cuts even deeper.
Answer: The classical mechanics initiated by Newton was very much non-rigorous at the time of its birth. After three hundred years it looks like mathematics, due to the services rendered by hundreds of mathematicians in the mean time. Electrodynamics, as developed by Maxwell and others were filled with ugly mathematics (like Dirac-delta function) at the early stage, but after one hundred years with the advent of "calculus of differential forms on smooth manifolds" the situation is getting better. After another hundred years, one can hope for a far better Electrodynamics than today. This is the way physics and mathematics go together.
Answer: I completed my PhD in pure math (differential/Riemannian geometry) a few years ago, and have recently turned my attention to quantum field theory and string theory, purely out of interest and curiosity.
I've learnt that physicists seem to use a different style of logical reasoning and derivations in their work, and a different process in the development of their body of knowledge.  They largely use the physics of a problem to guide their derivations and reasoning.  They use the scientific process of hypothesis and experiment to guide the development of physics - what passes as acceptable knowledge in physics is ultimately that which is validated by experiment to an acceptable degree of accuracy.  Physicists are interested in the final result of their reasoning of explaining the universe around us to an acceptable degree of precision, not necessarily in the level of mathematical rigour they displayed in getting to this result.  They do physics not mathematics.  These things take some getting used to and I understand that it couldn't really be any other way.
However, what frustrates me is I've noticed that physicists often use their own mathematical notations, definitions, terminology and even mathematical reasoning, even when clearer, simpler and in general better ways of doing things have been developed and highly refined within the mathematics community over a significant period of time.  Physicists also often seem to assume large amounts of universal symbols, notation and terminology - they often proceed with doing a significant amount of work, derivations, reasoning, etc, with undefined terms and mathematical notation, assuming that the reader already knows the notation and terms as though they are unambiguously and universally accepted in the wider physics community and set in stone.  I've read some theoretical physics books where the authors have used, and significantly drawn upon throughout the whole book, certain mathematical symbols and notations which they never actually defined in the first place.
You asked the question:  "but I was wondering if more advanced physics/mathematical physics is as rigorous as pure math? Or is this lack of rigor something I will just have to accept as I move on in physics?"
My experience is that mathematical rigour is less taken into consideration as you get into more advanced mathematical/theoretical physics.  Things get very confusing and if you don't understand or are unable to verify something you're reading, it becomes very difficult to discern if it's due to just not following along or that what you're trying to understand or verify actually isn't well founded mathematically.
Answer: I think that is the difference between mathematical physics and theoretical physics. I have a course in mathematical physics and it is mostly concerned with mathematical methods for solving partial differential equations. I think that many problems in mathematical physics are problems that are inspired by physics, for example the $n$-dimensional wave equation. Mathematical physics tries to formalize many of the ideas that come up in theoretical physics, for example renormalisation. Mathematical physics applies the same rigour as other disciplines in mathematics.
Theoretical physics on the other hand is more concerned with the physics than with the mathematics.  They are trying to find models for physial processes from which predictions can be made. They can then be tested in experiments.
You can read more about the difference here: Wikipedia: Mathematical vs. theoretical physics

Level of Rigor in Mathematical Physics


Update zabbix-agent mysql credentials

Question: I want to monitor my mysql server with zabbix.
So i've created a mysql user called zabbix. The user got a secret password.
Now is my question where i can update the password in the zabbix config? I read some pages in the internet and found something like this: mysql.status[zabbix,super-secret-password,Slow_queries]
Where should I insert this?
Answer: it's either in zabbix_agentd.conf.d or included in zabbix_agentd.conf
for my installation, zabbix configuration file is at /usr/local/zabbix/etc/
Comment: # find -name 'zabbix_agentd.conf' will show me this files:
'./usr/share/zabbix-agent/zabbix_agentd.conf' and
'./etc/zabbix/zabbix_agentd.conf' But in both there are only the 'GENERAL PARAMETERS' without mysql config

Update zabbix-agent mysql credentials


Trouble redirecting users after implementing LDAP

Question: We had a feature on our site where we redirected users with certain roles to a particular landing page upon logging in. In a custom module, we implemented hook_user_login(\Drupal\user\UserInterface $account) to examine the roles the user had, and redirect them to a particular landing page, depending on the user's roles.
Recently, we installed and configured the ldap module, so that users could log on with their LDAP credentials, and Drupal accounts would be auto-generated. However, we quickly found out that users with particular roles were not getting redirected on their very first login. Users belonging to other groups were correctly redirected upon creation of their Drupal account by means of _hook_user_login(), so it's strange that it only affects particular groups.
What happens is that, the first time you authenticate with LDAP credentials, the LDAP module creates a new Drupal user after successful authentication, then looks at your LDAP groups and assigns your user corresponding Drupal roles, mapped in the module's configuration.
I haven't been able to figure out why the redirection works for some roles but not others. Obviously, those roles are attaching to the account object earlier in the process than others. But where or why this happens, I haven't been able to figure out.
The second time the user logs in, the Drupal account has the roles at that point, and the redirect (running on hook_user_login) happens correctly. I am wanting to say that this works well enough, but my stakeholders want it to work correctly the first time.
My attempt to address the issue was to look at hooks implemented in the LDAP module, and see if any of those give me a user object with all of the assigned roles, from which I can figure out which landing page I should redirect the user to. I couldn't find robust documentation on the hooks, so I implemented each one in a custom module and debugged their arguments to see if any one gave me what I wanted. I found that hook_ldap_user_edit_user_alter($account, $ldap_user, $context) gave me an $account object. However in testing, at the time the hook fires, the account object only has the role anonymous. So, this attempt to use hooks defined in the ldap module seems stymied.
Is there a hook later on in the login/authentication process where I can get a fully fleshed-out user object, with all the roles that the LDAP module is assigning the newly-created user? Or is there another way I can redirect the user?
Answer: I was not able to find a hook that gave me what I wanted, but as a sort-of work around, I created an event subscriber that uses checkAuthStatus() to check the user and path, and redirect when necessary.
This is sub-optimal, because this event fires on every page load, as far as I can tell, but at least we got our feature.