Finding the "Starting point" when creating a composition or score

Question: This is a fairly simple one, and hopefully not too wide-open to be permitted here: what approaches are available when sitting at a fresh screen or sheet of paper, or at your instrument, to create the starting point for a composition?
I'm wondering if there are preferred methods as taught in the more formal books on the subject: arranging chords first then creating melodies over them, working the other way around, adding percussion first, working from lowest to highest-sounding instruments, scoring your own instrument first, etc.
Are there very visible advantages and disadvantages to any of those particular techniques? I've been known sometimes to write purely at a computer without an instrument near me at all, I have mixed feelings about it as it means I'm not limited by my own abilities, but I'm also not "feeling" the composition as I would be if I were improvising myself.
Comment: My understanding of the issue of composition is the whatever works approach. Though I don't compose myself, that's just always been my understanding of it.
Comment: I did consider doing so, but I wanted to leave it open. I write a lot of things, from technical death metal through to sweeping orchestral stuff, through to little poppy electronic ditties. I'm a believer that there's a commonality to composition that crosses genres, so I didn't limit this to just one.
Comment: This question could be more focused by specifying a musical genre for the composition.
Answer: If there were no specific techniques for beginning a composition, composition would likely not be a field of study.   Often within composition study, the teacher will provide a set of guidelines that essentially tell you how to start.  I am assuming that you are not working with a teacher here, which of course is the "real-world" case, and give you the number one rule I took from composition study:
Set limits.
Setting limits is decision-making, which in turn is composition.  You need to go from a blank slate to something tractable.  Some limits will nearly always be set for you if you are writing for a particular purpose.  For example, if a string quartet has commissioned a piece, the instrumentation is almost certainly the string quartet, so the instrumentation, texture, and pitch ranges available to you are already limited in a specific way.  Taking the abilities of the specific musicians into account is also important.  If you write a work that one specific musician or group can perform, others will probably also be able to perform the work.  It is too easy to write nearly-unperformable music, so keeping abilities in mind is important.  If you do not have specific musicians in mind, the preferred option is to find some.  If that is impractical, at least keep in mind the skill level of some "average" or "professional" or "student" musician(s) as you write.
Keep a few more things in mind here:
What if my limits don't allow me to use this really cool idea I have?
Then congratulations, you have a really cool idea you can use in a different piece with different constraints.  Consider keeping track of those ideas somewhere so you don't forget them!
What if my limits are not working for my piece?
If you set the limits, you can always change them.  Don't be afraid to set limits just because they might be too restrictive.  You can always change them later, provided they are not set for external reasons.
You don't have to compose the piece in order from start to finish.  In fact, you probably shouldn't.
On one choral piece, I had a text I wanted to use, and I knew exactly how I wanted the climax of the piece to sound.  I started there.  Start anywhere you want.  If you are not sure how to connect one section to another, skip it and come back.  If you have a melodic (or other) idea, but you are unsure where in your piece it goes, write it down somewhere anyway.  You can come back to it later when you know where it fits, like putting together a puzzle.  Or, maybe the idea comes from a different "puzzle" entirely.  Keep track of it along with your other "cool ideas" from above.
Decisions about form from the start can really help you get pieces finished.
Form can help you reuse elements throughout your piece so that you can get more mileage out of less material.  Further, form helps the piece be more coherent and, sometimes, more "comfortable" or "familiar-feeling" to the listener (if that is your goal).  Form is nearly always one of the first limits I set.
As implied elsewhere, there are probably at least as many approaches to composition as there are composers.  Nevertheless, you can do significantly better than "whatever works," and a composer who tells you that composing just involves "whatever works" either does not fully realize the assumptions he or she is making or does not want to reveal his or her secrets.
Comment: +1 Truly great answer pointing out the importance and effect of consiously deciding on limits. I've never thought of limits as being a compositional driving force this clearly before.
Answer: I think you'd get different answers depending on who you ask, so this may yet be closed as being too subjective.
Even the same composer may start at a different 'point' depending on the ideas they have at that moment in time.
For example, if they heard someone whistling an interesting melody in the street that day, then they may develop that melody first before harmonising it and then orchestrating it.
Alternatively they may have come across an interesting chord progression whilst at the piano and later try to craft a melody on top of it.
In the world of songwriting, Elton John and Bernie Taupin certainly worked in a very particular way (from Wikipedia):

The 1991 film documentary Two Rooms described the John/Taupin writing style, which involves Taupin writing the lyrics on his own and John then putting them to music, with no further interaction between the two.

But that doesn't mean words-then-music is the "correct" songwriting method. Alan Menken/Howard Ashman (of Disney fame) took a different yet equally successful approach (from theartsdesk.com):

When Howard and I wrote "Be Our Guest", I said, "You know I'm just going to give you some simple French piece of music." [He sings the melody.] It basically tumbled out as fast as my hands could play it. "That's the form, go take it, write the lyric, when you come back I'll write the real thing."

In terms of more instrumental composition, Howard Goodall (best known for numerous British TV themes) describes his creative process (pdf) when commissioned to compose a Requiem. A different approach yet again!
There are many "right" ways to go about composing music, but that's not to say there aren't "wrong" ways too. How you go about composing something will depend on what it is you are composing and what you have to work with. Some good questions to ask youself:
Is it functional?
If you are writing music to serve a purpose - say, a song important to the story in a musical or a jingle for an advert - then the form and content will be heavily dictated to you. Therefore, your focus should be on the best way to communicate that message/text through your music.
Do I already have a melody/text/chord progression?
If you happen to already have some idea of what your composition will sound like then it makes sense to develop it from that point outwards. If you have a melody, there'd be no point in writing anything else without that melody in mind; from the harmonisation through to the rhythms and instrumentation.
Does it need to fit a certain genre or style?
Again, this gives you something to work with - if you're composing a Romantic-style orchestral work you know you should be including some more exotic harmonies and wide-ranging dynamics than you would for, say, a Status Quo tribute band.
Having written all that, I can sum it up as "it depends", which probably means this will be closed!
Comment: Yeah, there's no "one true way", even for the same composer on different compositions. One day you might start with a hook, another day a bassline, another day a melody; sometimes people wake up with a fully formed song in their head!


Python program not returning function after if statement

Question: I'm writing a Python Tic-Tac-Toe bot and it keeps stopping after one if statement instead of restarting the function (code below). I'm fairly beginner-level at Python and would appreciate simpler answers.
code:
def process():
    uin = input('enter a move...')
    if uin == 'A1':
        atwo.remove('A1')
        bone.remove('A1')
        btwo.remove('A1')
        sou = random.choice(aone)
        print(sou)
        aone.remove(sou)
        return process
    elif uin == 'A2':
        aone.remove('A2')
        athree.remove('A2')
        btwo.remove('A2')
        sou = random.choice(atwo)
        print(sou)
        atwo.remove(sou)
        return process
    elif uin == 'A3':
        atwo.remove('A3')
        btwo.remove('A3')
        bthree.remove('A3')
        sou = random.choice(athree)
        print(sou)
        athree.remove(sou)
        return process
    elif uin == 'B1':
        aone.remove('B1')
        btwo.remove('B1')
        cone.remove('B1')
        sou = random.choice(bone)
        print(sou)
        bone.remove(sou)
        return process
    elif uin == 'B2':
        aone.remove('B2')
        atwo.remove('B2')
        athree.remove('B2')
        bone.remove('B2')
        bthree.remove('B2')
        cone.remove('B2')
        ctwo.remove('B2')
        cthree.remove('B2')
        sou = random.choice(btwo)
        print(sou)
        btwo.remove(sou)
        return process
    elif uin == 'B3':
        athree.remove('B2')
        btwo.remove('B2')
        cthree.remove('B2')
        sou = random.choice(bthree)
        print(sou)
        bthree.remove(sou)
        return process
    elif uin == 'C1':
        bone.remove('C1')
        btwo.remove('C1')
        ctwo.remove('C1')
        sou = random.choice(cone)
        print(sou)
        bthree.remove(sou)
        return process
    elif uin == 'C2':
        btwo.remove('C2')
        cone.remove('C2')
        cthree.remove('C2')
        sou = random.choice(ctwo)
        ctwo.remove(sou)
        return process
    elif uin == 'C3':
        btwo.remove('C3')
        btwo.remove('C3')
        ctwo.remove('C3')
        sou = random.choice(cthree)
        print(sou)
        cthree.remove(sou)
        return process
process()

Comment: does this game play w/o playerinteraction?
Comment: `process` is the function by itself, returning just the function won't *execute* it. So replace all your `return process` with `return process()` and you should solve the "my function stops after 1 iteration" problem.
This however doesn't mean your code is bug free, but this one in particular will disappear.
Answer: Put the function in a while loop
while True:
    process()

Then inside your function when the conditions to win the game are achived, put a break so it ends the loop.
Answer: From what I can see in your code, you are tending 3 different lists of "where are open spots".  I think it wouldbe easier to just tend one list instead, and get the "open" spots before choosing where to place.
You are trying to call the same function out of itself - this will lead to lots of stack-frames for each function call (python isolates function calls by preparing a "variable stack" memory area for that funciton that is cleaned up after you leave the function. If your function calls itself recursivly - they accumulate and clog down your computers memory) - most of the time it is better to avoid that and code non-recursivly using loops.
A board naturally leads to a 2-dim lists, you choose to also adress it by a letter and 1-indexed which leads to some back-and-forth calculations between the indexes in the list and the "output".
I added some functions that do certain things (return all unused spaces, set a space, pretty print the board, check wins):
ordA = ord("A")  # get the ascii value of A so we can compute the letter by the list-index

def getFieldsNotUsed(f):
    """Return all possible fields that are empty (if .strip()ed)"""
    for r_idx,row in enumerate(field):
        for c_idx,col in enumerate(row):
            if col.strip() == "":
                # get the letter that belongs to "A" + the 0bases list index
                yield chr(ordA+r_idx)+str(c_idx+1)

def setField(player,coord,f):
    """Places player (X or O) at coord [A1,A2,A3,B1,B2,B3,C1,C2,C3]-string"""
    print(f"{player} sets at {coord}:\n")
    r_idx = ord(coord[0])-ordA # compute the list index for row
    c_idx = int(coord[1])-1    # colum is easier, just int-ify the string and subtract 1
    f[r_idx][c_idx]=player

def printField(f):
    """Pretty prints the field given by f"""
    middle = 2
    for r in f:
        print("\t " + " | ".join( r ))
        if middle: # 0 is False
            print("\t" + "---|---|---")
            middle -= 1
    print("\n")

def checkWin(f):
    """Retunrs a winner-string or None - checks all rows && columns && both diagonals"""
    # check rows
    for r in f:
        if all( v == r[0] and v.strip() for v in r):
            return f"{r[0]} won!"
    # check cols
    for c in zip(*f):
        if all( v == c[0] and v.strip() for v in c):
            return f"{r[0]} won!"
    # check diag
    if (f[0][0] == f[1][1] == f[2][2] or
        f[0][2] == f[1][1] == f[2][0]) and f[1][1].strip() :
        return f"{r[0]} won!"

    return None # no wins

Main program
import random

# prepare the empty field with spaces - it is the only list to tend to
field = [[" "," "," "],[" "," "," "],[" "," "," "]]
player = ""
# get all fields that are still open
open_fields = list(getFieldsNotUsed(field))

# loop while open fields are present
while open_fields:
    # toggle the player from "" (at start) to X, then from X to O and back
    player = "X" if player != "X" else "O"

    # choose randomly, set player, print field
    place_where = random.choice(open_fields)
    setField(player, place_where,field)
    printField(field)

    # check win-conditions, continue loop if None else break
    win = checkWin(field)
    if win is None:
        open_fields = list(getFieldsNotUsed(field))
    else:
        # we got a winner - print it and exit loop
        print(win)
        break
else:
    print("Draw")

You can find the documentation to most of the used functions (ord,chr,int,range,zip) here:  Built-in Functions
Answer: It is important to understand the difference between return process and return process():
return process will not execute anything, it will just exit the function with the result being a reference to the process function. Your last line could use it like result = process() You could then loop on that result and you could exit the application at the end of the game by just returning None instead of the function.
return process() would execute the process() function and return its own result. You would get into the function more than once but it means that it will start chaining calls to functions and will chain-exit all of them at the end of the game. For a tic-tac-toe, it should work but for more complex stuff, this would probably cause a stack overflow.
The correct way would be to have a loop on the call to process() and not bother returning process itself.
Answer: You shouldn't be using return after every if - elif loop. Instead assign it to a variable and then increment that variable for every loop. Only one return per def:
def some_function(x, y):
    x = []
    y = "Some String"
    x.append(y)
    return y


The definition of a contractible space.

Question: I wonder if my approach is completely wrong. If so, may I request for some hints for heading to the right direction? Thank you!

Show that a retract of a contractible space is contractible.

The previous discussion Proof that retract of contractible space is contractible. used the definition that

The identity map on X is null-homotopic, i.e. if it is homotopic to some constant map.

But as to what I found, a space being contractible is simply defined as

A space having the homotopy type of a point is called contractible.

So following this definition, I can only carried out the proof in such a way:
We retract this space $X$ to $A \subset X$. Since $A$ is a subset of $X$, $A$ is also contractible.
So I am wondering, did I miss the definition somewhere? Or I should just use the other definition?
Thank you...
Comment: In general, a subspace of a contractible space is not necessarily contractible (take $S^1\subseteq \mathbb{R}^2$).
Comment: Yes @AldoGuzmánSáenz, but $\mathbb{R}^2$ can not retract to $S^1$, hence the retract is contractable. Should I follow this to prove..?
Comment: That is why it is important that $A$ is a retract of $X$, not just a subset of $X$.
Comment: @Jellyfish, yes, you are right, of course. I commented it because you wrote "Since $A$ is a **subset** of $X$, $A$ is also contractible" (emphasis mine), and I thought that maybe you thought that _any_ subset of a contractible space was contractible, which of course is not true. I see now that this was not the case.
Comment: Oh yes, I see what you mean @AldoGuzmánSáenz. I see why my proof won't work - so that means I have to use the other definition..? Thank you!
Comment: What is the definition of two spaces having the same homotopy type? The usual one is having two maps such that the compositions are homotopic to the identities of the spaces. In this case, I'd say that the proof in your linked question works.
Answer: A hint:
You have maps $A \xrightarrow{i} X \xrightarrow{r} A$ such that $ri = id_A$. You are also given the existence of a map $H : X \times I \to X$ such that, for each $x$, $H(x,0) = x$ and $H(x,1) = *$ for some fixed point $* \in X$. You can show that you might as well choose $* \in A$ (think about why -- must $X$ be path connected?)
You need to show the existence of a map $\widetilde{H} : A \times I \to A$ such that $\widetilde{H}(a,0) = a$ and $\widetilde{H}(a,1) = *$ for every $a \in A$. Try to build $\widetilde{H}$ using  the maps $H,i$ and $r$.
Comment: So that means I have to use the other definition..? Thank you Thomas!

The definition of a contractible space.


Using Drupal's session inside a PHP script

Question: I need to pass parameters from a Drupal page to a PHP script.
There's no way to pass that directly and I need to use SESSIONS.
I've searched around and added this at the top of the script:
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

With that I can use Drupal's session but I'm getting this error:
Warning: session_start(): Cannot send session cache limiter - headers already sent

It's not so bad since it's just a warning and I can use CSS to make it not visible to the user. But I was wondering if there is a cleaner way to do so.
Comment: Can the PHP script not be a Drupal module?
Comment: Unfortunately no...
It's a script for credit card company and i must do what they say...
Comment: Have you tried not bootstrapping Drupal and just trying to print_r($_SESSION); to see if what you need is in there?
Comment: of course...thats the first thing i did.
Comment: are you including anything above the code you provided? Maybe another include/require is printing out a header.
Comment: no... i've put it just beloew the "?<php" tag... the problem is that its a script inside an iframe inside a drupal form. so i'm guessing that the problem is that the drupal page is already started the session and when i bootsrtap it again in the iframe it gives me that warnings
Comment: This question may be answered elsewhere: http://drupal.stackexchange.com/questions/79807/loading-bootstrap-inc-in-external-php-file-in-a-subdirectory
Comment: Also similar to this one: http://drupal.stackexchange.com/q/22740/10729
Answer: In instances where I've had to do things like this I've done the following. It's worked for D6/D7 without any warnings for me.
  $current_path = getcwd(); //Current app path

  //Remove any HTTP headers/output
  header_remove();
  ob_clean();

  //Bootstrap Drupal w/ dir change
  //$drupal_root being the root Drupal install path
  define('DRUPAL_ROOT', $drupal_root);
  chdir($drupal_root);
  require_once "$drupal_root/includes/bootstrap.inc";

  /*Execute Code Dependant on Drupal Environment */

  chdir($current_path); //Return to existing app path

Answer: Verify that you do not print anything to the output buffer (with functions like echo or print) before setting/defining headers (with functions like header)
Comment: Thank you for the answer, but i cannot control this... i'm a regular drupal page(hook_menu) and in this page i've put an iframe with the php script... so basically drupal bootstrap runs twice and i'm guessing this is the problem but i don't know how to solve this
Comment: Try to add ob_start(); directly after the 3 lines you posted, this will start another output buffer preventing to send headers
Comment: Nope, this didn't do the trick...
Comment: Why are you starting drupal bootstrap in your script if it is already started before ?? You shouldn't need to do this.


Show that $|A-I|=0$

Question:
let A be a $ n \times n$ orthogonal matrix,where n is an even number with $|A|=-1\quad$.  Show that $|A-I|=0$

So basically I have to show that 1 is an eigenvalue of A.
Here is how I proceeded:-
Since A is orthogonal $$\Rightarrow AA^T = I \Rightarrow AA^T -I =0
 \Rightarrow AA^T -AA^{-1} =0 \Rightarrow A(A^T- A^{-1}) = 0$$
$$|A||(A^T- A^{-1})|=0 \Rightarrow|(A^T- A^{-1})|=0$$, since  $|A|=-1$
If A has the eigenvalue $\alpha_1,\alpha_2,\alpha_3,......\alpha_n$
Then $A^T$ must also have the same eigenvalues $\alpha_1,\alpha_2,\alpha_3,......\alpha_n$
Then $A^{-1}$ has the eigenvalues of $ \frac{1}{\alpha_1},\frac{1}{\alpha_2},\frac{1}{\alpha_3},.....\frac{1}{\alpha_n}$
Then $A -A^{-1}$ have the eigenvalues in the form of $\alpha_i -\frac{1}{\alpha_i}$
**I am not sure whether this above mentioned statement is correct **
then $|A -A^{-1}|$ can be written as $$\prod_{i=1}^{i=n} \alpha_i -\frac{1}{\alpha_i} =0 \Rightarrow \alpha_t -\frac{1}{\alpha_t} =0\quad \text{,for some t}$$
$$\Rightarrow {\alpha_t}^2 =1 \Rightarrow {\alpha_t} =\pm 1  $$.
This proves that some eigenvalue may take the value of +1, or -1.

I am not sure of how to proceed from here .Also I have a question about the purpose of even order of matrix A. Any other way to prove is welcome.
Comment: The conventional way to prove the statement is to note that $A-I=A(I-A^T)$.
Comment: For some variants see [here](https://math.stackexchange.com/q/443311/11619), [here](https://math.stackexchange.com/q/1841067/11619). I still think I have seen this handled on our site, so keeping my answer CW even though I could not find an exact duplicate.
Answer: Since $A$ is orthogonal, each of its eigenvalues is a complex number whith absolute value $1$. Since the eigenvalues are the roots of the characteristic polynomial of $A$, wich is a real polynomal, for each complex non-real eigenvalue $\lambda$, $\overline\lambda$ is also an eigenvalue and $\lambda.\overline\lambda=|\lambda|^2=1$. Therefore, $|A|$ is the product of the real eigenvalues of $A$, each of which is $\pm1$. Since the total number of eigenvalues is $n$, wich is even, and since the non-realeigenvalues come in pairs, there's an even number of real eigenvalues. Since their product is $-1$, they can't be all equal to $-1$.
Comment: Is there any proof of"Since A is orthogonal, each of its eigenvalues is a complex number whith absolute value 1?"
Comment: @DRPR If $v$ is an eigenvector of $A$ with eigenvalue $\lambda$, then $\|Av\|^2=\langle Av,Av\rangle=\langle\lambda v,\lambda v\rangle=|\lambda|^2\|v\|^2$. But, on the other hand, $\|Av\|^2=\langle Av,Av\rangle=\langle v,A^TAv\rangle=\langle v,v\rangle=\|v\|^2$. Since $v\neq0$ and $|\lambda|^2\|v\|^2=\|v\|^2$, $|\lambda|=1$.
Answer: Combine
$$|A-I|=|A-AA^T|=|A|\cdot |I-A^T|=-|I-A^T|=-|I-A|$$
and
$$|I-A|=(-1)^n|A-I|.$$
Comment: @DRPR For any square matrix $M$ we have $|M|=|M^T|$. Apply that to $M=I-A$.
Comment: $-|I-A^T|=-|I-A|$ how?

Show that $|A-I|=0$


Evaluating $\int \frac{\cos x}{\sin^3x+\sin x}dx$

Question: Given the function $$g(x)=\frac{\cos x}{\sin^3x+\sin x},$$ by letting $u=\sin x$, show that $$\int g(x) dx=\int\left(\frac{A}{u}+\frac{Bu+C}{u^2+1}\right)du$$ where $A,B$ and $C$ are constants. Hence, find $A,B$ and $C$. Hence, solve $\int g(x)dx$.
My attempt,
$$g(x)=\frac{\cos x}{\sin^2 x(\sin  x+1)}$$
$$=\frac{\sqrt{1-u^2}}{u^2(u+1)}$$
I'm stuck here.
Comment: Interesting that the recommended solution uses partial fractions rather than a second trig substitution.
Answer: If you do $u=\sin x$, then you must also do $\mathrm du=\cos x\,\mathrm dx$. So$$\int\frac{\cos x}{\sin^3x+\sin x}\,\mathrm dx$$becomes$$\int\frac1{u^3+u}\,\mathrm du=\int\frac1{u(u^2+1)}\,\mathrm du.$$Can you take it from here?
Answer: Method$\#1:$
$\sin x=u\implies $
$\displaystyle\int g(x)\ dx=\int\dfrac{du}{u(u^2+1)}$
Now using Partial Fraction Decomposition let $\dfrac1{u(u^2+1)}=\dfrac Au+\dfrac{Bu+C}{u^2+1}$
$\implies1=A(u^2+1)+u(Bu+C)=u^2(A+B)+Cu+A$
Comparing the coefficients of $u,u^2$ and the constants
$\implies C=0,A=1,A+B=0\iff B=-A=?$
Can you take it from here?
Method$\#2:$
$$I=\int\dfrac{\cos x}{\sin x(\sin^2x+1)}dx=\int\dfrac{\cos x\sin x}{\sin^2x(\sin^2x+1)}dx$$
Set $\sin^2x=v\implies dv=2\sin x\cos x\ dx$
$$2I=\int\dfrac{dv}{v^2(v^2+1)}=\int\dfrac{(v^2+1)-v^2}{v^2(v^2+1)}dv=?$$
Comment: You don't really have to go to all this trouble of doing partial fraction decomposition. You can split that fraction using basic algebra: $$\frac{1}{u(u^2+1)}=\frac{u^2+1-u^2}{u(u^2+1)}=\frac{u^2+1}{u(u^2+1)}-\frac{u^2}{u(u^2+1)}=\frac{1}{u}-\frac{u}{u^2+1}.$$


Existence of infinitesimal function

Question: Prove that exist function $\varphi :\left( {0,\varepsilon } \right) \to \mathbb{R}$ such that
$$\mathop {\lim }\limits_{x \to {0^ + }} \varphi \left( x \right) = 0,\mathop {\lim }\limits_{x \to {0^ + }} \varphi \left( x \right)\ln x =  - \infty .$$
I think $\varphi \left( x \right) = \frac{1}{{\ln \left( {\ln \left( {\Gamma \left( x \right)} \right)} \right)}}$ is fine. But i can't check that.
If we replace $ln$ by $f\left( x \right)$ such that $\mathop {\lim }\limits_{x \to {0^ + }} f\left( x \right) =  - \infty$, can we find $\varphi$?
Answer: Let $f$ be such that $\lim_{x\to0+} f(x)=-\infty$ Let $\phi (x)=\frac 1 {\sqrt |f(x)|}$. Then $\phi (x) \to 0$ and $\phi (x) f(x) \to -\infty$ (because $|\phi (x) f(x)|=\sqrt {|f(x)|}$ and $\phi (x) f(x)$ has the same sign as $f(x))$. This answers the second part and the first part is a special case when $f(x)=\ln (x)$.
Comment: What is $f$ in this answer?
Comment: @quid Have you seen the edited answer? If you need more details I will be happy to help.
Comment: @EthanBolker look at the last part of the question where $f$ is given. The first part is only a special case so my construction answers both parts.
Comment: Could you please add some phrase to the answer to explain a bit more. I agree it is an answer, but it is hard to see at first glance how it relates to the question.
Comment: Thank you for the expansion.
Answer: I guess you want something that shrinks to zero, but does so slower than $\ln$ grows. So what about $$\varphi(x) = |\ln(x)|^{-1/2}$$ I think that should work.

Existence of infinitesimal function


How to add a menu under Webform Results?

Question: In Drupal 7, I know we can use Views to add sub menu or menu tab on "My Workbench". The form result I have in "mydomain.com/node/99/webform-results" contained Submissions, Analysis, Table, Download, and Clear sub-menus. How can I add another sub menu next to "Submission"? I have tried to use the same method from Workbench, but it does not seem to work.
My new sub-menu setting in Views
Type: page
path: /node/99/webform-results/details
menu: Menu Tab: Navigation

Comment: Path should be `node/%/webform-results/details`, No?
Comment: You are right @Sumit Madan, but I only want to apply to that specific form. I want to show a field that only this form has.
Comment: Try selecting : `Default menu tab` instead of `Menu tab`.
Comment: Changing to "Default menu tab" does work, but I have to recreate all other tab menu and sub-menus, because the "Parent menu item: already exists" does not work on this situation. Can you post your answer below so we can close this issue? ty @Sumit Madan.
Comment: Glad it helps. I posted it as an answer.
Answer: Try to select Default menu tab instead of Menu tab.


Is there a Google Play Movie API?

Question: Trying to integrate Google Play's Movies and Series into http://www.BAGmovies.com, so our users can know which movies are for rent in Google Play
Is there a Google Play API for movies? I'm looking to

Make a call (e.g. with a Movie Title or Movie ID)
Get Availability / Price

Thanks!
Jaime
Answer: No, Google doesn't provide APIs for the features used in Google Play, Google Movie or Google Music apps. There are some inoffical Documentations/Libraries (reverse engineered), but I wouldn't recommend the usage of them. Especially not in a commercial background.
Answer: Yes, There is an API you can enable for Google Movies Anywhere. However, the API is for app integration, I'm not sure if you are trying to do web.
It's possible you do not need to use the API - an example intent for your first point:
<code>Intent movie = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/movies/details?id=" + movieId));
startActivity(movie);
</code>
Comment: where is the movie ID obtained from?

Is there a Google Play Movie API?


time-series of time-series

Question: I am trying to figure out how to make a time series of time series. I might not even be asking the right question.
I created individualized lm models based on one year of transactions for each customer using purrr, broom, dplyr and I did to do this for numerous different one-year windows of time. The goal is to measure the differences in the models over time.
I am sure there is a way to do it without just copying my code 12 times. I was hoping someone could point me in the right direction.
Comment: Does taking the first difference of the data help?
Comment: I would like each customer to have 12 different LM models, each model will encompass 12 months worth of data (weekly data as the time series).  The goal is to forecast churn or decrease in buying behavior. My hypothesis is that changes in the slop and intercept of the different models could potentially provide me some predictive value. I have a lot of other features that I was then going to put into xgboost.
Comment: @Ferdi I don't really know. I was thinking a fast way of doing this would be to create 12 copies of the data frame and modifying the date and customer ID. Customer A would become A1, A2, A3... the date 12/1/2016 would become 1/1/2017, 2/1/2017.... This way filter could be used. I could then combine the data frames and create the lm models I could them combine them back by the original customer ID.
Comment: If you want to avoid writing the code 12 times you can run a for-loop
Answer: The term for what you are doing is a lagged time series. In your case it sounds like you have a time series per customer and you want to compare different lagged 12 month windows for each customer.
Have a look at R's lag function. There is also a lot of background on lagged groups of time series in this answer.

time-series of time-series


Definitions of differentiability

Question: I have seen two definitions of differentiability of a real valued function and I wonder why they are equivalent.
The first definition: For a function $\mathbf{F}:\mathbb R^n\to \mathbb R$ is differentiable at $\mathbf x$, if there exist a matrix $\mathbf{DF}(\mathbf x)$ such that $$\lim_{\Delta\mathbf x\to\mathbf0}\frac{\mathbf F(\mathbf x+\Delta\mathbf x)-\mathbf F(\mathbf x)-\mathbf{DF}(\mathbf x)\Delta\mathbf x}{||\Delta\mathbf x||}=0$$
It turns out that $\mathbf{DF}=\nabla \mathbf F$
So if $\mathbf F$ is differentiable, $$\lim_{\Delta\mathbf x\to\mathbf0}\frac{\Delta\mathbf F-\nabla \mathbf F\cdot\Delta\mathbf x}{\Delta \mathbf x}=0$$
The second definition: If $\mathbf F$ is differentiable,
$$\Delta\mathbf F=\nabla\mathbf F\cdot\Delta\mathbf x+\epsilon\cdot\Delta\mathbf x$$
where $\epsilon=(\epsilon_1,\epsilon_2,...,\epsilon_n)$ and $\epsilon\to\mathbf0$ as $\Delta \mathbf x\to \mathbf0$
I know how to prove 2 implies 1 by Cauchy Schwarz inequality ($\epsilon\cdot\Delta\mathbf x\le||\epsilon||||\Delta\mathbf x||$) but I don't know how to prove 1 implies 2
Comment: There seems to be something wrong in the second definition. On the right hand side you sum the vector $\nabla\mathbf F\cdot\Delta\mathbf x$ and what I infer from your comments to be a scalar $\varepsilon\cdot\Delta\mathbf x$. That makes no sense ...
Comment: @String $\epsilon$ is a vector as well (I can't bold it) and bot right and left hand sides are scaler
Comment: Ah, right you are! I just got pre-occupied with the statement about $\mathbf{DF}(\mathbf x)$ being a matrix. You are talking about a multivariate *real valued* function $\mathbf{F}$ and not a vector valued one, so should not $\mathbf{DF}(\mathbf x)$ be a vector rather than a matrix? Then it starts to make sense, I think.
Comment: @String ya, actually I got this question when I was reading https://proofwiki.org/wiki/Characterization_of_Differentiability
Comment: Sorry about the confusion! I gave an answer to the question know, I hope it is satisfactory ...
Answer: For the other direction, define a function $k:\mathbb R^n\setminus\{\mathbf0\}\rightarrow\mathbb R$ by
$$
k=k(\Delta\mathbf x)=\frac{\Delta\mathbf F-\nabla \mathbf F\cdot\Delta\mathbf x}{||\Delta \mathbf x||}
$$
then $\Delta\mathbf F-\nabla \mathbf F\cdot\Delta\mathbf x=k\cdot||\Delta\mathbf x||$. Since $\Delta\mathbf x\neq\mathbf 0$ we have $||\Delta\mathbf x||\neq 0$. Thus we may define
$$
\mathbf\epsilon=k\cdot\frac{\Delta\mathbf x}{||\Delta\mathbf x||}
$$
in order to have $\mathbf\epsilon\cdot\Delta\mathbf x=k\cdot||\Delta\mathbf x||=\Delta\mathbf F-\nabla \mathbf F\cdot\Delta\mathbf x$. Finally, since we have assumed 1 to hold we know that $k\longrightarrow 0$ for $\Delta\mathbf x\longrightarrow \mathbf0$ and since the normed vector $\dfrac{\Delta\mathbf x}{||\Delta\mathbf x||}$ is bound to be on the unit sphere having length $1$ it follows that $\mathbf\epsilon=k\cdot\dfrac{\Delta\mathbf x}{||\Delta\mathbf x||}\longrightarrow\mathbf 0$. This proves that $\mathbf{(1)}\implies\mathbf{(2)}$.

Definitions of differentiability


Decreasing training learning curve

Question: I have made a learning curve that looks like this:

Why wouldn't it be more like both training and cross-validation score begin low
and both gradually increase with more samples? Why does one start high while the other
starts low? For example, this is how I thought it would look:

Thanks
Comment: I cannot see any images
Comment: What is "score"? What kind of metric do you use?
Comment: take a look at this video to understand learning curves :
https://www.youtube.com/watch?v=ISBGFY-gBug
Comment: See also http://scikit-learn.org/stable/modules/learning_curve.html#learning-curve, since this is tagged with scikit-learn
Answer: Because a sufficiently powerful machine learning algorithm (together with nicely separable data), will have no problem correctly classifying a small number of data points. Of course that usually means it will be overfitting to those few points, which is why your training score is high and your cross-validation score low.

Decreasing training learning curve


i am getting an Uncaught TypeError: Cannot set property 'onclick' of null

Question: // insert value using add buttons

btnadd.onclick= (event)=>{

let flag = bulkcreate(db.products, {

custname: custname.value,

items: items.value,

name: proname.value,

seller: seller.value,

price: price.value

   });
}

when I write this code then In console give an error is main.js:25 Uncaught TypeError: Cannot set property 'onclick of null
why this error come plz help me to find a solution
Comment: try wrapping it in a `window.onload= function() { // your code }`
Answer: This is because you need to create the button, get a reference to it, then pass it to your code
in your html
<button type="button" id="btn_add">Add</button>

Then is your JS, consider using this inside a page load event:
var btnadd = document.getElementById("btn_add");

btnadd.onclick= (event)=>{

let flag = bulkcreate(db.products, {

custname: custname.value,

items: items.value,

name: proname.value,

seller: seller.value,

price: price.value

   });
}

Comment: Problem was not solved same error are come
Comment: I would need to know what line and what code is on this line, or all of the code  main.js:25 Uncaught TypeError:


Python OOP --action() function

Question: I'm new to Python OOP and trying to create a OOP program to manage a library. This code is from a book.
This code is working as expected but I need to understand how the action() calls the corresponding function when I select a particular option, e.g.: when I select 1 the show_notes function is called even though we don't call it.
Menu.py
import sys
from notebook import Notebook, Note

class Menu:
    '''Display a menu and respond to choices when run.'''
    def __init__(self):
        self.notebook = Notebook()
        self.choices = {
                "1": self.show_notes,
                "2": self.search_notes,
                "3": self.add_note,
                "4": self.modify_note,
                "5": self.quit
                }

    def display_menu(self):
        print("""
Notebook Menu

1. Show all Notes
2. Search Notes
3. Add Note
4. Modify Note
5. Quit
""")

    def run(self):
        '''Display the menu and respond to choices.'''
        while True:
            self.display_menu()
            choice = input("Enter an option: ")
            action = self.choices.get(choice)
            if action:
                action()
            else:
                print("{0} is not a valid choice".format(choice))

    def show_notes(self, notes=None):
        if not notes:
            notes = self.notebook.notes
        for note in notes:
            print("{0}: {1}\n{2}".format(
                note.id, note.tags, note.memo))

    def search_notes(self):
        filter = input("Search for: ")
        notes = self.notebook.search(filter)
        self.show_notes(notes)

    def add_note(self):
        memo = input("Enter a memo: ")
        self.notebook.new_note(memo)
        print("Your note has been added.")

    def modify_note(self):
        id = input("Enter a note id: ")
        memo = input("Enter a memo: ")
        tags = input("Enter tags: ")
        if memo:
            self.notebook.modify_memo(id, memo)
        if tags:
            self.notebook.modify_tags(id, tags)

    def quit(self):
        print("Thank you for using your notebook today.")
        sys.exit(0)

if __name__ == "__main__":
    Menu().run()

notebook.py
import datetime

# Store the next available id for all new notes
last_id = 0

class Note:
    '''Represent a note in the notebook. Match against a
    string in searches and store tags for each note.'''

    def __init__(self, memo, tags=''):
        '''initialize a note with memo and optional
        space-separated tags. Automatically set the note's
        creation date and a unique id'''
        self.memo = memo
        self.tags = tags
        self.creation_date = datetime.date.today()
        global last_id
        last_id += 1
        self.id = last_id

    def match(self, filter):
        '''Determine if this note matches the filter
        text. Return True if it matches, False otherwise.

        Search is case sensitive and matches both text and
        tags.'''
        return filter in self.memo or filter in self.tags

class Notebook:

    '''Represent a collection of notes that can be tagged,
    modified, and searched.'''

    def __init__(self):
        '''Initialize a notebook with an empty list.'''
        self.notes = []

    def new_note(self, memo, tags=''):
        '''Create a new note and add it to the list.'''
        self.notes.append(Note(memo, tags))

    def _find_note(self, note_id):
        '''Locate the note with the given id.'''
        for note in self.notes:
            if str(note.id) == str(note_id):
                return note
        return None

    def modify_memo(self, note_id, memo):
        '''Find the note with the given id and change its
        memo to the given value.'''
        note = self._find_note(note_id)
        if note:
            note.memo = memo
            return True
        return False

    def modify_tags(self, note_id, tags):
        '''Find the note with the given id and change its
        tags to the given value.'''
        note = self._find_note(note_id)
        if note:
            note.tags = tags
            return True
        return False

    def search(self, filter):
        '''Find all notes that match the given filter
        string.'''
        return [note for note in self.notes if
                note.match(filter)]

Answer: Functions and methods are themselves objects.  So the dict contains objects which we then call.
So self.choices is a dictionary with "1", "2", etc as keys.  The values are method objects.  When you get the value from the dictionary, you get that object (called a "callable") and assign it to action.  Then you call that object with action().
The key bit of code is this:
 self.choices = {
            "1": self.show_notes,
            "2": self.search_notes,
            "3": self.add_note,
            "4": self.modify_note,
            "5": self.quit
            }

self.choices["1"] evaluates to the value of self.show_notes, which is then assigned to action, which you then call with action().
(As an aside: The menu in the example code is hardcoded, but in fact could be autogenerated, if the methods had docstrings.  "\n".join("%s: %s" % (key, action.__doc__) for key, action in sorted(self.choices.iteritems()))  To properly handle a menu with >=10 items, you'd want to make the keys into integers, or expand the one-liner.)
Comment: If the action variable would be called `task`, would one call the callable then `task()`? Or is action a built-in type, or convention similiar to `self`?
Answer: self.choices is a dictionary of methods.  When you select "1" this is happening:
action = self.choices.get("1")  # action = self.show_notes

Therefore when you call action() you're actually calling self.show_notes().
Answer: You call the function here:
action = self.choices.get(choice)  # <--- get the function based on user input
if action:
    action()   # <--- call the function here

If choice is equal to '1' the above code will assign self.show_notes to action and then call it.
Answer: in menu.py::__init__, self.choices is a dict, where the keys are integers, and the values are functions. In menu.py::run, choice is input from stdin, and is used to key into the self.choices dict. so the line
action = self.choices.get(choice)

is setting action to be one of the functions in self.choices. This function can then be called:
action()

Python OOP --action() function


How is potential profit from an arbitrage bet (a.k.a. surebet) calculated?

Question: Arbitrage bet or surebet means betting on all possible outcomes in which you make profit independently on the result of the event.
How exactly can I calculate whether given odds form an arbitrage and what the potential profit could be?
Comment: As merging the sport betting proposal with this site [is being discussed at the moment](http://discuss.area51.stackexchange.com/questions/11541/should-sports-betting-be-merged-into-sports), one of the reasons I have posted this questions was to have more questions about betting here, so that we can see how they are received.
Comment: I have posted an answer [simultaneously with the question](http://blog.stackoverflow.com/2012/05/encyclopedia-stack-exchange/). Answering own questions is actually encouraged, see [It's OK to Ask and Answer Your Own Questions](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) at SE blog.
Comment: Who was against you posting an answer to your question? It is in our [help center](http://sports.stackexchange.com/help/self-answer), [this meta post](http://meta.sports.stackexchange.com/questions/296/is-it-acceptable-to-ask-a-question-already-knowing-the-answer), and the links you reference. Thus, this is already comprehensively covered.
Comment: @edmastermind29 There were not any complaints. I just thought that it might be good to put an explanation into a comment; maybe not every user is familiar with those links.
Comment: True. That's what the help center's for. Thanks for leading users to helpful links :)
Answer: Complementary bets
First let us look at the situation where we have several possible outcomes, which are complementary, i.e., exactly one of these results can happen.
There can be various number of complementary outcomes; we can have 2 of them (two players in a tennis match, over/under in a soccer match, home/away in ice hockey), 3 results (home/draw/away in soccer, or regulation time in ice hockey) or even more results (for example, betting on exact score 0-0, 1-0, 0-1, and complementing this with over 1.5).
Let us try the case of 3 possible outcomes; the computations are similar in the case of other number of results.
We may have the following outcomes and odds:
-------------------------------
|   | odds | stake | winnings |
-------------------------------
| 1 |  o1  |  b1   |   o1*b1  |
-------------------------------
| X |  o2  |  b2   |   o2*b2  |
-------------------------------
| 2 |  o3  |  b3   |   o3*b3  |
-------------------------------

We would like to maximize the winning in the case of any outcome, hence
W=o1b1=o2b2=o3b3
which yields
b1=W/o1
b2=W/o2
b3=W/o3
If we bet the amount of B altogether, then
B=b_1+b_2+b_3=W(1/o1+1/o2+1/o3).
To obtain an arbitrage, we need W>B, i.e.,
1/o1+1/o2+1/o3<1.
And the fraction
W/B=1/(1/o1+1/o2+1/o3)
represents how much is the winning larger than our stake. We can also calculate from the above equations b1,b2,b3; i.e., the percentage of our stake to put on various outcomes.
We can have a look on a particular example. Suppose we find the following odds at various bookmakers
-------------
| 1 |   6   |
-------------
| X |   5   |
-------------
| 2 | 1.746 |
-------------

Since 1/6+1/5+1/1.746=0.9394<1 this is an arbitrage, and the profit is 1/0.9394=1.0645; which means the potential profit is 6.45%.
Arbitrage of type pk/X/2
Let us have a look at one more type of arbitrage.
Many bookmakers offer bet called pk (standing for pick-em)
or handicap 0 which works as follows: If the team wins, the
bettors obtains the winning; in the case of draw the bettor gets
his stake back. If the team loses the match, the bettor loses his
stake.
Let us have a look again what happens if the bettor bets on all
three possible outcomes. (They are, so to say, partially
complementary.)
-------------------------------
|   | odds | stake | winnings |
-------------------------------
| pk|  o1  |  b1   |   o1*b1  |
-------------------------------
| X |  o2  |  b2   | b1+o2*b2 |
-------------------------------
| 2 |  o3  |  b3   |   o3*b3  |
-------------------------------

We try to optimize the wagers in a such way that the winning in all cases is maximal possible. This yields the winning
W=o1b1=o3b3=b1+o2b2
The first equality yields
b1=W/o1
b3=W/o3
Now we can use b1 to compute b2.
b_2=(W-b1)/o2=W/o2-W/(o1o2)
Using b1+b2+b3=1 (i.e., assuming b1,b2,b3 represent the percentage of the stake) we get:
W/o1+W/o2-W/(o1o2)+W/o3=1
1/o1+1/o2-1/(o1o2)+1/o3=1/W
1/(1/o1+1/o2-1/(o1o2)+1/o3)=W
Hence we can obtain an arbitrage if
1/o1+1/o2-1/(o1o2)+1/o3<1
(which is equivalent to W>1.)
Again, we can compute b1, b2, b3 from the above equations. We can have a look at an example again. Suppose we have match with the following odds:
-------------------
| home, pk | 2.24 |
-------------------
|   home   | 2.98 |
-------------------
|   draw   | 4.1  |
-------------------
|   away   | 2.45 |
-------------------

The usual 1/X/2 arbitrage with the odds 2.98/4.1/2.45 gives
profit 1.252%. Using pk for the home team yields 1.05%
(Hence, in this case, using this type of arbitrage bet did not bring an advantage.)
Risks
Perhaps it is important several risks connected with this types of betting. Many of them are mentioned in the Wikipedia article about arbitrage betting, too. (Here is link to the revision at the time when this answer was posted and to the current revision.)

You have to be careful about the limits you are allowed to stake.
You need to be careful about the bookmarkers rules. For example, in tennis some bookmakers make the stake void if one of players withdraws during the match; some consider the other player the winner. (And some have even more complicated rules depending on number of sets that have already been played.) Similarly in baseball, some bookmakers make the bet void unless the listed pitchers started.
There are bookmakers that have different rules for pk (for example, they return only 90% instead of the whole bet).


Is the maximum function of a continuous function continuous?

Question: Suppose $f(x)$ is continuous on the closed interval $[a,b]$. Define $m(x)=\max_{a\leq s\leq x}\, f(s)$, $a\leq x\leq b$. Is $m(x)$ continuous necessarily? Thank you.
Comment: Yes it is. What are your thoughts?
Comment: Thank you. I know that $m(x)$ is increasing. So it is continuous unless it has jumps around some points. And this is not very possible since $f(x)$ is continuous. But I just do not know how to show this rigorously. Do you have any suggestion?
Answer: Yes it is.
HINT: Clearly $m(s)$ is monotonically non-decreasing on $[a,b]$. Thus, if it is discontinuous at some $x\in[a,b]$, it must have a jump discontinuity at $x$: either $\lim\limits_{s\to x^-}m(s)<m(x)$, or $m(x)<\lim\limits_{s\to x^+}m(s)$.

Suppose first that $\lim\limits_{s\to x^-}m(s)<m(x)$ for some $x\in(a,b]$. Show that $\lim\limits_{s\to x^-}f(s)<f(x)$, contradicting the continuity of $f$.
Then suppose that $m(x)<\lim\limits_{s\to x^+}m(s)$ for some $x\in[a,b)$. Show that $f(x)<\lim\limits_{s\to x^+}f(s)$, again contradicting the continuity of $f$.

Added: Here's a little more help with (1). Let $u=\lim\limits_{s\to x^-}m(s)$. For all $s\in[a,x)$ we have $$f(s)\le m(s)\le u<m(x)=\max\{f(s):a\le s\le x\}\;.$$ In other words, $f(s)\le u$ for every $s\in[a,x)$, but $\max\{f(s):a\le s\le x\}=m(x)>u$; this is possible only if $f(x)=m(x)$. But then $\lim\limits_{s\to x^-}f(s)\le u<f(x)$.
(2) can be dealt with very similarly.
Comment: Thank you. That is a quite rigorous proof. It helps a lot.
Comment: @Knightgu: You're welcome; glad it helps.
Answer: $f$ is uniformly continuous on $[a,b]$. Fix $\varepsilon>0$, choose $\delta$ such that $|f(x)-f(y)|\leq\varepsilon$ when $|x-y|\leq \delta$ and let $x\in [a,b]$. We have to show that $|m(x)-m(x+t)|\leq\varepsilon$ if $|t|\leq \delta$. We have for $t>0$ that
$$m(x+t)=\max_{0\leq s\leq x+t}f(s)=\max\{f(x),\max_{x\leq s\leq x+t}f(s)\},$$
and for $t<0$ that
$$m(x+t)=\max\{f(x-t),\max_{x-t\leq s\leq x}f(s)\}.$$
We have $|f(x)-\max_{x\leq s\leq x+t}f(s)\}|\leq\varepsilon$ when $0<t<\delta$ and $|f(x-t)-\max_{x-t\leq s\leq x}f(s)|<\varepsilon$ when $0>t>-\delta$.
Comment: I wonder if it is the case in your answer that $$m(x+t)=max\{m(x),\,max_{x\leq s\leq x+t}\,f(s)\}$$for t>0. Noting that $f(x)\leq m(x),$ we therefore have $$|m(x+t)-m(x)|\leq max\{0,\,|max_{x\leq t\leq x+t}\,f(s)-f(x)|\}.$$ The case $t<0$ is similar.


Can a football (soccer) league decide to use video review?

Question: As a fan of ice hockey, I've become accustomed to the benefits of video review. The NHL does it right. There is one VAR room where all video reviews are done for the entire league, which leads to a high degree of consistency. The officials do not leave the playing surface or view the video themselves, but when the video review is uncertain the official ruling on the ice stands.
Why is this not done in association football? I suspect that the answer is that the people who make the decisions are, like me, over 60. This leads to my real question. Could an individual league such as the Barclays Premiere League, or MLS in North America, chose to use video review or does FIFA prevent this?
Comment: BPL means *Barclays Premier League* not *British Premier League*, but is commonly known as the EPL (English Premier League). This is important since there are separate English, Scottish, Welsh and Northern Irish league systems in the UK. These teams do not play one another except in "international" competitions, such as the Champions League.
Comment: http://www.mirror.co.uk/sport/football/news/fifa-to-trial-hawkeye-goal-line-technology-846282
Answer: Regarding your first subquestion, why is this not done in association football:  The governing bodies are very much concerned that the game is played at all levels according to the same rules.  Local club football would obviously not be able to use any kind of video review, and therefore the way players and officials approach the game at different levels would be different.  For example, referees might be more or less likely to give certain decisions if they could review them on video, and players might play certain kinds of tackles more or less if they knew that video review could exonerate them.
It is also a concern that this would create more interruptions, but I think that is secondary.
Then, could an individual league do this anyway?  Well, a league can do whatever it wants, really, as long as they comply with certain basics, like sporting codes and anti-doping regulations.  They don't have to follow the official rules 100%.  Major League Soccer, for example, has experimented with numerous rule changes.  Or a league could play the whole game indoor on a smaller field, which of course many in fact do.
But if FIFA or UEFA, say, feel strongly about this, and I think they do, they could sanction anyone who tries by saying, for example, only teams that play without video review can participate in the World Cup or the Champions League.  That would probably convince everyone.  There are many quite benign regulations like that, in fact.  For example, you need to play on natural grass if you want to try to participate in the World Cup.
Comment: "The governing bodies are very much concerned that the game is played at all levels according to the same rules" -- well, that's a rant in itself for any fan. They don't care whether there's the same number of officials at all levels (there aren't), the same requirements on pitch conditions, lighting, etc. They care deeply about things that second-guess the referee, though. One almost suspects that "consistency" is a ruse to keep the tech out, since it's obviously too expensive for minor leagues.
Answer: As time goes by, things change.
Several domestic European leagues have already started using VAR, including the top ones (e.g, Spanish La Liga, German Bundesliga, Italian Serie A and Portuguese Primeira Liga).
FIFA doesn't prevent this at all and actually on the contrary started using it at the 2018 World Cup in Russia, having previously tested it during the 2017 Confederations Cup.
Answer: Well.. it can be use in a non official way. The rules clearly states that no one but the referee can make decisions over the course of the game. He can ask the field assistants about game related issues, but he has the last word about it. Rugby use tech to sort out difficult plays (usually to know if a try is Ok or not). And in that case there is a referee looking at a tv screen that makes the call. But in the case of football, there are still argument that tv review will kill the game.
Yesterday I saw that even Basketball use it (didn't know about it, but happens on SA-Clipper game).
Since football rules are a lot about interpretation of what just has happen (eg: not always touching the ball with the hand is a foul), FIFA is still arguing that it will just cut the game momentum (but in other sports is ok). So since football is a business (IMHO), I think they didn't want to put on problems minor leagues (on poor countries), since if it is mandatory, it will involve a lot of effort. But again, usually not all rules are mandatory, so we will never know the real reason.
The use of mark on the field (using a spray can with foam) was first tested on the second division of the argentina league, for about two years. Now is used in all america, But I don't remember if it is used anywhere else. Every rule is tested for a long long time.
I will look for the newspaper article, But I readed that they will test the goal cam on some upcoming matches. (the rules are usually tested on young players championships).


A differentiation under the integral sign

Question: Let $f:\mathbb{R}^n\to\mathbb{R}$ be a function Lebesgue summable on all $\mu$-measurable and bounded subsets of $\mathbb{R}^n$, where $\mu$ is the usual Lebesgue measure defined on $\mathbb{R}^n$, and let $g:\mathbb{R}^n\to\mathbb{R}$ be a function of class $C^k(\mathbb{R}^n)$ whose support is contained in the compact subset $V\subset\mathbb{R}^n$. That implies that all the derivatives of $g$, up to the $k$-th, are bounded and supported within $V$.
I suspect that these conditions are enough to guarantee that the function $$h(\boldsymbol{x}):=\int_V f(\boldsymbol{y}-\boldsymbol{x})g(\boldsymbol{y})\,d\mu_{\boldsymbol{y}}$$is of class $C^k(\mathbb{R}^n)$. In fact, I notice, if I am not wrong, that $$h(\boldsymbol{x})=\int_{V-\boldsymbol{x}} f(\boldsymbol{y})\bar{g}(\boldsymbol{y}+\boldsymbol{x})\,d\mu_{\boldsymbol{y}}=\int_{\mathbb{R}^n} f(\boldsymbol{y})\bar{g}(\boldsymbol{y}+\boldsymbol{x})\,d\mu_{\boldsymbol{y}}$$where $$\bar{g}(\boldsymbol{y}) := \begin{cases} g(\boldsymbol{y}), & \boldsymbol{y}\in V \\ 0, & \boldsymbol{y}\in\mathbb{R}^n\setminus V \end{cases}$$and $V-\boldsymbol{x}=\{\boldsymbol{y}\in\mathbb{R}^n:\boldsymbol{y}+\boldsymbol{x}\in V\}$, and I suppose that the conditions on $g$ may be enough to allow us to differentiate under the integral sign.
Is my intuition that $h\in C^k(\mathbb{R}^n)$ correct and, if it is, how can we prove it?

A trial of mine: I know a corollary of Lebesgue's dominated convergence theorem that
- if $f:V\times [a,b]\to \mathbb{R}$, $(\boldsymbol{x},t)\mapsto f(\boldsymbol{x},t)$ with $V$ measurable is such that $\forall t\in[a,b]\quad f(-,t)\in L^1(V)$, i.e. the function $\boldsymbol{x}\mapsto  f(\boldsymbol{x},t) $ is Lebesgue summable on $V$,
- and if there is a neighbourhood $B(t_0,\delta)$ of $t_0$ such that, for almost all $\boldsymbol{x}\in V$ and for all $t\in B(t_0,\delta)$, $\left|\frac{\partial f(\boldsymbol{x},t)}{\partial t}\right|\le\varphi(\boldsymbol{x})$, where $\varphi\in L^1(V) $, then
$$\frac{d}{dt}\int_V f(\boldsymbol{x},t) d\mu_{\boldsymbol{x}}\bigg|_{t=t_0}=\int_V\frac{\partial f(\boldsymbol{x},t_0)}{\partial t}d\mu_{\boldsymbol{x}}$$but I am not able to find a proper $\varphi$ to use in this context. Nevertheless I would not be amazed if there were an even more straightforward method to prove that the integral and derivative sign can be commutated...
Comment: As written, the premises don't really make sense. First you write $f\colon \mathbb{R}^n \to \mathbb{R}$, then afterwards you say $f$ is defined (and integrable) on $V$. I suspect the intended premise is that $f$ is _locally integrable_, that is, the restriction of $f$ to every bounded Lebesgue-measurable $V\subset \mathbb{R}^n$ belongs to $L^1(V)$. Is that correct?
Comment: If you only assume that $f$ is summable on a specific $V$, then you can't even be sure that $h(x)$ is defined for any $x\neq 0$. To be sure that $h$ is defined on all of $\mathbb{R}^n$, you need local integrability. (That is, $f$ should be integrable over every _bounded_ measurable subset of $\mathbb{R}^n$, or, equivalently one can say that $f$ should be integrable over every _compact_ subset of $\mathbb{R}^n$.) If you assume that $f$ is locally integrable, everything works out nicely.
Answer: Your intuition is correct, if $f\colon \mathbb{R}^n \to \mathbb{R}$ is locally integrable, and if $g \in C_c^k(\mathbb{R}^n)$, then the function $h$ given by
$$h(x) = \int_{\mathbb{R}^n} f(y-x)g(y)\,d\mu_y$$
belongs to $C^k(\mathbb{R}^n)$, and its partial derivatives of order $\leqslant k$ are given by
$$D^{\alpha} h(x) = \int_{\mathbb{R}^n} f(y-x)D^{\alpha} g(y)\,d\mu_y.$$
The change of coordinates $z = y-x$ gives us
$$h(x) = \int_{\mathbb{R}^n} f(z)g(z+x)\,d\mu_z,\tag{$\ast$}$$
and in that form we can apply the dominated convergence theorem to justify differentiation under the integral.
We let $K := \operatorname{supp} g$, and define $L = \{x \in \mathbb{R}^n : \operatorname{dist}(x,K) \leqslant 1\}$. Then $L$ is also compact, hence of finite Lebesgue measure. Now we fix an arbitrary $x_0 \in \mathbb{R}$ and show that $h$ is continuously differentiable on $B_1(x_0)$. The integrand in $(\ast)$ is only nonzero for $z$ such that $z+x \in K$, and rearranging gives $z \in K + (x_0 - x) - x_0$. Since we only look at $x$ with $\lVert x-x_0\rVert < 1$, we have $K + (x_0 - x) \subseteq L$, so
$$f(z)g(z+x) \neq 0 \implies z \in L - x_0$$
for $x\in B_1(x_0)$. As a continuous function with compact support, $g$ is bounded, say $\lvert g(y)\rvert \leqslant M$ for all $y$. Then we have
$$\lvert f(z)g(z+x)\rvert \leqslant M\cdot \lvert f(z)\rvert \cdot \chi_{L - x_0}(z)$$
for all $z \in \mathbb{R}^n$, and choosing $d(z) := M\cdot \lvert f(z)\rvert \cdot \chi_{L - x_0}(z)$ as the dominating function yields the continuity of $h$ on $B_1(x_0)$. If $k \geqslant 1$, then the partial derivatives of $g$ are all continuous functions with compact support, and hence bounded. We may assume that $\lvert \partial_{i}g(y)\rvert \leqslant M$ for all $y\in \mathbb{R}^n$ and $1 \leqslant i \leqslant n$. Then $d$ is also a dominating function for
$$f(z)\partial_i g(z+x),$$
and another application of the dominated convergence theorem - repsectively of the mentioned corollary - yields the continuous partial differentiability of $h$ on $B_1(x_0)$, and the formula
$$ \frac{\partial h}{\partial x_i} (x) = \int_{\mathbb{R}^n} f(z) \partial_i g(z+x)\,d\mu_z.$$
If $k > 1$, we can iterate the argument to obtain the existence and continuity of the higher-order partial derivatives of $h$ on $B_1(x_0)$. Since $x_0$ was arbitrary, it follows that $h \in C^k(\mathbb{R}^n)$.
Comment: Substituting $z = x-y$, we get $$h(x) = \int_{\mathbb{R}^n} f(z) g(x-z, t - \alpha \lVert z\rVert)\,d\mu_z,$$ and under appropriate conditions, we can differentiate under the integral (and then substitute back).
Comment: Yes. Assuming of course that $f$ is locally integrable.
Comment: Very clear and explicative answer, as yours always are. I also see, by substituting $f$ with $z\mapsto f(-z)$ that $$D_x^\alpha\int_{\mathbb{R}^n}f(x-y)g(y)d\mu_y=\int_{\mathbb{R}^n}f(x-y)D_{y}^{\alpha}  g(y)d\mu_y$$also holds, which is a result that I think to be useful in the theory of convolution... Thank you so much!
Comment: Forgive me if I'm bothering you: does something analogous hold with $h(x):=\int_{\mathbb{R}^n}f(x-y)g(y,t-\alpha\|x-y\|)d\mu_y$ and opportune assumptions on $g$, for ex. $g\in C_c^k(\mathbb{R}^{n+1})$ and? I ask this question because I'm trying to prove to myself that the Laplacian of the electric retarded potential $V(x,t):=\frac{1}{4\pi\varepsilon_0}\int_{\mathbb{R}^n} \frac{g(y,t-c^{-1}\|x-y\|)}{\|x-y\|}d\mu_y$ satsfies the Lorenz gauge condition. I heartily thank you!
Comment: Thank you very much! Well, I would say that (I use $D^\alpha$ for the derivatives w.r.t. $\tau$, too), if (1) $g\in C^k(\mathbb{R}^{n+1})$, $(\xi,\tau)\mapsto g(\xi,\tau)$; (2) there is a compact set $K\subset\mathbb{R}^n$ such that $\forall\tau\in\mathbb{R}$ the support of $\xi\mapsto D^\alpha g(\xi,\tau)$ is contained in $K$; (3) $\exists M>0:\forall(\xi,\tau)\in\mathbb{R}^{n+1}\quad|D^\alpha g(\xi,\tau)|\le M$ (these three conditions are met if $g\in C_c^k(\mathbb{R}^{n+1})$) ...
Comment: ...  then $D^\alpha_{(x,t)} h(x,t)=D^\alpha_{(x,t)}\int_{\mathbb{R}^n}f(y-x)g(y,t-c\|x-y\|)d\mu_y$ $=\int_{\mathbb{R}^n}f(y-x)D^\alpha_{(\xi,\tau)} g(y,t-c\|x-y\|)d\mu_y$. And that also holds with $f(x-y)$. Am I right? I $\aleph_0$-ly thank you!


Is there a word for the motif of linearly-tumbling & surging little bundles of notes? (E.g., "FEDC-FEDC-BCDEF")

Question: For example, Cerulean's Flight (from the start and throughout):

I've found this to be one of the most common attributes of my favourite music. In my notes I've had to knowingly-misuse the terms "chromaticism" (for the motif's colourful image) and "glissando" (for its directionality) and it would be great to clear up that problem.
Edit: To be clear, it's not necessarily a melody using only the smallest stepwise motions through a scale. It can leap, reset and switch directions. I think leaps help, actually. Juicy little segments running upward and downward are what cause this distinct colourful effect, so a word ought to encompass that boundary somewhat precisely. I think the effect is powerful enough to deserve some formal term.
In the meantime, I've come up with the term helicism (from helix) to describe the kind of smooth-but-twisting linearity I mean. Feel free to steal it.
Comment: I think this might be OT here, but do you perhaps mean the term *ostinato*?
Comment: @Lazy why would a question about a compositional technique be off topic?
Comment: @Lazy It definitely overlaps with *ostinato* to some degree. But some examples of ostinato use more convoluted repeating units (from the start: https://youtu.be/aQzigNXsom0). I'm thinking more of a chopped up (and possibly slowed) kind of micro-glissando, all within the scale, holding its direction until the end of each repeating unit (assuming the tumbling & surging units even repeat at all).
Answer: It seems like you're hoping for a name for this phenomenon—a noun. I don't know of one, but there's an adjective that might help: scalar (also stepwise motion). When we talk about the way we move from note to note, "scalar" or "stepwise" means we're moving from one note to the neighboring one above or below, while "intervallic" means we're skipping notes to leap to another one. I might say that the melody of "Twinkle Twinkle Little Star" is highly scalar—aside from a couple of fifths, it's all stepwise motion. In contrast, I might say that the USA's national anthem is more intervallic: In the first phrase, it moves intervallically 12 times, and stepwise only 10 times. (Note: for some reason, I might say that a melody "is scalar," as a quality, but not "is stepwise"; if we use stepwise it's usually paired with motion.)
Now, I wrote all that before listening to the video. Given your description in the text (fedc-fedc) I might imagine describe a passage with words like "the melody is characterized by short scalar fragments." However, the video is an interesting situation: The first few notes are intervallic, an arpeggio. They then start to get "filled in" with neighbor-notes. The "chunks" still often contain or start with a leap. In fact, the overall effect emphasizes the disconnectedness of the chunks; as a whole, the line is fragmented. I wouldn't describe it as scalar overall. Maybe I'd use a phrase like "the synth line, in an unbroken stream of equal durations, varies the intervallic direction in a quasi-random way that fragments the line into disparate chunks of nearby notes."
Sometimes there's no good one word for something; you just have to describe it.
Comment: @Theodore I like better the definition from wikipedia: "a virtuoso piece of music typically for a keyboard or plucked string instrument featuring fast-moving, lightly fingered or otherwise virtuosic passages or sections, with or without imitative or fugal interludes, generally emphasizing the dexterity of the performer's fingers." *Toccata* means "touch," after all. (Does it count if it's programmed?...)
Comment: My aging copy of *The Clark New Pocket Music Dictionary* defines **toccata** as "…a piece with a flowing movement of notes of equal value…", but I can't find any other source giving a similar definition.
Comment: *Scalar* has some potential, because although it seems to technically mean *stepwise* or *conjunct*, some descriptions of it seem to allow for slight leaps (which is what I want). It would be nice to have a simple Italian term to describe the piece or movement. *Fiume* for "river" or "stream". For my notes I think I'll use the neologism *helicism* (of or related to a *helix*) for the kind of smooth-but-segmented effect I mean to describe.
Answer: I haven't heard of a particular term, but two related terms may be helpful.
To me, this technique is a nod to the minimalist style. And Philip Glass, one of the most famous minimalist composers, has described minimalism as "music with repetitive structures." If "repetitive structures" is good enough for him, it may well be good enough for your purposes.
Slightly outside of minimalism, the composer György Ligeti used what the music theorist Miguel Roig-Francolí calls "net-structures." In his book Understanding Post-Tonal Music, Roig-Francolí says that a

net-structure is a continuous web of finely woven lines or repeated patterns in a constant, interactive process of transformation. (292)

I'm not sure your example has this process of transformation, nor do I think it's "finely woven" in the sense that Ligeti's music often is (often with faster note values; a related term is "micropolyphony," which I think is suggestive). Nevertheless, the process is certainly related.
Answer:
Edit: To be clear, it's not necessarily a melody using only the smallest stepwise motions through a scale.

By my reading this contradicts what you describe in the title. Your "edit" note and continuing description make things unclear, because nearly all music will involve lines that go up and down in short conjunct segments along with some leaps.
It's hard to know what you mean, because your not really describing in musical terms what in the music you're focused on. The extra words like 'tumbling, surging, juicy' don't help either, not until those words are connected to the musical devices that produce those feelings.
The step-wise motion you describe in the title would be called conjunct motion. Disjunct motion is moving by leaps. Both of those terms are generic and don't get into things like rhythm, length of the passage, or tempo.
Conjunct motion of short duration, like 1 beat, might be called various turns, and German has many specific turn names based on the contour of the turn. There is another German term, fortspinnung, for stringing together short turns and other motifs. It's associated with German Baroque music.
Those are the terms that came to mind immediately upon reading the title of your question.
When I listen to the recording example all of that goes out the window and I immediately thought: minimalism. When the track continues to the electronic dance music beat it isn't really minimalism, but the first 10 seconds sound very similar to stuff like Steve Reich's Piano Phase.
Phase and phase shifting seem like terms to apply. The idea is to take a fairly simply motif, repeat over and over and over in more than one part, phase (or time) shift the two parts slightly to create a composite line which has new melodic features. Things like dissonant seconds create rhythmic accents, or you can start to hear repeated pitches, things that aren't in the original motif played alone. Minimalist music achieve the phase shift in actual performance, the players would sort of go out of sync rhythmically. Your sample track does something similar, but it's using some kind of electronic delay.
In your example, it's hard for me to aurally separate what actually was played (probably on a keyboard) from what was generated by delay. I don't know if that matters to you, but personally I want to separate what was played from what any effect settings were, because I would want to know how to do it. That might have some bearing on terms to describe it.
One thing I hear is a polyrhythm effect. Polyrhythm is playing two "conflicting" rhythms simultaneously like groups of 3 against a base of 4. The performance versus effect question comes up hear, because I can't tell if that is played or just the result of the delay. Regardless, polyrhythm may be a term to apply. It diffuses the sense of meter, and with out the solid feel of a well established meter, this might account for what you hear as "tumbling/surging." Also, when meter/rhythm are diffused it lends for a lot of repetition, because it's harder to aurally identify the repeating pattern.
You probably want to not describe with as chromaticism, because this stuff sounds very diatonic. In fact if you do this phase shift, delay on actual chromatic motifs, it will likely create unpleasant dissonance. Harmonically this stuff isn't that exotic. In modern styles harmony pretty much extends to playing nearly all diatonic tones together. A diatonic thirteenth chord without the eleventh is pretty normal provided certain voice spacing and inversion aspects are handle right. A strong, clear bass part - which this example track has - with nearly any combination of diatonic tones in the upper range/voices can work well. I don't mean the upper parts are haphazard, we can't discuss everything in a Q&A, but you can generally say the upper parts can enjoy much more freedom that the bass. You might say there is a kind of board interchangeable tolerance of tones in the upper parts. I think that free treatment and tolerance of dissonance, when confined to a diatonic palette, in the upper parts contributes to the "twisting" and "colorful" sense of the music.


Given $a$ in $\gcd(a,b)$ with $a > b > 0$, how can I find $b$ which give the maximum number of steps for the Euclidean algorithm?

Question: Given $a$, where $a$ and $b$ are positive integers with $a > b$, how can I find the values for $b$ which give the maximum number of steps for the Euclidean algorithm $\gcd(a,b)$?
For example, where $a = 1000, b = 703$ and $b = 633$ both give the maximum number of steps:
$$(1000,703) → (703,297) → (297,109) → (109,79) → (79,30) → (30,19) → (19,11) → (11,8) → (8,3) → (3,2) → (2,1)$$
$$(1000,633) → (633,367) → (367,266) → (266,101) → (101,64) → (64,37) → (37,27) → (27,10) → (10,7) → (7,3) → (3,1)$$
If $a$ is the Fibonacci number $F_n$, then $b= F_{n-1}$ gives the maximum number of steps, but I'm looking for a method that works for any $a$.
Thanks.
Update: C code to list all b which take max steps
I've been using the following code to iterate through all possible b and display those which take the max number of steps. However, I was hoping there might be some way to calculate solutions or narrow the range.
<code>#include <stdio.h>

/* count number of steps for Euclidean algorithm */

int gcd_steps(int a, int b)
{
    return !a ? 0 : 1 + gcd_steps( b % a, a );
}

/* for each A (1-50), display the maximum number of steps for the
   Euclidean algorithm and list all B which take the max steps */

void main()
{
    int a, b, max_steps;
    for ( a=1; a<=50; a++ )
    {
        max_steps = 0;
        for ( b=1; b<a; b++ )
            if ( gcd_steps( b,a ) > max_steps )
                max_steps = gcd_steps( b, a );
        printf( "%i [%i] ",a , max_steps );
        for ( b=1; b<a; b++ )
            if ( gcd_steps( b, a ) == max_steps )
                printf( "%i,",b );
        printf( "\n" );
    }
}
</code>
Comment: https://oeis.org/A034883 is relevant.
Comment: @GerryMyerson thank you, yes.  I've read through A034883 and some related sequences, but I haven't found any method apart from iterating though all possible *b*.  I was hoping there might be some way to calculate solutions or narrow the range.
Comment: Let's look at $a=997$, where the maximum number of steps is $12$. There are $996$ values of $b$ to check, and only $12$ different possible lengths, so on average there are $83$ values of $b$ for each length. I don't know how many values of $b$ actually give length $12$, but this calculation suggests there might be lots of them. I think that's one of the difficulties; if there were always only one or two values of $b$ maximizing length, there'd be a hope there was some formula to find them. But if there are $80$ different $b$ that work, then I don't see any improvement on exhaustive search.
Comment: For *a* = 997, there are two values of *b* which give the max number of steps, 616 and 717.  Of the *a* 1-1000, there are 63 where only one *b* gives the max number of steps and 455 where there are two values of *b* which give the max.  Note ( 616 * 717 ) % 997 = 1.  Of those 455 *a* which have two *b* with the max steps, 430 have ( *b₁* * *b₂* ) % *a* = ±1.
Comment: It's no surprise that $b_1b_2\equiv\pm1\bmod a$ very often when $b_1$ and $b_2$ have the same number of steps, as the continued fractions of $b_1/a$ and $b_2/a$ are very closely related when $b_1b_2\equiv\pm1\bmod a$. It is a surprise to me that for $a=997$ there are only two values of $b$ that give the maximum number of steps.
Comment: Have you looked at that link?
Answer: Comment:
Suppose number of steps or the length is $l$, we have:
$a-kb=d_1$
$b-k_1d_1=d_2$
$d_1-k_2d_2=d_3$
.
.
.
$d_{l-2}-d_{l-1}=d_l$

$a-(k-1)b-d_l=\sum^l_{i=1}l_id_i \space\space\space\space\space\space\space\space\space(1)$
Also we know that if $(a, b)=c$ , then we have an equation like:
$ma-nb=c\space\space\space\space\space\space\space\space\space(2)$
So we have to maximise $l$ in following system of equations:
$\begin{cases}a-(k-1)b-d_l=\sum^l_{i=1}l_id_i\\ma-nb=c\end{cases}$
We can let $l$ and $c$ as knowns of system. For estimating $l$ and $b$ we may use following method:
In your example we have:
$m\times 1000- 703\times633=1$
which gives $m=445$ and $n=703$ or $n=633$, such that:
$445\times 1000-703\times 633=1$
we can use this property for estimation of other numbers. For example we want to find $b$ for number $a=4277$. We may write:
$4277/1000=4.277$
We use this as proportion factor:
$b= 4.277\times633=2707.341$
Take for example $b=2707$ which is prime, so $c=1$:
$(4277, 2707)=1$, also number of steps or length is $l=10$
Also $m=1788$and $n=2825$, such that:
$1788\times 4277-2825\times 2707=1$
$(4277, 2825)=1$, also number of steps or the length is $l=10$
We do not know $l=10$ is maximum, but we can check few numbers as a range it's mean is $2825$
or $2707$.
We can also try $b= 4.227\times 703=3006.731$,  take for example $b=3001$ which is prime and gives:
$1437\times 4277-2048\times 3001=1$
$(4277, 3001)=1$ and $l=6$
also:
$(4277, 2048)=1$ and $l=6$
and conclude that numbers $2875$ and $2707$ are more reasonable for our task.
Comment: Thank you, I'll go through your answer in detail and run some tests.


Executar arquivos Python, usando o python

Question: Existe alguma forma de executar um arquivo x em Python usando um arquivo y em Python, por meio de códigos Python?
Answer: sim, isso é inerente em linguagens de programação.
A forma "certa" é importar o arquivo x.py como um módulo.
veja:
x.py
print('olá do modulo X')

def main():
    print('olá da função principal "x.main()"')

if __name__ == '__main__':
    main()

y.py
import x
# >>> 'olá do modulo X
x.main()
# >>> olá da função principal "x.main()"

Alternativamente é possível rodar arquivos .py como um processo separado, usando o o interpretador Python, para isso, use o modulo subprocess:
y.py
import subprocess

subprocess.run("python x.py", shell=True)
# >>> olá do modulo X
# >>> olá da função principal "x.main()"

para ver mais:
https://docs.python.org/pt-br/3/tutorial/modules.html
https://docs.python.org/3/library/subprocess.html
Comment: Obrigado!!! Deu certo


How rendering routes from when the nav section is in a other Component ?

Question: My website is split into two component, a "Side" component that displays a nav menu and a "View" with a "Menu" component that display the a specific component depends on nav button you click on.
The problem is that the component never rendering.
My Menu Component :
import React from 'react';
import { BrowserRouter as Router, Link, BrowserRouter } from 'react-
router-dom';
import './Menu.css'

class Menu extends React.Component{
    render(){
        return (

                <Router>

chevron_left

                            <Link to="/work" className="nav-title">
                                equalizer
                            </Link>

                            <Link to="/work" className="nav-title">
                                work
                            </Link>

                            <Link to="/education" className="nav-title">
                                library_books
                            </Link>

                        {/*
equalizer
 */}

chevron_right

                </Router>

    )
}
}

 export default Menu;

My Side component :
import React from 'react';
import { BrowserRouter as Router, Route, Link, Switch } from 'react-
router-dom'
import './View.css'

import Work from '../Work/Work'
import Skills from '../Skills/Skills'
import Education from '../Education/Education'

class View extends React.Component{
     render(){
    return (
        <Router>

                <Switch>
                    <Route path='/work' component={Work} />
                    <Route path='/skills' component={Skills} />
                    <Route path='/education' component={Education} />
                </Switch>

        </Router>
    )
}
}

export default View;

Do you have a solution to solve this ?
Answer: So <Route/> and <Link/> components need to be children of the same <Router/> component. Move your <Router/> component up into a common ancestor of the both the view and sidebar components and remove the <Router /> component from both the view and sidebar components.
If you're using redux you will need to wrap the component that has your <Route/> components with the withRouter HoC.
Edit: Here is a example code sandbox to show you how this works. Click on the about and home links on the side to see the components change.
Comment: Thanks :) That's work, but with this solution my component will be render in the ancestor, not in my view component.
Comment: Put the `` components in the view component, and they will render in the view component. The `` will be rendered wherever they are located. The `` is what needs to be in the common ancestor of the routes and links.
Comment: I have : You should not use  or withRouter() outside a
I put the Route Component in the View Component, and import the View component in the App Component (where i put the router) https://gist.github.com/TonyGorez/e1650cb7e669337ee70ea5e7ea7394f9


How do I solve for $x$ in $\ln(x)\ln(x) = 2 +\ln(x)$

Question: How do I solve for $x$?
$$\ln(x)\ln(x) = 2 +\ln(x)$$
Comment: This is just a quadratic in $\ln x$. Nothin' tricky.
Comment: I think of it like that too now :)
Comment: Just a quick tip: you now have enough reputation that you can "upvote" as many helpful answers as you'd like, even those you accept. To "upvote", click on the upward-pointing arrow to the left of the answer: when you click, it turns *red*.
Answer: HINT:
Putting $\ln (x)=y,$ we get
$$y^2-y-2=0.$$
Do you know how to solve a Quadratic Equation?, and we know that
$$\ln (x)=a\iff x=e^a .$$
Comment: edit: ln(x) = -1 doesn't fail, gets us x = 1/e
Comment: So I would get:

y^2 -y -2 = 0
then
(y-2)(y+1)=0
then
ln(x)=2 v ln(x)=-1 (fails)
then
x = e^2

Right?
Comment: @Jones, you got the answer. $\ln(x)$ can assume any real value but as $e^a>0$ for real $a$ and $x$ must be $>0$
Answer: $$\ln(x)\ln(x) = 2 + \ln(x) \iff (\ln (x))^2 - \ln (x) - 2 = 0\tag{1}$$
Let $t = \ln x$. Then $(1)$ becomes $$t^2 - t - 2 = (t - 2)(t + 1) = 0\tag{2}$$
So, $$t = \ln x = 2 \implies x = e^2\;\text{ or }\; t = \ln x = -1 \implies x = e^{-1} = \frac 1e$$
Comment: Good morning! Off to the gym. Needs another TU +1


Extract values from Json code using Python

Question: I'm trying to extract the values from the following json code in this format by displaying each device in a different row. Any ideas on how to do it? Thanks in advance
device1 : 232323 Completed
device2 : 345848 Completed etc

I tried the below which gives me the following output:
[{'cid': 631084346, 'data': [[{'text': 'device1'}], [{'text': '732536:Completed.'}], [{'text': '1'}]], 'id': 1750501182}, {'cid': 1891684718, 'data': [[{'text': 'device2'}], [{'text': '732536:Completed.'}], [{'text': '1'}]], 'id': 2218910703}

api_readable = api_response.json()
    computer_name = str(api_readable['data']['result_sets'][0]['rows'])
   # computer_name = re.sub("[{},':]", "", computer_name)
    print(computer_name)

Sample Json used
{
    "data": {
        "max_available_age": "",
        "now": "2020/01/09 22:43:58 GMT-0000",
        "result_sets": [{
            "age": 0,
            "archived_question_id": 0,
            "columns": [{
                    "hash": 3409330187,
                    "name": "Computer Name",
                    "type": 1
                },
                {
                    "hash": 1792443391,
                    "name": "Action Statuses",
                    "type": 1
                },
                {
                    "hash": 0,
                    "name": "Count",
                    "type": 3
                }
            ],
            "error_count": 0,
            "estimated_total": 129,
            "expire_seconds": 3660,
            "filtered_row_count": 11,
            "filtered_row_count_machines": 11,
            "id": 2880628,
            "issue_seconds": 0,
            "item_count": 11,
            "mr_passed": 129,
            "mr_tested": 129,
            "no_results_count": 0,
            "passed": 128,
            "question_id": 2880628,
            "report_count": 233,
            "row_count": 11,
            "row_count_machines": 11,
            "rows": [{
                        "cid": 631084346,
                        "data": [
                            [{
                                "text": "device1"
                            }],
                            [{
                                "text": "732536:Completed."
                            }],
                            [{
                                "text": "1"
                            }]
                        ],
                        "id": 1750501182
                    },
                    {
                        "cid": 1891684718,
                        "data": [
                            [{
                                "text": "device2"
                            }],
                            [{
                                "text": "732536:Completed."
                            }],
                            [{
                                "text": "1"
                            }]
                        ],
                        "id": 2218910703
                    }

Comment: https://docs.python.org/3/library/json.html + the proposed duplicate.
Comment: @tevemadar How would it? They have *already* parsed their JSON and their question has nothing to do with JSON.
Comment: @StefanPochmann You can be right, but I do not see actual parsing, and I see a commented regexp.
Comment: @tevemadar It's clearly already parsed and in the `api_readable` variable.
Answer: api_readable['data']['result_sets'][0]['rows'] is a list, you can simply loop over it and print the items you want.
for row in api_readable['data']['result_sets'][0]['rows']:
    print(f"{row['data'][0][0]['text']} : {row['data'][1][0]['text']}");

Comment: It doesn't seem to work I get this error now :
Comment: print(f"{row['data'][0]['text']} : {row['data'][1]['text']}");
TypeError: list indices must be integers or slices, not str
Comment: For some reason, each dictionary in `data` is nested in an extra list with just one element. I've added the extra indexing.


Proof that every group of order 847 is abelian.

Question: How would I use Sylow's theorems to prove that any group of order 847 is abelian?  I know that every group of prime order is cyclic, and thus, abelian.  However, $847 = 7*11*11$, thus, is not a prime number.
Comment: If I'm not mistaken, both Sylow subgroups are normal. That makes this an easy one.
Comment: Are Sylow subgroups normal in general?
Comment: If they were always normal the Sylow theorems would be a lot less useful.
Answer: Let $n_p$ denote the number of $p$-Sylow subgroups of $G$. We are interested in $n_7$ and $n_{11}$. We know that

$n_7\mid 121$, $n_7\equiv 1\pmod{7}$
$n_{11}\mid 7$, $n_{11}\equiv 1\pmod{11}$

It follows that $n_7=n_{11}=1$, can you see why? If $A$ is the $7$-Sylow subgroup and $B$ is the $11$-Sylow subgroup, we have $G\cong A\times B$.
Can you finish?
Comment: Oh, I see.  Every finite abelian group is the product of cyclic groups.  Also, a group is cyclic if it is of prime order.  So we must show that $G\cong A\times B$, where $A$ and $B$ are subgroups of $G$ by using the internal direct product.  In order to use the internal direct product $A \cap B = \{ e \}$, $A$ and $B$ must be abelian with respect to each other, and $AB = G$.  $A$ can be a Sylow 7-subgroup and $B$ can be a Sylow 11-subgroup.  Since each element in $A$ is some power of $7$ and each element of $B$ is some power of $11$ then $A \cap B = {e}$.  How would I show that $AB = G$?
Comment: Also,  how would I show that $A$ and $B$ are abelian with respect to each other?
Comment: @PiccolMan It's a general result that if all Sylow subgroups are normal then the group is the direct product of them. Now $A$ is clearly abelian; what about $B$?
Comment: I know that every group of order $p^{2}$ is abelian, but I don't know why.  $|B| = 11^{2}$, thus, $B$ is abelian. But why is this true?
Comment: @PiccolMan Well, $B\cong G/A$.
Comment: How do you know that A and B are normal?
Comment: @PiccolMan The conjugate of a $p$-Sylow subgroup is a $p$-Sylow subgroup; if there's only one, it's self-conjugate, hence normal.