Any tips on writing the structure of a song for a band which does not read music?

Question: I am starting to play some pre-written songs with a band. These are written by the vocalist and we are trying to make a demo out of them. We (as a band) are having a hard time trying to remember he structures/orders of the songs, in the sense that which section comes after the other. Does the bridge come after the 3rd chorus or is it the solo? Things like these. I did come across the AABA, ABAB etc forms of music but somehow the drummer seems to not get it and play completely different parts and be confused about it.
Do you have any tips on how I can write this down effectively especially for drums and for people who don't read music?
Thanks
Comment: In addition to developing a language to write down and discuss structure, a rough "demo" recording of the songs that the band members can listen to in between practices can be very helpful. Also recording songs during practice so there's a record of changes made as the song develops is a big help.
Comment: How does the vocalist work when composing?  Do they play an instrument to accompany the vocal? Can they record a simple demo with just that instrument and voice, using a mobile phone or similar?
Comment: Teach them how to read [TAB](https://en.wikipedia.org/wiki/Tablature).
Answer: Rather than AABA, why not write "Verse Verse Chorus Verse"?  Or even more descriptive, you could write "Verse (16 bars)  Verse (16 bars) Chorus (24 bars) ..."
Try that first. There are various other forms of simplified notation, such as lead sheets and Nashville number sheets, but if your drummer can't understand "Verse Verse Chorus Verse" then fire the drummer I would try an approach that doesn't use writing.
Can you find or make a rough demo recording of how the song should go, by any means? It doesn't really matter how you put it together. MIDI instruments or recordings of your rehearsals will work. If you have to, you can even record the songs in pieces and then stitch all the parts together later on your computer. Then have your drummer listen to the demos on their own time, play along to them, and memorize how the songs go.
Comment: Definitely "fire the drummer" if he literally can't remember "verse chorus verse chorus solo verse chorus". Everyone makes mistakes, but this level of incompetence indicates he literally isn't ready to play in public. Or it's up to the rest of you whether you want to carry him and train him up until he learns.
Comment: The rough demo is a good idea. Not just for practicing along with, but for listening to and internalizing the song so the players will feel where the changes are while they play the song. Of course they will also have to listen to the song while you all play it, and that might be a bigger challenge to overcome.
Answer: Try using colloquial labels.
It can be easier to remember "That na-na-na part" or "The cool guitar riff part" than "The B section". The label is more direct to the music itself, with no need to map the words "verse" or "A section" to a musical idea. The musical idea is expressed directly. Compared to "AABA" or "Verse Verse Chorus Verse", it's less concise and efficient, but it gets the job done. Meanwhile, anyone in the band who doesn't understand the musical terminology can be learning it.
The band would have to agree upon the second names, but a "score" would look something like:

intro
singer starts
intense section
repeat intro 3x
second vocal section
bass solo
outro

I've used this successfully with bands and students as an interim, intuitive method while they learn the more conventional ways.

Note: One can also split the difference:

intro
[verse] singer starts
[chorus] intense section
repeat intro 3x
[verse] second vocal section
[chorus] bass solo
outro

That provides an assist to those who need it while they learn the more standard labels.
Comment: Add to this a discussion of what counts as "one time around" versus "two times around"  and this is pretty much exactly how we've discussed things in bands I've been in. As in, "so it's going to be the metal riff three times around and then the transition to the bridge with the funk jam six times around before the singer comes back in". I've found white boards up in the practice space are helpful for putting notes up that everyone can refer to when running down something newish.
Answer: Notate it anyway.   Lay out the page so as to make the sections clear, and label them.  Indicate the lyrics.  Those who 'don't read music' will realise they read more than they imagine!  Show them other useful details in the notation, like stops.
If anyone really takes a stand against 'reading' (funny how some players do) make a rough demo recording.
Answer: What your band might appreciate is not full-on sheet music, but lead sheets with only the lyrics and the chords.  You seldom need to notate where measures start and end; a few times through the song following along with the lyrics and chords and everyone ought to have it down.
Wildwood Flower

C                              G           C
I will twine, I will mingle my raven black hair

                              G         C
With the roses so red and the lilies so fair

                                 F       C
And the myrtle so bright with an emerald hue

                             G         C
And the the pale emanita and hyssop so blue.

If additional verses have the same chord structure, you can choose to omit the chords from them and list the words only, but it's usually better to not optimize for space.  It's easier to just be able to play through from beginning to end, especially if you're using the lead sheet to learn the song and not as a reminder of how it goes.
Be sure to format these with a fixed pitch font so that the chord symbols line up with the words.
American folk music is commonly notated like this; you will find many examples of it on the internet.  The idea isn't that the lead sheet is enough to learn the song.  The idea is that the lead sheet plus playing with someone who knows the song, or hearing a recording of it, is enough.
When writing a lead sheet for a band, you can notate where the breaks and intros go:
Intro

Verse

(Words and chords)

Guitar break

Verse

(Words and chords)

People should be able to hear and see where the breaks begin and end without having to count measures, they should be listening to each other and watching each other for nods and other cues.
Comment: In my experience, a chord sheet as per your first example is very much the 'standard' for this use case... +1
Comment: Why, oh why, oh *why* can't people who write lead sheets **USE BARLINES**???  IME, unless you already know the tune well, they're pretty darn useless…
Comment: @gidds I see barlines used most often on intros and musical breaks, they can be really helpful there.
Answer: Doubtful if your drummer can count up to 16. Not being disrespectful - but when I drum, I'm not counting bars either. However, he really ought to be able to, and actually do, the counting, as that's going to be his salvation. Or like so many bands, play each song the number of times it takes before it gets into his memory. Surely that's what he's done with all the other songs the band plays?
I suppose the other way is to get a big board with all the words, and colour certain parts , like verses red, choruses blue, so he just reads through the whole song, top to bottom. Or consider getting a better drummer?
Answer: Use post-its or a digital equivalent of it when you're constructing the structure of the song.
Map the colors to the various types of the parts, e.g. yellow for verse and red for chorus, green for bridge etc.Put the sequence up on the wall or on a big paper.
This has a few advantages:

you can write details on the notes e.g. about the song structure, or about the rhythm section or whatever you think is necessary and relevant. E.g. a yellow note "WITH lead guitar" and later on one with "NO lead guitar". Or e.g. "straight 4/4" and one with "syncop. 4/4"
It's easy to shuffle them around, when you mess with the structure
You can tear the notes in half vertically or horizontally e.g. if you need to denote it switching from 4/4 to 2/4 and back
You can have multiple rows, e.g. if the bass keeps on going with the same line as in the verse but all others go to the bridge you could have a separate row for the bass with its own post-its
It's a LOT easier to remember the structure of the song. Seriously.
You can take pictures if it's not convenient to take the post-its with you, and reconstruct the next time
It's a lot easier to discuss and for everyone to refer to specific parts of the song, no more "yeah I meant the first second part, not the second second part". Simply point at the post-it.
Comment: Or - find a drummer who can do the job - it's not that difficult..!
Answer: I too though use "verse chorus" instead of "A B".
You could also put the first few words of the lyrical line with those labels, the words might be a more concrete association.
Make boxes proportionally sized. If verses are 4 bars and there is a transition of just 2 bars, make sure the transition box is half the size.
Color is good too, and keep it consistent, like verses are green, choruses blue, bridges are red. Anything else probably don't color, you don't what a rainbow dazzle, just some color highlights.
I would also think one of the best cues would be some eye contact and body signals. Maybe the singer can do this.
Answer: I had several bands where I was the only one who could read music. In the cases where this was needed (sometimes new songs and a few times a customer would give a big tip if we could play something we hadn't heard of so I had to sightread the music), I would read and play the music and the band would follow (like when a member was the only one who knew a piece.) Of course, we rarely used music in performance but it was useful while learning new stuff.
Bob Wills' band (The Texas Playboys) found out during the 1930s that they had to learn to read to play complicated country music; those who couldn't learn were let go; Bob had to learn to play from sheet music in his 30s.
To get started, whoever can read the singer's pieces should just play them and tell the other musicians what to do during rehearsals.
Comment: Reading the question, it seems like the drummer can't remember, even after rehearsals (to me).


Sobolev estimates $\|\phi\|_2\leq\|\phi\|_{H^2}$

Question: I have been reading the paper 'Convergence of a finite volume scheme for a system of interacting species with cross-diffusion' by Carrillo et al. in Section 4.1 they have been using an estimate,
$\|\nabla\phi\|_{L^{\infty}(\Omega)}\leq \|\phi\|_{H^2(\Omega)}$,
which seems quite intuitive, however I am unable to show the result. I already know for a bounded domain, $\Omega$
$\|\cdot\|_{L^1(\Omega)}\leq\|\cdot\|_{L^2(\Omega)}$,
and this can be extended to any finite $p$. However, this is not true for the essential supremum norm. $\|\cdot\|_{L^p(\Omega)}\nleq\|\cdot\|_{L^{\infty}(\Omega)}$, as pointed out by @falcon
I also unsuccessfully tried to use the Poincaré Inequality, stated as
$\|\phi\|_{L^p}\leq\|\nabla\phi\|_{L^p}$, for $\phi$ in $H^2(\Omega)$.

EDIT: This assertion is false as shown by the counterexamples provided by @falcon. I am posting a new question with the correct form as given by @calvin-khor
Comment: You want to show $||\phi||_{L^{\infty}(\Omega)}\leq ||\phi||_{H^2(\Omega)}$ for a bounded $\Omega$ ?
Comment: Yes, that this what I would like to show.
Answer: Well, this is not true. Take $\Omega = [0,1/2]$ and $\phi(x) = 2$ for all $x$, then
$$\|\phi\|_{L^\infty} = 2$$
but
$$\|\phi\|_{H^2} = \left(\|\phi\|_{L^2}^2 + \|\phi'\|_{L^2}^2  + \|\phi''\|_{L^2}^2\right)^{1/2} = \int_0^{1/2}2 = 1. $$

EDIT: Still not true. Take $\Omega = [0,1/2]$ and $\phi(x) = 2x$, then
$$\|\nabla \phi\|_{L^\infty} = 2$$
but
\begin{align}
\|\phi\|_{H^2} &= \left(\|\phi\|_{L^2}^2 + \|\phi'\|_{L^2}^2  + \|\phi''\|_{L^2}^2\right)^{1/2}  \\
&= \left(4\int_0^{1/2} x^2 dx + 4\int_0^{1/2} dx\right)^{1/2}\\
&= \left(\frac{1}{6}+ 2\right)^{1/2} < 2.
\end{align}
Comment: What is true is $\|\nabla \phi\|_{L^\infty((a,b))} \le C \|\phi\|_{H^2((a,b))}$.
Comment: May be they missed the constant or its in the estimate, should I post this as a seperate question? Btw thank you for the counterexamples!
Comment: I think I wrote the inequality wrong, I am sorry I will fix it.
Comment: What I would like to show is $||\nabla\phi||_{L^{\infty}(\Omega)}\leq ||\phi||_{H²(\Omega)}$ for a bounded domain $\Omega$
Comment: Yes, post another question with the link to this one. And you are welcome for the counterexamples :)
Comment: Just added a new one [here](https://math.stackexchange.com/questions/4472299/sobolev-estimates-nabla-phi-2-leq-c-phi-h2). @Falcon


How can I dynamically set the site URL (in Drush9+)?

Question: In Drush 8 I had that neat little reusable line in my drushrc.php:
$options['l'] = getenv('MY_SITE_URL_VAR');

I know that I can hardcode my site URL in a drush.yml file, but that does not fit my configuration workflows, where each server knows its URL.
So how can I set the l option from an environment variable?
Answer: I don't see how you can easily reproduce that (nice) configuration setup since the yaml files are indeed static.
The only solution I see is to write a little wrapper script that always calls drush with the --uri option, like:
drush --uri $MY_SITE_URL_VAR $@

Recommended solution
A much simpler solution is to use the shell variable DRUSH_OPTIONS_URI.
export DRUSH_OPTIONS_URI=http://example.com

I wasn't able to find any documentation for this, but it seems to work.
Comment: Now documented in https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml


500 internal server error on server, works locally

Question: How do I go about tracking down an error when all production.log gives me is this?
11:     <%= javascript_include_tag "application" %>
12:     <%= csrf_meta_tags %>
13:     <%= yield(:head) %>
app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__4417234491726047977_45250520'
app/controllers/docs_controller.rb:27:in `index'
Processing by ErrorsController#broken as HTML
Rendered errors/broken.html.erb within layouts/application (0.5ms)
Completed 500 Internal Server Error in 16ms

FYI: the line 10 of application.html.erb is <%= stylesheet_link_tag "application", :media => "all" %> so I'm assuming it has something to do with either my CSS or my gemfile. How do I investigate it further?
Also, my gemfile:
source 'https://rubygems.org'

gem 'rails', '3.2.12'
gem 'json', '1.7.7'
gem 'mysql2'

group :assets do
  gem 'coffee-rails'
end

group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'meta_request'
end

group :development, :test do
  gem 'rspec-rails'
  gem 'steak'
  gem 'factory_girl_rails'
end

gem 'sass'
gem 'less-rails'
gem 'less-rails-bootstrap'
gem 'jquery-rails'
gem 'devise', '>= 2.1.2'
gem 'cancan'
gem 'paperclip', '~> 3.0'
gem 'therubyracer'
gem 'yaml_db'
gem 'passenger'
gem 'capistrano'
gem 'prawn'
gem 'bootstrap-wysihtml5-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'kaminari'
gem 'truncate_html'
gem 'rails3-jquery-autocomplete'
gem 'whenever'
gem 'impressionist'
gem 'acts_as_list'
gem 'acts_as_indexed'
gem 'state_machine'
gem 'exception_notification'
gem 'public_activity'

Answer: My gemfile needed uglifier, which was imported with an old version of another gem.
gem 'uglifier'

fixed it.


Regarding Dilated Convolutions vs Max-Pooling with Padding

Question: I have been going through the paper, Multi-Scale Context Aggregation by Dilated Convolutions.
In it they propose using dilated convolution to get global context as opposed to max-pooling/downsampling since pooling will shrink your image and dilated convolutions will not.
My first question is: They modify VGG16 and remove the last two max-pooling layers but they leave the other 3 max-pooling layers in. Why did they not just remove all the max pooling layers? Computational efficiency? Won't this result in a smaller image? How do they expand it back to the original size, bilinear interpolation?
My second question is: They note in the paper:

"We also remove the padding of the intermediate feature maps.
  Intermediate padding was used in the original classification network,
  but is neither necessary nor justified in dense prediction."

Why would that be the case, if you don't pad will you not further reduce the size of our final output, especially given that dilated convolutions can have very large receptive fields?
Answer: Answering your first question, I think you are correct, the output is 1/8th the original size and they  use interpolation to upsample to original size. You can find the evidence in source code available here. In the file test.py, function test_image, the default zoom is set at 8 (line 103). More evidence can be found in the file train.py where again default zoom is set to True and they use an upsampling layer.
And since they are already reducing size they dont need to use padding just to retain size. The reason I think padding is not needed in their case is that segmentation is a case of dense prediction and thus introducing some pixels from our own side don't intuitively make sense. But again the best way to argue about the same would be to practically test a network both with and without intermediate pooling.


How to prune a decision tree properly in R

Question: I have a sample of 12,500 observations and 12 explanatory variables. I want to build a pruning decision tree, to do that I am using the rpart function and then the prune function. My problem is that I am not sure how to build the full tree, I am using
rpart(*, *, *, control = (minbucket=x, minsplit=y, cp=z))
# the * are irrelevant to my question

to build the full tree, but I don't know what x, y and z should I use. All the examples I have found are with much fewer observations compared to my case.
Comment: Is your question about how to use the R code properly, or about how to build such trees more generally? If the former, it would be off-topic for CV (see our [help center](http://stats.stackexchange.com/help/on-topic)), but could be on-topic on [Stack Overflow](http://stackoverflow.com/) if it has a [reproducible example](http://stackoverflow.com/q/5963269/1217536). Please clarify your question. If it is about R code, add a reproducible example & we can migrate your Q to SO for you (*please don't cross-post, though*).
Comment: Requires statistical knowledge, on topic. Thank you for sharing your question here.
Comment: Ths isn't really about _pruning_ a tree, but how to _build_ it.
Comment: Helpful: http://stackoverflow.com/questions/15318409/how-to-prune-a-tree-in-r
Answer: To put every observation into its own leaf, use minbucket=2, minsplit=1, cp=-1. The negative value for cp is to ensure that rpart doesn't end splitting prematurely.
You probably don't want to put every observation into its own leaf though. It just makes the pruning task more difficult, and your tree take a lot of time to fit and memory to store. You can get by with the default values of minbucket and minsplit for the most part (but cp=-1 is ok). If you have a big dataset (much bigger than 12500 cases) you should actually increase these values.
Answer: It doesn't hurt to set cp a good deal smaller that the default of 0.01 because plotcp() will show you where you need to set cp anyway. Try 0.002.
I actually don't worry about minbucket and minsplit (no idea how much this could be hurting me), so someone else will have to help you with those.


PHP - Mostrar mensagem de dados inseridos correctamente

Question: Estou com dificuldade em colocar uma mensagem a dizer : Dados inseridos com sucesso e depois enviar para outra página.
<?php
  include 'ligacao_pdo.php';

    $condutor = $_POST['condutor'];
    $carro = $_POST['carro'];
    $matricula = $_POST['matricula'];

 if (!$ligacao->query("INSERT INTO condutor (condutor, carro, matricula) VALUES ('$condutor', '$carro', '$matricula')"))

{
   echo"SUCESSO";
   header("location: add.php");

 }

Comment: Possível duplicata de [Erro - "Cannot modify header information - headers already sent"](https://pt.stackoverflow.com/questions/4251/erro-cannot-modify-header-information-headers-already-sent)
Comment: Se você vai redirecionar para outra página, por que exibir uma mensagem?
Comment: Se tiver sucesso salve a mensagem de sucesso em uma variável de sessão, assim na outra página vc chama a variável, vou fazer um exemplo.
Answer: Na página que faz a inserção no banco, vc salva uma variável de sessão com a mensagem, assim:
<?php
include 'ligacao_pdo.php';
session_start();
$condutor = $_POST['condutor'];
$carro = $_POST['carro'];
$matricula = $_POST['matricula'];

if (!$ligacao->query("INSERT INTO condutor (condutor, carro, matricula) VALUES ('$condutor', '$carro', '$matricula')"))
{
    $_SESSION['sucesso'] = "Dados salvos com sucesso!";
    header("location: add.php");
}
?>

E na add.php que a página para qual o usuário será redirecionado:

OU só um echo:
<?= $_SESSION['sucesso']; ?>

testa aí.
Comment: Não estou a conseguir redireccionar para a página add.php
Comment: Dá algum erro?
Estão no mesmo diretório?


Explicit formula from for interesting reccurence

Question: $$t_0=-5, t_1=\frac{11}{5} $$
$$t_n=1-\frac{2}{t_{n-1}} + \frac{-4}{t_{n-2}*t_{n-1}} $$
I have never seen so uncommon formula for recurrence like this before. I have no idea how to solve it. Please, can anyone help me ?
Answer: The recurrence can be re-written as $t_n t_{n-1} t_{n-2} = t_{n-1}t_{n-2} - 2t_{n-2} -4$.
Let $x_n = t_0 t_1 t_2 \dotsb t_n$. Then
$$\frac{x_n}{x_{n-3}} = \frac{x_{n-1}}{x_{n-3}} - 2\frac{x_{n-2}}{x_{n-3}} -4$$
Hence $x_{n} = x_{n-1} - 2x_{n-2} - 4x_{n-3}$ and $x_0 = -5$, $x_1 = -11$, $x_2 = -5$. You can find $x_n$ from this (one solution of the characteristic equation is $r=-1$), and then $t_n = \frac{x_{n}}{x_{n-1}}$.
Answer: I propose a solution utilizing the very interesting auxiliary sequence called $x_n$ introduced by @Catalin Zara, verifying
$$x_{n} = x_{n-1} - 2x_{n-2} - 4x_{n-3}$$
The characteristic equation $r^3 - r^2 + 2r + 4 = 0$  of this recurrence relationship has the following roots $r=-1$, $r=1\pm i \sqrt{3}$.
Therefore, its general term can be expressed, using calculations that we do not reproduce here, in the following way
$$x_n=-\dfrac{1}{7}\left( A(-1)^n + B 2^n \cos(n\pi/3)+C 2^n \sin(n\pi/3)\right) \ \ \text{with} \ \ \ A=3, B=32, C=16 \sqrt{3}$$
(taking initial conditions into account). Therefore:
$$t_n=\dfrac{x_n}{x_{n-1}}=\dfrac{A(-1)^n + B 2^n \cos(n\pi/3)+C 2^n \sin(n\pi/3)}{A(-1)^{n-1} + B 2^{n-1} \cos((n-1)\pi/3)+C 2^{n-1} \sin((n-1)\pi/3)}$$
Division of the numerator and the denominator by $2^{n-1}$ prove that this sequence is arbitrarily close to the following sequence:
$$u_n:=2\dfrac{B \cos(n\pi/3) + C \sin(n\pi/3)}{B \cos((n-1)\pi/3)+C \sin((n-1)\pi/3)}$$
which has a cycle of length three: $2.5, 0.4,-8$.
For example, $u_{30}=\dfrac{2 B}{\dfrac{B}{2}-C\dfrac{\sqrt{3}}{2}}=-8$
Remark: this period-3 cyclic behavior persists when changing initial conditions.
Comment: You are right. I correct it.


How to create file using streamwriter in c# in which the content is inputed by users using cmd

Question: I created a console application which accepts arguments. After building the program i will run it through cmd in which the user will input like this "filemgr.exe create [filename] [contents]" . My code is below. I want to enter "my text here" content, but when i check the output, only the FIRST word is displayed which is the "my", how to include the rest of the strings?(which is the text here)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace filemgr
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args[0]=="create")
            {
                using (StreamWriter file = new StreamWriter(args[1]))
                {
                    file.Write(args[2]);
                }
            }
        }
    }
}

Comment: Space in the separator of console parameters, if you want to pass phrase with space as single param you should surround the phrase with double quotes :

MyExecutable.exe "Param1 gose here" Param2
Comment: is it possible not to use double quotes? is it programmable in c# in making phrase with spaces as single param?
Answer: Pass content args in double quotes
filemgr.exe create [filename] "[contents]"

filemgr.exe create C:\test.txt "my file content"

I would suggest to use quotes even in file path as well. When you use args, its always a chance to make mistake while accessing arguments.
Answer: You need to recombine the args array into a string (although this method will likely lose quotes):
file.Write(string.Join(" ", args.Skip(2)));

Alternatively you can quote the string in the commandline:
program.exe create test.txt "hello this is a message"

Also, if you want to append to the file through sequential calls you need to open the stream like so:
using (StreamWriter file = new StreamWriter(args[1], true))

This signifies that you want append mode, and not create/replace.


If $a,b$ have order $2^j$ mod $p$, then $a\cdot b$ has order $2^{j'}$ mod $p$ for some $j'<j$.

Question: Let $a,b\in\mathbb{Z}^+$ and $p$ prime such that $(a,p)=(b,p)=1$. If $a,b$ have order $2^j$ mod $p$, then $a\cdot b$ has order $2^{j'}$ mod $p$ for some $j'<j$.
I have been trying this problem using that $ord_p(ab)\mid 2^j$. But I'm not sure.
Comment: If $a,b$ have order $2^j\bmod p$, then $a^{2^j}\equiv b^{2^j}\equiv1\bmod p$, so $(ab)^{2^j}\equiv1\bmod p,$  so $ord_p(ab)|2^j$, so $ord_p(ab)=2^{j'} $ for some $j'\mathbf \le j$
Answer: It simply suffices to show that $(ab)^m \equiv 1 \pmod{p}$ where $m=2^{j-1}$. We know that $(a^m)^2 \equiv 1 \pmod{p}$ but $a^m \not\equiv 1 \pmod{p}$. This means that $a^m \equiv -1 \pmod{p}$. Similarly, $b^m \equiv -1 \pmod{p}$. Hence:
$$(ab)^m \equiv -1 \cdot -1 \equiv 1 \pmod{p}$$
which proves the required.
Comment: Thank you, I liked your idea to prove the result.


Aparecer um loading enquanto os nomes não são listados na busca autocomplete Jquery

Question: Estou usando na minha busca interna o Jquery onde ao digitar a primeira letra, aparece o nome dos usuários referentes a letra digitada. Até aqui funciona corretamente,  o problema é que a query que estou usando, ela faz busca em uma outra tabela da chave estrangeira e foi incluído também um Count. Algo mais ou menos dessa forma:
SELECT *, COUNT(COMP.IdCompras) AS QTDComprasEfetuadas FROM usuario USU INNER JOIN compras COMP ON USU.IdUsuario = COMP.IdUsuario;

Só que estou sentindo uma certa lentidão para aparecer os nomes e gostaria de colocar um loading e o botão para buscar aparecesse só depois da query executada. O código que tenho é esse:

      <input type="text" name="Nome" class="form-control col-md-8" placeholder="Digite o nome do usuário" id="usuario" aria-label="Buscar por nome" aria-describedby="btnGroupAddon2">

         <button type="submit" class="input-group-text" id="btnBuscar" style="cursor: pointer"></button>

Answer: Consegui resolver dessa forma:


showing map $\mathbb{RP}^2 \rightarrow \mathbb{RP}^5$ is smooth embedding

Question: Condider $f:\mathbb{RP}^2 \rightarrow \mathbb{RP}^5$ given by
$$f[x,y,z]=[x^2,y^2,z^2,yz,xz,xy]$$
I would like to show that $f$ is a smooth embedding, meaning that it is a smooth immersion and a topological embedding. For $f$ to be a smooth immersion, I need the differential to be injective. This is given by
$$df=\begin{pmatrix}
2x & 0 & 0\\
0 & 2y & 0\\
0 & 0 & 2z\\
0 & z & y\\
z & 0 & x\\
y & x & 0\\
\end{pmatrix}.$$
However, I am not sure how homogeneous coordinates influence this. Do I need to use charts rather?
Answer: Yes, you need to use charts. What you have written is not $df$, it is the differential of a map $\mathbb{R}^3 \to \mathbb{R}^6$. But we can restrict $f$ to an affine chart
$$ f[x,y,1] = [x^2,y^2,1,y,x,xy] $$
and compute its differential as a map $\mathbb{R}^2 \to \mathbb{R}^5$
$$ df = \begin{bmatrix} 2x & 0\\ 0 & 2y\\ 0 & 1\\ 1 & 0\\ y & x \end{bmatrix} $$
Edit: Here's how to finish the argument. By computing the differential you can show that $f$ is a smooth immersion. Next we show that $f$ is injective. Suppose that $f[x,y,z] = f[a,b,c]$. Then $x^2=a^2,y^2=b^2,$ and $z^2=c^2$ (since e.g. $x^2=-a^2$ is impossible) so $x=\pm a, y=\pm b, z=\pm c$. Now use the equations $xy=ab,yz=bc,xz=ac$ to see that either $x=a,y=b,$ and $z=c$ or $x=-a, y=-b$, and $z=-c$. In either case $[x,y,z]=[a,b,c]$ so $f$ is injective.
Now $f$ is an injective smooth immersion defined on compact manifold, so it is an embedding.
Comment: Being a smooth immersion is a local property, so you can verify it by checking on each chart. Can you tell $f$ is a smooth immersion restricted to this chart in my answer? After that, you can compute the differential in two more affine charts and get a similar answer. Now to check that $f$ is an embedding, you just need to check that $f$ is injective. But you can check that directly from the definition.
Comment: You now need to check that $f$ is injective. An injective smooth immersion on a compact manifold is a topological embedding. See for instance: https://math.stackexchange.com/questions/1111112/condition-that-a-local-homeomorphism-be-a-covering-map
Comment: So I know that if a map between manifolds is locally a smooth embedding, then it is globally as well. But I still don't understand how I can use the charts to show this particular map is a smooth embedding.
Comment: Being an embedding is a global property, not a local one. There is no additional difficulty in this case, however, since the domain is compact and the codomain is Hausdorff. Nonetheless it might be instructive to figure out what the inverse looks like and why it is continuous.
Comment: I managed to show that f is a smooth immersion in local coordinates by showing that the differential has trivial kernel is each coordinate chart, meaning that it is injective. How do I check that f is a homeomorphism onto its image (so it's a topological embedding as well)?
Comment: I am still not sure how to check injectivity. So suppose $f[x,y,z]=f[a,b,c]$, say. Then I have to show that $[x,y,z]=[a,b,c]$, but I also need to consider that in projective space points which are scalar multiples of each other are the same.


Fundamental group of the $m$-fold suspension of a finite discrete space

Question: Recall that the suspension of a topological space $X$ is the space $SX$ resulting by identifying $X\times\{0\}$ and $X\times\{1\}$ to single points of the "cylinder" $X\times[0,1]$. Now let $X_m$ be a discrete space consisting of $m$ points, and denote by $S^nX$ the $n$-fold suspension, i.e., $S^nX=SS^{n-1}X$.

What is the fundamental group of $S^nX_m$ for $n,m\geq1$?

Here is my attempt. The case $m=2$ is easy since $SX_2$ is a circle, so the fundamental group is $\mathbb Z$, and $S^2X_2$ is the sphere, whose fundamental group is trivial. Further, the suspension of the $n$-sphere is the $(n+1)$-sphere so $\pi_1(S^nX_2)$ is trivial for $n\geq2$.
Now consider $m>2$. Then $SX_m$ is homotopy equivalent to an "$(m-1)$-fold eight"
$$\underbrace{\bigcirc\hspace{-.1cm}\!\bigcirc\hspace{-.1cm}\!\bigcirc\cdots\bigcirc}_{\text{$m-1$ circles}}$$
so the fundamental group is $F_{m-1}$, the free group on $m-1$ generators. If I am not mistaken two homotopy equivalent spaces have homotopy equivalent suspensions, so $S^2X_m$ is homotopy equivalent to the wedge product of $m-1$ spheres, and consequently $\pi_1(S^2X_m)$ is trivial. I am having trouble, however, to visualise the space $S^nX_m$ for $n>2$. How can $\pi_1(S^nX_m)$ be computed?
Comment: I had to delete my answer, because it's actually reduced (or pointed) suspension that preserves wedges, and though for spheres reduced and unreduced suspension agree, I don't see an easy argument as to why it should be the same for wedges of spheres (though it seems to be the case in low dimension so it's probably true; but that's really not a good argument)
Comment: Ok, but thanks anyway!
Answer:
$m = 1$: All suspensions of $X_1$ are contractible.
$m > 1$:

2.1. $n = 1$: As you stated correctly, $\pi_1(SX_m) = F_{m-1}$.
2.2. $n > 1$: Let us prove the following theorem.
If $Y$ is path connected, then $SY$ is simply connected.
This applies to $Y = S^{n-1}X_m$.
Let $p : Y \times I \to SY$ denote the quotient map. Since $Y$ is path connected, so are $Y \times I$ and $SY$. As a basepoint for $SY$ choose $z_0 = p(y_0,1/2)$, where $y_0 \in Y$ is an arbitrary point. The sets $U = p(Y \times (0,1])$ and $V = p(Y \times [0,1))$ are open in $SY$, and we have $z_0 \in U \cap V = p(Y \times (0,1)$ which is pathwise connected. Since $U$ and $V$ are contractible, we get $\pi_1(U,z_0) = \pi_1(V,z_0) = 0$.
Now apply the Seifert-van Kampen-theorem to see that $\pi_1(SY,z_0) = 0$.
Comment: That's a very useful result, thanks!


Create proportional tables of a single variable with a list of variables

Question: This is probably a very easy question, but I cannot seem to figure it out.
I created a proportional table of two variables:
mtcars %>%
  group_by(cyl, carb)%>%
  summarise(n=n())%>%
  mutate(prop=n/sum(n))%>%
  subset(select=c("cyl", "carb", "prop"))%>%
  spread(cyl, prop)%>%
  kable()

Now I want to create multiple tables with cyl as one variable and looping through a list of multiple variables for the second variable. This was one approach I tried that didn't work:
cols = c('vs', 'am', 'gear', 'carb')
for (q in cols) {
  map2(~prop.table(table(mtcars[[q]], mtcars[["cyl"]])))
}

Thanks in advance for any help!
Answer: Here,  we can use map to loop over the 'cols' instead of for + map2 to return a list of output
library(purrr)
lst1 <-  map(cols, ~ prop.table(table(mtcars[[.x]], mtcars[["cyl"]])))
lst1
#[[1]]

#          4       6       8
#  0 0.03125 0.09375 0.43750
#  1 0.31250 0.12500 0.00000

#[[2]]

#          4       6       8
#  0 0.09375 0.12500 0.37500
#  1 0.25000 0.09375 0.06250

#[[3]]

#          4       6       8
#  3 0.03125 0.06250 0.37500
#  4 0.25000 0.12500 0.00000
#  5 0.06250 0.03125 0.06250

#[[4]]

#          4       6       8
#  1 0.15625 0.06250 0.00000
#  2 0.18750 0.00000 0.12500
#  3 0.00000 0.00000 0.09375
#  4 0.00000 0.12500 0.18750
#  6 0.00000 0.03125 0.00000
#  8 0.00000 0.00000 0.03125

If we want to use the tidyverse functions
library(dplyr)
library(tidyr)
map(cols, ~ mtcars %>%
               group_by_at(vars(cyl, .x)) %>%
               summarise(n = n()) %>%
               mutate(prop = n/sum(n)) %>%
               select(cyl, !!.x, prop) %>%
               pivot_wider(names_from = cyl, values_from = prop))

Comment: Both options worked great! And thanks for showing it two ways.


How to display multiple default items for field collection with unlimited cardinality?

Question: I have used following code and it works fine i.e 3 items are displayed, but the issue in my code is add another item button remains inactive on click.
<code><?php

function two_form_alter(&$form, $form_state, $form_id) {

  if($form_id == 'product_culinary_node_form') {
    $field_language = $form['field_tabs']['#language'];
    $items_count = 3;

    $field_name = 'field_tabs';
    $form_theme = $form[$field_name][$field_language]['#theme'];

    // Remove delete and add more buttons
    // $form[$field_name][LANGUAGE_NONE][0]['remove_button']['#access'] = FALSE;
    $form[$field_name][$field_language]['add_more']['#access'] = TRUE;

    $items = &$form_state['field'][$field_name][$field_language];

    // Generate required number of fields collection
    if ($items_count > 1 && $items['items_count'] != $items_count) {
      $items['items_count'] = $items_count;

      // $items['field']['cardinality'] = $items_count;
      $wrapper = $form[$field_name][$field_language]['add_more']['#ajax']['wrapper'];
      $field_parents = $form[$field_name][$field_language]['#field_parents'];
      $language = $form[$field_name][$field_language]['#language'];
      $after_build = $form[$field_name][$field_language]['#after_build'];
      $form[$field_name][$field_language] = field_multiple_value_form($items['field'], $items['instance'], $field_language, array(), $form, $form_state);
      // Reset theme function, as field_multiple_value_form hijacks it
      $form[$field_name][$field_language]['#theme'] = $form_theme;
      $form[$field_name][$field_language]['#after_build'] = $after_build;
      $form[$field_name][$field_language]['#language'] = $language;
      $form[$field_name][$field_language]['#field_parents'] = $field_parents;
      $form[$field_name][$field_language]['add_more']['#ajax']['wrapper'] = $wrapper;
    }
  }
}
</code>
Comment: Check out [this issue](https://www.drupal.org/node/1337804), You might find something useful.
Comment: Yogesh, I have gone through almost all the patches and comments of the issue you have linked above and related posts. Nothing has worked till now.
Answer: 1 solution to this is https://www.drupal.org/node/1337804#comment-6326678. I will post another solution if found without form rebuild.


Woocommerce WC_Order get_shipping_address() not returning as array

Question: When retrieving order information from Woocommerce it states it should be an array see..
http://docs.woothemes.com/wc-apidocs/class-WC_Order.html#_get_shipping_address
Instead it returns a comma separated string.
Looking at the function in the core code of Woocommerce...
<code> public function get_shipping_address() {
  if ( ! $this->shipping_address ) {
      if ( $this->shipping_address_1 ) {
          // Formatted Addresses
                $address = array(
                'address_1'     => $this->shipping_address_1,
                'address_2'     => $this->shipping_address_2,
                'city'          => $this->shipping_city,
                'state'         => $this->shipping_state,
                'postcode'      => $this->shipping_postcode,
                'country'       => $this->shipping_country
                );
         $joined_address = array();
            foreach ( $address as $part ) {
                if ( ! empty( $part ) ) {
                    $joined_address[] = $part;
                }
            }
            $this->shipping_address = implode( ', ', $joined_address );
        }
 }
  return $this->shipping_address;
 }
</code>
I can see it using implode to create the string, without modifying this function how can I call this function and retrieve $address as an array? (if this is possible?)
The reason is I CAN explode the returned value but commas in the address will break it.
Answer: Habit of answering my own questions...
So to receive a string as explain above you would do it like this...
<code>$order = new WC_Order($order_id);
echo $order->get_shipping_address();  //Road , Street, City, County, Postcode, Country
</code>
If you want to receive individual lines you can do so like this...
<code>$order = new WC_Order($order_id);
echo $order->shipping_city;      //London
echo $order->shipping_country;   //GB
</code>
IMO the later is going to be a lot more useful!


i feel confused with jquery's load

Question: with jquery,how can i do something just after the dom loaded,i write like this:

but nothing happen~
if i use ready() instead of load like this:

,it will work ,but the pointer "this" will not be $("#google"),and it seems to be "window" or other things,i feel confused~
Comment: Could you tell us whether that image is dynamically generated or hard-coded in your html ?
Comment: it's hard-coded and what i want is that the function work after the dom loaded~ not all the document dom tree loaded ,as sometimes the dom tree is too big~
Answer: If I understood correctly you want to manipulate #google after the DOM is fully loaded. Then what you want to use is actually $(document).ready(function() {//do stuff with #google});
.load() is used to make ajax requests. You should read up on it here
It would also be interesting to know whether #google is dynamically generated or not.
Oh and in your second example, you can't do alert(this). alert() just takes a string as a parameter.
Comment: @wong2 Thing is he doesn't describe exactly how the image comes into all this... Edit: I've just asked him.
Comment: @David : The reason I asked is in case he took the code from Firebug or Web Inspector ;) But yeah it stands to reason that the image is already there in the code.
Comment: i learn the load event from jquery's website:http://api.jquery.com/load-event/
and it can be use in many doms "This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object." what i want is the function work just after the dom loaded
Comment: @Dafims, and you're not inherently using it wrong, it's just that in your particular scenario, you don't seem to need it.
Comment: @ Guy Fawkes ,TX i used $(document).ready to solve the problem that all doms loaded, so i want to know if some methods will work after some special dom loaded~
Answer: In your first code, you're looking a #google element and tells it to notify you when its image is loaded. However, at the time where the javascript is executed (above the element, in the code), there exists no #google element, and so the event listener is not assigned to anything.
Sadly, adding the event listener inside a DOMReady listener won't always solve the problem either. If, for instance, the image is already in browser cache, the #google load event may occur before DOMReady. The safest approach seems to be to attach the listener immediately after the image is created.

Working example
If you're not happy with injecting a script block in the middle of your code like that, but want to defer your script to someplace later, you can always listen to $(window).load() instead of $('#google').load(). This is equivalent to , i.e. it will run when all external content has been loaded. So when $(window).load() occurs, you know that your #google image has loaded, but it's not guaranteed to be immediately after it's loaded.
Comment: works in jsbin, but not in jsfiddle, that's because you have to add the  immediately after the . I think it's not nice..
Comment: TX~ i works~
follow your mind,i want to know if jquery's live event will work as its Description: Attach a handler to the event for all elements which match the current selector, now and in the future.
but it seems that
Answer: Try this instead:
$(function() {
    var that = $("#google");
    alert(that);
});

This code will run when the DOM is fully loaded, as triggered by the $(document) ready() event.
Answer: Just use the following:
$(document).ready(function() {
   alert("The DOM has loaded");
});

The .load function is used to trigger an ajax call and place the response in the div specified.
Comment: as i know "$(document).ready" will work after all dom loaded, what i want is after the "#google" dom loaded,sometimes we got a large html file and we want the script works after some dom loaded~
Answer: You should first bind the event handler to the load event, then set the image's src to actually start the load.
$('#google').bind("load", function() {
    alert('ok');
});
$("#google").attr("src", "http://www.google.com/images/logos/ps_logo2.png");

see this: http://jsfiddle.net/VaLhf/
Comment: If you're going with this approach, a safe practice is to let the image initially point to a transparent pixel or something like that, because some browsers will interpret an omitted `src` just like they interpret a `form` without an `action`, i.e. as a reference back to itself, and cause a second request to the page the image resides on. That can cause some oddities if you're executing serverside script on that page. And if you are referencing a transparent pixel from the beginning, you better check sure your `load` listener to verify that it's not *that* image that is being fired.
Comment: i seems that it works after $(window).loaded like this:
 $(window).load(function(){
    $('#google').bind("load", function() {
      alert('ok');});$("#google").attr("src", "http://www.google.com/images/logos/ps_logo2.png");

 });

i think it will be a good method to solve the load problem,through dynamic add attribute ~TX

i feel confused with jquery's load


Como posso fazer uma comparação do atributo?

Question: Como posso fazer a comparação >0 ou <0 entre estes atributos no Yii?
[
    'attribute' => 'gross_total',
    'header' => 'ENTRADAS'
],

[
    'attribute' => 'gross_total',
    'header' => 'SAÍDAS'
],

Answer: Assumindo que esteja utilizando um GridView no Yii2. Na propriedade value da column, você pode utilizar uma closure e efetuar a comparação:
[
    'attribute' => 'gross_total',
    'header' => 'SAÍDAS',
    'value' => function ($model, $key, $index, $column) {
        if($model->gross_total > 0){
            return 'Gross total maior que zero.'
        }
    }
],


What is this descending riff of notes referred to as?

Question: In this battle song from Xenoblade Chronicles 3 Future Redeemed, between 1:09 and 1:13, there's a jazzy piano riff of notes that steadily descend. Something about it really sticks out to me, and sounds iconic (like I've heard something like it before). Is there a name for this particular type of riff? Or is it emblematic of a certain genre/style of music?
If I'm not mistaken, the entire song is basically in a really up-beat major key up to that point, whereas this riff just pops in out of nowhere in a minor key?
Answer: That riff is called a montuno. It is actually only a snippet of a montuno because a montuno is generally a repetitive rhythmic pattern that extends over many bars and also outlines the harmony with the pitches used. It is played mostly by the piano in Afro Cuban, Salsa and Latin Jazz. Over the years this type of pattern has spread into other Latin and non-Latin styles as well. Sometimes it is just single notes played in both hands and other times it can combine single notes with 2 or 3 note chords. It can be clave based (two bars long) or non-clave based (one bar long). This one in particular is a single note two bar clave based pattern. Clave is both an instrument, 2 sticks that are struck together and also the name of a 2 bar pattern that is the underlying pulse that other rhythm instruments base their patterns on. The pattern can start on either bar and is named for the number of notes in each bar, 5 total, either 3-2 or 2-3.
Below is what is played on the recording with one exception, I replaced the final note, C# with D to make it a better looping pattern. The descending aspect of the pattern comes from the chords, written above. The 2-3 clave on which this pattern is based is in the staff below for reference:
Comment: @chausies At 4:20 he plays pretty much the same pattern a semitone up in Cm!
Comment: Thanks so much! As an aside, I found this video on Montuno that basically killed me with how powerful it is @.@: https://youtu.be/_sG6RI7aYVQ?t=218
Comment: @chausies I tried to reasonably include as much detail as I could but there are actually entire books written about this! "The Salsa Guidebook" by Rebecca Mauleón is particularly good because it has chapters on different instruments and different grooves and how they work together. I believe she also has a separate book dedicated to piano.
Answer: It is a very typical example of a Montuno, a common Latin (eg. salsa) piano comping riff that features (in the right hand) arpeggiated (broken) chords while accentuating (in octaves) one of the chord voices (with nice voice leading) in a repeating 2 bar syncopated pattern.
In your example the voice leading is chromatically descending (root, M7, 7, 6). The Montuno is very brief and, as you pointed out yourself, somewhat out of context. Here it is more a quote.  Usually it repeats over the chord changes throughout an entire song or section.


Are there models for "censored" spatial point processes?

Question: This is a problem I'm encountering in the context of analyzing a data set comprised of all crime locations in a city over a fixed time interval, although it could potentially arise in other types of point processes. The problem has to do with the fact that crime locations are not observed exactly. They are located by whatever street address the police wrote down on their report. In my city of study (and probably almost any city), there are "natural barriers" in the landscape that make these "locations" inherently imprecise.
For example, suppose there is a large nature reserve/park in the middle of a city. Then, all crimes occurring within the nature reserve are mapped to a single address - presumably the address of the main office of the nature reserve. This kind of "censoring" causes artificial clustering in the data set and, most likely, biases the estimate of the intensity function and the associated covariate effects, etc. I'd imagine these sort of "natural barriers" exist in pretty much any city so that this issue has probably been fomented by other researchers so my question is: Are there known methods for handling this type of data?
At the moment, I have analyzed this data set using an ordinary inhomogeneous poisson process model and have gotten some interesting results. I really think these results are "real" based on previous descriptive analysis, etc. and the model fits reasonably well except near these natural barriers where there are huge residuals due to smoothing over "zero density" areas, making the model wildly fail any kind of "goodness of fit" test despite the fact that the empirical density of the observed data agrees fairly closely with the empirical density of data simulated under the fitted model.
Here are the main possibilities I've considered (and why I've decided against them):

Delete these "natural barriers" from the window of observation and view this as a point process on a grid. I don't want to do this since it fundamentally changes the parameter you're estimating and, effectively, sweeps the "censoring" issue under the rug.
Bin the data into areal units (e.g. census-based groups), since this censoring infrequently crosses over census boundaries. This may be a good solution in some cases, but oversmoothing is a concern and, more importantly, the city I'm working with is too small (not enough census units) to do this.
Develop my own model for this. I'm pretty sure this is what I have to do but I wanted to check first that I'm not reinventing the wheel. Based on my own literature search, I'm not, but some specialists here may know something I don't..
Comment: (+1) Are these regions known and annotated as such in your data or do you have to "identify" them after the fact? Is it reasonable/sensible to estimate via a resampling approach, e.g., redistributing the points at random within the censored region? I can imagine how that might not be satisfactory either. Presumably the nature reserve would have well-travelled trails/paths.
Comment: Are you interested in covariate effects, or merely interested in estimating the intensity of the process (i.e. forecasting or fitting a causal model)? This is a fundamental limitation of the data, it doesn't occur just in parks, it occurs everywhere. The only paper I could think of related to where you might want to go is [Zimmerman (2008)](http://dx.doi.org/10.1111/j.1541-0420.2007.00870.x). Looking at the papers that have cited Zimmerman brings up [this article](http://projecteuclid.org/euclid.ba/1340369794) that might be of interest, although it appears more aimed at edge effects.
Comment: I am somewhat familiar with this literature and haven't seen this problem addressed in any reasonable way. The datasets I have had access to have been large, yet had so few values of this sort that it was easy to downweight them when fitting models and easy to overlook any high residuals.
Comment: Hi @whuber - can you please clarify what you mean by "downweight them when fitting models"? In regression-type models the meaning is clear but I'm a little confused what you mean in the context of a point process model.
Comment: Hi @cardinal, in a perfect world, I'd like to do this without knowing where these "regions" are, but I'm pretty sure that's not feasible. Perhaps they could be detected by observing many crimes in _exactly_ the same location. Hypothetically, data would exist to characterize these regions, such as street networks. Then, this could be viewed as a point process that was "pushed" onto the grid defined by the street networks. I like your suggestion and I may do something like that if I can't find an alternative that avoids the computational burden (these models take a good ~30 sec to fit, each).
Comment: Hi @Andy, I'm mainly interested in estimating covariate effects, but I need a well-fitting model so I can interpret them the way I want to. This kind of artificial clustering is discordant with a poisson process so I am concerned with "going to town" with my current analysis (but I have some reason to think it's a reasonable approximation). You are right that this is a fundamental limitation with this kind of data but I was thinking it could be like "missing" data in some sense and some EM-alg based approach could be reasonable. Thank you for the reference, btw, I haven't seen this one.
Comment: I've seen related permutation/allocation examples that cardinal mentions, although not quite in this context (I may just write up an answer when I get a chance). What is the spatial unit your interested in? A continuous field? Most covariates of interest to criminologists aren't measured like that either.
Comment: @AndyW, Yes, since I'm modeling this as a point process, space is continuous, not aggregated into areal units. There are reasons why aggregating into areal units is not such a great idea in these data. The main covariates of interest are continuously observed, in a sense - think densities of place-based features like certain types of businesses, etc. Although, I think you could incorporate "binned" predictors (like census-unit demographics) by viewing it as a continuously observed predictor that is constant within the pre-determined borders or by smoothing it across the area, right?
Answer: To start, this change in support problem is an active area of research, and so although it is usual to treat units of analysis in criminology as discrete, you can certainly make a case for treating it as a continuous field. Although I don't hold as such a negative view of using discrete units as you, I look forward to any further research and advances on the topic. I can see the hesitation to use larger areal units, like census block groups, but I don't have as much problem with smaller units like street segments or parcel units, which are becoming more popular in criminology all the time.
On its face, it seems the problem is related to edge effects (as you labeled the question as a censored point process), but it is a little different. Edge effects are typically handled by creating a weight for observed point process, and points near the edge of the study space are weighted higher. You have a process you observe though, but it is binned at a precision that doesn't suit your fancy.
This is very similar to the change of support problem, and attempts to solve it can be characterized as attempting to allocate the points (the suggestion) or by utilizing different techniques to take into the uncertainty in the aggregation. The dasymetric techniques listed are synonymous with the permutation/reallocation cardinal suggests in the comments. See the previous (two) answers of mine to a question of simulating similar outcomes. You can see examples of EM both for calculating ecological regressions, and for allocating estimates (see Tsutsumi & Murakami, 2012 - which is admittedly quite rough around the edges - as you can imaging by the title of the paper). The simulation approach you suggest is very similar to what Goovaerts (2008) suggests in his area-to-point kriging models.
I would note though, that there are areas that can be legitimately considered places that should be cut out of the window. For instance, although technically possible, you can assume the lake in the park is an area where no crime occurs. It also changes depending on the type of crime; burglary (as usually defined) can only occur in non-public areas, a public park can not be the victim of a burglary. Similarly if you wanted to fit a model of traffic accidents or DUI they are pretty much limited to actual roads. Most contemporary examples of crime forecasting though ignore this (and still produce estimates in areas where it is not possible to have a crime committed). Taking such places into account is what intelligent dasymetric mapping is all about.
Sorry, I believe there is no easy answer (and the best I can do is just provide a long list of literature that won't directly answer your question anyway).

As a sidebar, I'm not diametrically opposed to representing reality like this, but the examples you in the comments are obviously not measures that are continuous fields. The only continuous field I can think of that criminologists have been interested in is (unless you are a really persnickety physicist) weather related.
But, as perhaps always, how you go about representing the variables should be partly guided by what substantive questions you want answered. The continuous field approach to smoothing in the end confounds local and spatial spillover effects, and so is not reasonable to answer particular questions.
For example, if a concerned citizen came to me and said,

A parcel a block away, in a separate neighborhood group, was recently proposed to be rezoned to allow the sale of alcohol. Although it isn't in my neighborhood, I think my neighborhood should be allowed to vote on whether it is rezoned. Can you provide evidence if bars have an effect on crime not just where they are on the street, but a block away?

This answer can not be addressed with bars as a continuous density formulation in the model. But this can be by treating street blocks as units of analysis and fitting a spatial model to take into account bars not only on the local street, but on the neighboring street.
Comment: Thanks for this answer and for the references (+1) and for confirming my suspicion that I'll have to "make my own" to handle this problem. I agree that barriers like lakes - where crimes literally cannot happen - may be sensibly removed from the "space". Regarding your sidebar - obviously there are issues of interpretation but in a continuous space model like this (which I have good reasons for needing to do in this project), you have the practical consideration of needing to represent covariates continuously, so... Aside from that, there is literature regarding how alcohol outlet _density_,
Comment: not necessarily the location of a specific alcohol outlet, or the nearest outlet, or the number within a certain radius (etc...) affects the community atmosphere and the dynamics of the process you're studying. See, e.g. Gruenewald PJ. The spatial ecology of alcohol problems: niche theory and assortative drinking. Addiction. 2007;102(6):870–878. So, I think there is some validity to representing reality this way. Of course, you are right that for some particular research questions, this would not be useful or appropriate.
Answer: Censored spatial data is very common in the field of Cosmology. The issue is typically dealt with by creating a sample of random points with a flat distribution but that receives the same censoring as the data you are trying to model. Then, your analysis is adjusted by comparing effects seen in your data relative to effects seen in the random (but censored) data.
The classic estimator is one by Landy & Szalay, for the analysis of spatial clustering in real space (as opposed to Fourier space). Go here for the article
http://adsabs.harvard.edu/abs/1993ApJ...412...64L


When do three disks in the plane intersect?

Question: Suppose $ABC$ is a triangle with $|AB|=c$, $|BC|=a$, $|CA|=b$. Suppose further that $A,B,C$ are the centers of three disks with radii $r_A,r_B,r_C$, respectively.
Is there a sensible algebraic condition (inequality?) involving $a,b,c,r_A,r_B,r_C$ equivalent to the statement "these three disks have nonempty intersection"?
Comment: Seems like you should be able to do something with the law of cosines here...
Comment: One thing is clear that $r_A+r_B+r_C < \frac {a+b+c} {2}$ from the diagram.
Comment: @Dbchatto67 I think your inequality must be reversed
Comment: I think the concept of radical centre would be much useful here
Answer: Particular case when $r_a= r_B= r_C = r$. Then the quesition is when the triangle $ABC$ is contained in a circle of radius $r$. We know that the smallest  circle of radius $r_{\text{min}}$ containing $\triangle ABC$ is the circumscribed on if the triangle is not obtuse and the circle of diameter the largest side it the triangle is obtuse. Now the condition is $r \ge r_{\text{min}}$.
In general the condition is semialgebraic in $a$, $b$, $c$, $r_A$, $r_B$, $r_C$, obtained by elimination, although that could be rather involved.


Universal property of the tautological line bundle

Question: Let $X$ be a smooth, projective variety and $\pi:E \to X$ be a projective bundle of rank $r$ i.e., each fiber of $\pi$ is a projective space of dimension $r$. Let $F \subset E$ be a projective sub-bundle of $E$, over $X$ of codimension $1$ i.e., the fiber over each point of $\pi|_F$ is of dimension $r-1$. Then,
1) Is the pull-back of the tautological line bundle $\mathcal{O}_E(-1)$ to $F$, the tautological line bundle $\mathcal{O}_F(-1)$?
2) Is the line bundle associated to $F$, $\mathcal{O}_E(-F)$ isomorphic to the tautological line bundle $\mathcal{O}_E(-1)$?
Answer: Answer to (1) is yes:
It is better to use Grothendieck's convention (you have to dualize all the bundles and work with quotients and not with sub bundles) and the proof is clear (cfr. Hartshorne book):
If $Y$ is a variety. A map $g:Y\to{\Bbb P}(E)$ is a triple  $(f;L;j)$ where $f:Y\to X$  is a morphism, $L$ is a line bundle on $Y$ and $j:f^\ast(E)\to L$ is a surjection of vector bundles. Moreover, $g^\ast({\cal O}(1))=L$. In particular, if $p_E:{\Bbb P}(E)\to X$, you have a tautological surjection $p^\ast(E)\to {\cal O}(1)$.
Consequently, if you have a quotient $E\to F$ of $E$, then, since on $\Bbb P(F)$ you have a double surjection $p_F^\ast(E)\to p_F^\ast(F)\to \cal O(1)$, the conclusion follows.
Answer to (2) is NO:
If you have a quotient as before, you have an exact sequence
$$0\to N\to E\to F\to 0$$
and by adjunction you can verify that ${\cal O}_E(F)={\cal O}_E(1)\otimes p_E^\ast(N^\ast)$.


If $|R|=p$ where $p$ is prime, then its additive structure is cyclic. Moreover, every non-zero element in $R$ has a multiplicative inverse.

Question: Suppose $R$ is a commutative ring. Is the following statement true ? If $|R|=p$ where $p$ is prime, then its additive structure is cyclic. Moreover, every non-zero element in $R$ has a multiplicative inverse.
I suspect it is true but I have no idea how to prove it.
Answer: This is true. There is only one abelian group (indeed group) up to isomorphism of order $p$, it's the cyclic group by Lagrange's theorem. Now the multiplication is completely determined as the usual multiplication mod $p$ from the ring axioms
e.g. $m. n = (1 + \cdots +1).(1 + \cdots +1)$ (where the first has $m$ 1's and the second has $n$ 1's), and distributivity along with the identity law tellls you this equals $mn$ mod $p$.
Since every nonzero element has an inverse in the usual multiplication mod $p$, then this is true here too.
Comment: How do we know the additive structure is cyclic when the order of the group is prime? Why is cannot be multiplicative structure is cyclic?
Comment: This answer is valid for the case when $R$ has *unit*. Otherwise there is another example, the zero ring on $\Bbb Z_p$, in which every product is $0$.
Comment: Usually having a ring includes having the one [link](http://en.wikipedia.org/wiki/One_Ring) or [link](http://en.wikipedia.org/wiki/Ring_theory)
Comment: Does it has something to do with this theorem ? The characteristic of domain is either zero or prime. By the way, how do we rephrase this theorem into if-then statement?
Comment: Take a nonzero element of your ring (which exists, e.g. $1 \neq 0$ if we assume the ring has a unit. Call your chosen element $x$. The subset $ = \{ n.x | n \in \mathbb{N} \}$ is a subgroup of the additive group of your ring. By Lagrange's theorem its order must divide $|R| = p$. But It can't have only one elemnet as it includes at least $0$ and $x$. Therefore the subgroup is the whole group, so $R$ is cyclic, generated by $x$.
Comment: @Tom Harris: I'm not quite undestand your argument of every non-zero element has a multiplicative inverse. Can you elaborate ?
Comment: My argument says that the additive structure of the ring \textit{completely determines} the multiplicative structure (if we assume there is a 1). That is I have really shown that any ring with $|R|=p$ is isomorphic to $\mathbb{Z}/p\mathbb{Z}$. Since isomorphic rings are essentially the same, and every non-zero element of $\mathbb{Z}/p\mathbb{Z}$ has a multiplicative inverse, the same is true in $R$.
Comment: @TomHarris: So in this statement, there is only one group which satisfies it, that is $\mathbb{Z}_p$ where $p$ is prime?
Comment: Yes that's correct.


SignalR stops working in Xamarin.Forms Android app after migration of backend server and app to .NET Core 3.1 signalR

Question: I am working on migrating my website from ASP.NET Framework to ASP.NET Core, and have hit an issue in my final step of updating my Xamarin Forms app to connect with the migrated signalR on the backend.  I got my app migrated, everything worked in the emulators and on my physical device (LG V50 THINQ) via USB in Debug configuration, so I deployed my Release configuration APKs to Google Play.  However, when I went to install the app onto the same physical device from the Google Play store, signalR stopped working.
First, there appear to be no issues with the backend.  I'm not ruling it out completely, but what I have documented so far does not point to backend issues.  Also, to note, I am currently set up in my app to generate one package (.apk) per selected ABI.  The architectures I have been uploading to the Play Store up to this point are armeabi-v7a and arm64-v8a.
To track this down, I took the follow steps:

Ran my Release configuration on the emulator - WORKED
Ran my Release configuration from VS 2019 on device via USB - FAILED - Device log showed outbound call to signalR hub and signalR hub showed everything connected fine and tried to call device client as expected, but device log did not show that the inbound call from the signalR hub was successful.
Toggled settings in Release config to bring it in line with the Debug config until I found that toggling the following settings in the Android Options panel allowed the app to receive the call back from the signalR hub to work:

<code>    <DebugSymbols>true</DebugSymbols>
    <Optimize>false</Optimize>
</code>

I then tried uploading APKs to Google Play with these options set and deploying to device from Google Play - FAILED
At this point, I took a step back, copied the signed APK for armeabi-v7a directly to the V50 (the same APK I had uploaded to the Play Store) and installed the APK manually - WORKED
I uninstalled the armeabi-v7a APK, and then directly copied and manually installed the signed APK for arm64-v8a to the V50 - FAILED
I reverted Release config settings back to default, built and signed new APKs, and found that even under the original, default Release configuration armeabi-v7a WORKED and arm64-v8a FAILED.

So, I know two things:

On the V50 device, the 32-bit armeabi-v7a 32-bit APK works with signalR and the 64-bit arm64-v8a APK does not work with signalR under default Release configuration settings (but I still don't know why).
If I update the Release config settings as shown above for those two items (and both are required), I can debug on the V50 running the Release config straight from VS 2019, but those settings do not change behavior once deployed out as a signed APK.

At this point, I am stumped.  Feels like an issue with 64-bit vs 32-bit, but don't have any breadcrumbs to point me where I should look next.  Anyone have any leads for me to follow?
Answer: OK, finally found the apparent culprit.  Had to disable "Use LLVM Optimizing Compiler" and signalR started working with arm64-v8a.
Comment: Where is this option?


Evaluating $\int_0^{\infty} \log(\sin^2(x))\left(1-x\operatorname{arccot}(x)\right) \ dx$

Question: One of the ways to compute the integral
$$\int_0^{\infty} \log(\sin^2(x))\left(1-x\operatorname{arccot}(x)\right) \ dx=\frac{\pi}{4}\left(\operatorname{Li_3}(e^{-2})+2\operatorname{Li_2}(e^{-2})-2\log(2)-\zeta(3)\right)$$
is to make use of the series of $\log(\sin(x))$, but the result I got after doing that wasn't that friendly.
Is it possible to find a neat way of evaluating the integral?
Comment: Noting that the Fourier transform of $x\mapsto(1-x\, {\rm arccot}( x))$ is given by $\omega\mapsto\dfrac{1-(1+|\omega|)e^{-|\omega|}}{\omega^2}$ the result follows from what I called "The mixed Parceval-Plancherel Formula", in http://arxiv.org/abs/1312.0464. This will be published in The Journal of Classical Analysis.
Comment: @OmranKouba Oh, that's really interesting! Thank you for the paper.
Comment: @OmranKouba I feel the need to mention that the Example 3.2 in the paper is exceptionally nice.
Comment: Yes, thank you, I think so too.
Answer: First notice that
$$ \begin{align} &\frac{1}{2} \int_{0}^{\infty} \log (4 \sin^{2} x) \Big(1 - x \, \text{arccot}(x) \Big) \, dx \\ &= \frac{\log(4)}{2} \int_{0}^{\infty} \Big( 1- x \, \text{arccot}(x) \Big) \, dx + \frac{1}{2} \int_{0}^{\infty} \log (\sin^{2} x) \Big(1 - x \, \text{arccot}(x) \Big) \, dx \\ &= \frac{\pi \log(2)}{4} + \frac{1}{2} \int_{0}^{\infty} \log (\sin^{2} x) \Big(1 - x \, \text{arccot}(x) \Big) \, dx . \tag{1} \end{align}$$
Now use the fact $$ \text{Re} \log(1-e^{2ix}) = \frac{1}{2} \log(4 \sin^{2} x) $$
and integrate by parts to get
$$ \begin{align} &\frac{1}{2} \int_{0}^{\infty} \log (4\sin^{2} x) \Big(1 - x \, \text{arccot}(x) \Big) \, dx \\ &= \text{Re} \int_{0}^{\infty} \log (1-e^{2ix}) \Big(1- x \, \text{arccot}(x)  \Big) \, dx \\ &= \text{Re} \, \Big(1- x \, \text{arccot}(x)  \Big) \frac{i \, \text{Li}_{2}(e^{2ix})}{2} \Bigg|^{\infty}_{0}- \text{Re} \, \frac{i}{2} \int_{0}^{\infty} \left(\frac{x}{1+x^{2}} - \text{arccot}(x) \right) \text{Li}_{2} (e^{2ix}) \, dx \\ &= 0 + \frac{1}{2} \int_{0}^{\infty} \Big(\frac{x}{1+x^{2}} - \text{arccot}(x) \Big) \sum_{n=1}^{\infty} \frac{\sin({\color{red}{2}}nx)}{n^{2}} \, dx \\  &= \frac{1}{2} \sum_{n=1}^{\infty} \frac{1}{n^{2}} \int_{0}^{\infty} \Big(\frac{x}{1+x^{2}} - \text{arccot}(x) \Big) \sin (2nx) \, dx \\ &= \frac{1}{2} \sum_{n=1}^{\infty} \frac{1}{n^{2}} \left(-\frac{\pi}{4n} + \frac{1}{n} \int_{0}^{\infty} \frac{\cos(2nx)}{(1+x^{2})^{2}} \, dx \right) \tag{2} \\ &= \frac{1}{2} \sum_{n=1}^{\infty} \frac{1}{n^{2}} \Big(-\frac{\pi}{4n} + \frac{1}{n} \frac{\pi}{4} e^{-2n} (2n+1) \Big) \tag{3} \\ &= - \frac{\pi}{8} \sum_{n=1}^{\infty} \frac{1}{n^{3}} + \frac{\pi}{4} \sum_{n=1}^{\infty} \frac{e^{-2n}}{n^{2}} + \frac{\pi}{8} \sum_{n=1}^{\infty} \frac{e^{-2n}}{n^{3}} \\ &= -\frac{\pi}{8} \zeta(3) + \frac{\pi}{4} \text{Li}_{2}(e^{-2}) + \frac{\pi}{8} \text{Li}_{3} (e^{-2}). \end{align}$$
Therefore,
$$ \int_{0}^{\infty} \log (\sin^{2} x) \Big(1 - x \, \text{arccot}(x) \Big) \, dx = \frac{\pi}{4} \Big(\text{Li}_{3} (e^{-2}) + 2 \text{Li}_{2}(e^{-2}) -2 \log(2) - \zeta(3) \Big).$$
$ $
$(1)$ Simple Integral $\int_0^\infty (1-x\cot^{-1} x)dx=\frac{\pi}{4}$.
$(2)$ Integrate by parts again.
$(3)$ There is probably a question on here about evaluating $\int_{0}^{\infty} \frac{\cos(ax)}{(1+x^{2})^{2}} \, dx$, but I can't find it at the moment. The most direct approach is to use the residue theorem. You could also use the fact that $\int_{0}^{\infty} \frac{\cos (ax)}{b^{2}+x^{2}} \, dx = \frac{\pi}{2b} e^{-ab} \, , \,  (a \ge 0,b > 0) $ and differentiate both sides with respect to $b$.
Comment: Good job! (+1) :-)
Answer: We start with: $\displaystyle \int_0^1 \frac{t^2}{x^2+t^2}\,dt = 1-x\tan^{-1}\frac{1}{x}$
Then,
$\displaystyle \begin{align} \int_0^{\infty} \log (2\sin x)\left(1-x\tan^{-1}\frac{1}{x}\right)\,dx &= \int_0^{\infty}\int_0^1 \frac{t^2\log (2\sin x)}{t^2+x^2}\,dt\,dx\\&= -\sum\limits_{n=1}^{\infty} \int_0^1 t^2\int_0^{\infty} \frac{1}{n}\frac{\cos 2nx}{t^2+x^2}\,dx\,dt\tag{1}\\&= -\frac{\pi}{2}\sum\limits_{n=1}^{\infty} \frac{1}{n}\int_0^1 t^2\frac{e^{-2nt}}{t}\,dt\\&= -\frac{\pi}{2}\sum\limits_{n=1}^{\infty} \frac{1}{n}\left(\frac{1}{4n^2} - \frac{e^{-2n}}{4n^2} - \frac{e^{-2n}}{2n}\right)\\&= -\frac{\pi}{2}\left(\frac{1}{4}\operatorname{Li}_3(1)-\frac{1}{4}\operatorname{Li}_3(e^{-2})-\frac{1}{2}\operatorname{Li}_2(e^{-2})\right)\end{align}$
where, we used: $\displaystyle \int_0^{\infty} \frac{\cos ax}{b^2+x^2}\,dx  = \frac{\pi e^{-ab}}{2b}$ in $(1)$.
Combining with the fact that: $\displaystyle \int_0^{\infty} \left(1-x\tan^{-1}\frac{1}{x}\right)\,dx = \frac{\pi}{4}$ we get the desired result.


Why are functions indexable in Python but not PHP?

Question: I don't mean for this question to be about Python vs PHP but about languages in general.  I use Python and PHP as examples because I know them.
In Python we can do mytoken = mystring.split(mydelimiter)[1], accessing the list returned by str.split without ever assigning it to a list.
In PHP we must put the array in memory before accessing it, as in $mytokenarray = explode($mydelimiter, $mystring); $mytoken = $mytokenarray[1];.  As far as I know it is not possible to do this in one statement as in Python.
What is going on behind this difference?
Comment: Functions are not indexable in any language that I've ever heard of. You mean "expressions".
Comment: possible duplicate of [Parse error on explode('-','foo-bar')\[0\] (for instance)](http://stackoverflow.com/questions/2396782/parse-error-on-explode-foo-bar0-for-instance)
Comment: Yes, it is basically a duplicate of that question.
Comment: [Array Dereferencing is in trunk now](http://schlueters.de/blog/archives/138-Features-in-PHP-trunk-Array-dereferencing.html)
Comment: There are a lot of false assumptions in the question. The example is not indexing the function. It is indexing the return value of the function. In PHP assigning a variable to a value does not "put the array in memory before accessing it". The array is already in memory.
Answer: It is a design decision the authors of the languages chose to make. Generally spoken (and this is of course not always the case) the nicer the syntax a language has the slower it tends to be. Case in point: Ruby.
Comment: This makes no sense.  For any compiled language, of course, the syntax disappears at runtime.  And for interpreted languages—well, take Ruby.  A source file is loaded and parsed *before* it is run, so even if parsing *were* much slower (something I'm not convinced of), this would only be a problem *once per file*.  And PHP here is not making things "nicer", just less regular.
Comment: I wonder if it's more to the point to say that the nicer the syntax is the more difficult the compiler is to write.
Comment: Niceness is a complicated thing. Some of it won't affect neither compiler nor speed, some will affect compiler complexity (affecting speed of interpreted languages) and some will affect runtime performance. Examples: I'd imagine that not requiring semicolons at the end of lines won't affect complexity nor performance since you just use the `\n` instead of `;`. Not requiring type declarations in a statically typed language increases compiler complexity since it has to infer the types. Dynamically typed languages are slower at runtime because method calls must be looked up at runtime.
Answer: If you try to do this in php
$mytokenarray = explode($mydelimiter, $mystring)[1];

notice the error you get: Parse error: syntax error, unexpected '['.
This means that php is getting upset when it tries to parse the code, not when it tries to execute it. I suspect that means that php's grammar (which, I hear rumored, is generated on the fly though I really have no idea) says that you can't put '[' after a statement or expression or whatever they call it. Rather, you can probably only put '[' after a variable.
Here's Python's grammar. http://docs.python.org/reference/grammar.html which contains the rule trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME From there you can see that trailer is part of atom which can also contain [. You're starting to get the picture that it's pretty complicated.
Blah blah blah, long story short, learn about compilers, or even better, write one for a toy language. Then you will have loads of insight into language quirks.
Comment: Or, put more controversially: PHP's grammar is very weird/full of special cases. In sane languages, referencing a variable is just another expression...
Answer: This feature is now possible with PHP as of version 5.4.


Entity Malformation Exception Error

Question: When I try to access some specific pages, I get the following errors in my log, one after the other:

Notice: Trying to get property of non-object in ds_field_formatter_view() (line 1233 of /var/www/sites/all/modules/ds/ds.module).

Followed by

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7729 of /var/www/includes/common.inc).

And the page serves the following error:

Error
  The website encountered an unexpected error. Please try again later.

I had the modules taxonomy and taxonomy manager enabled. I disabled taxonomy manager, but no effect. I wanted to disable taxonomy too, but could not because there was a field with data in it. This has made almost 44 pages of the site with good content in accessible, so any help will be greatly appreciated.
Answer: The error was happening due to the fact that database records where not removed when a taxonomy term reference field was deleted. The solution was to install taxonomy orphanage module which removes such references.
Comment: To make the taxonomy orphanage module effective, one has to go to `/admin/structure/taxonomy/orphanage` and click "Round up". This can be set to be done by cron, but is not done automatically on module installation.

Entity Malformation Exception Error


Find the inverse of the following linear map.

Question: Find the inverse of the linear map
$φ:ℝ_3[t]\toℝ_3[u], at^2+bt+c\mapsto (a+c)u^2+(b+c)u+(a+b)$
I know I need to take an arbitrary element in $ℝ_3[u]$ and solve $φ(at^2+bt+c)=xu^2+yu+z$.
But now I am completely blank and have no clue what to do, or how to solve this.
Thanks in advance.
Comment: @MrCroutini You have the equation $(a + c)u^2 + (b + c)u + (a + b) = xu^2 + yu + z$. Two polynomials are equal only when their coefficients are equal. So you have the system of equations $a + c = x, b + c = y, a + b = z$. Now solve this system for $a, b, c$ (sorry, I should have said solve for $a, b, c$ before). For example eq1 + eq3 - eq2 gives $(a + c) + (a + b) - (b + c) = x + z - y \implies a = \frac{1}{2}(x + z - y)$.

Once you solve for $a,b,c$, you can write down the formula for the inverse as $\varphi^{-1}(xu^2 + yu + z) = at^2 + bt + c$ you know the coefficients in terms of $x, y, z$.
Comment: Try writing down a matrix representation of the map and then inverting the matrix.
Comment: How would you do that? They're polynomials.
Comment: The last equation should be "$\varphi( ...$" not "$\varphi_2( ...$". And what is $\varphi(at^2 + bt + c)$? According to the definition the equation becomes $(a + c)u^2 + (b + c)u + (a + b) = xu^2 + yu + z$. Now you should be able to solve for $x, y, z$. Alternatively, you can use matrices as suggested by mtiano which are useful when the system of equations you obtain are more complicated.
Comment: Sorry, $φ_2$ was a typo.
Comment: @MrCroutini In order to solve it using matrices, you first need a basis. For example $\beta = \{1, t, t^2\}$ and $\gamma = \{1, u, u^2\}$. Then you can get a vector representation of the polynomial $at^2 + bt + c$ as $(c, b, a)^T$. You can also get the matrix representation of $\varphi$ and you last equation becomes a matrix equation.
Comment: @PratyushSarkar, how do I solve for x,y,z?
Comment: Yes, thank you! I understand now! :)
Answer: As suggested in the comments, we can use $\beta=\{1,t,t^2\}$ and $\gamma=\{1,u,u^2\}$ as bases for the vector spaces, and then the matrix of $\phi$ with respect to these bases is given by
$\begin{bmatrix}[\phi(1)]_{\gamma}&[\phi(t)]_{\gamma}&[\phi(t^2)]_{\gamma}\end{bmatrix}$ where $\phi(1)=u^2+u$, $\phi(t)=u+1$, and $\phi(t^2)=u^2+1$.
Therefore the matrix is given by $A=\begin{bmatrix}0&1&1\\1&1&0\\1&0&1\end{bmatrix}$, and then $A^{-1}=\frac{1}{2}\begin{bmatrix}-1&1&1\\1&1&-1\\1&-1&1\end{bmatrix}$ will be the matrix representing the inverse of
$\phi$ with respect to these bases.


push a viewcontroller(C) from uitabbarcontroller,C leave a white blank on bottom,but disappear after a while

Question: The UITabbarController have serveral embedded UINavigationControllers.
look at this pic
Layout Pic

When I push another ViewController,look at this pic
Problem Pic

I don't know how to solve this problem.
Comment: I checked "Hide Bottom Bar on Push" at storyboard.
Comment: can you use a modal segue to present the view Controller C ?
Answer: <code>- (BOOL)hidesBottomBarWhenPushed{ return YES; }
</code>
use this code, the problem solved,don't hide by storyboard,I don't know why...
Comment: self.tabBarController.tabBar.translucent = NO; solved
Comment: try to comment that an see the changement of your views frame in viewDidLayoutSubviews you will understand
Comment: still have white blank on bottom,and disapper after a while.
Comment: yes I didn't say it to solve the problem but to make you understand why it get solved by himself , when your app load the view , it load the view with its constraint modified by the buttonBar , but when it finally get hidden by your setting , the problem get solved you can see the update in ViewDidLayoutSubViews . What you have done is force the modification before the view get set , and the reason why there is a problem is TIMING .
Comment: e,but can you tell me how can I do to solve this problem,please,this problem puzzle me a whole day.
Comment: you did it right I just explained the reason of the problem


Limit behaviour for solutions of $y'=-(1/x) y-(1/x^3)\cos(1/x)$

Question: The ODE $$y'=-\frac1x y-\frac1{x^3} \cos\left(\frac1x\right)$$
has as its set of solutions defined on $(-\infty,0)$ the functions
$$y_C:(-\infty,0)\to\mathbb{R},~~~y_C(x):=\frac1x\left(C+\sin\left(\frac1x\right)\right).$$ If $C\not=0$ we see by choosing $x_k:=-\frac1{\pi k}$ that $\lim_{k\to\infty} y_c(x_k)=-\text{sign}(C)\cdot \infty$. For $C=0$ we may choose $x_k'=-\frac1{(2k+1/2)\pi}$   to get $\lim_{k\to\infty}y_0(x_k') =\lim_{k\to\infty}(-\frac1{x_k})=\infty$.
In this case ($C=0$) much more can be shown:

For each real $b$ there is a sequence $(b_n)$ of negative numbers tending to $0$ such that $\lim_{n\to\infty} y_0(b_n)=b$.

To this aim let $z_n:=-\frac1{(n+1/2)\pi}$. Then $z_n<z_{n+1}$ and $\lim_{n\to\infty} z_n=0$. Morover let $f(x):=\sin(1/x)-b x$. Obviously $f(x_{2n})=-1-b x_{2n}$ and $f(x_{2n+1})=1-b x_{2n+1}$. For large $n$ ($\vert b\cdot x_{2n}\vert<1$) this implies $f(x_{2n})<0$ and
 $f(x_{2n+1})>0$. Thus there is some $b_n\in(x_{2n},x_{2n+1})$ such that $f(b_n)=0$, i.e., $y_0(b_n)=b$. This trivialy implies $\lim_{n\to\infty }y_0(b_n)=b$
For $\vert C\vert>1$ there is no sequence of $z_n<0$ converging to $0$ such that $y_C(z_n)$ converges to some real number since otherwise we would have $\lim_{n\to\infty} (C+\sin(1/z_n))=0$, implying $C\in[-1,1]$.

Question: Given $\vert C\vert\leq 1$ what are the points $b$ with $\lim_{n\to\infty } y_C(z_n)=b$ for some sequence of negative reals $z_n$ converging to $0$?
Comment: DERIVE says ∂(1/x·(c + SIN(1/x)), x)=- COS(1/x)/x^3 - SIN(1/x)/x^2 - c/x^2 and - 1/x·(1/x·(c + SIN(1/x))) - 1/x^3·COS(1/x)=- COS(1/x)/x^3 - SIN(1/x)/x^2 - c/x^2, i.e. *it is a solution!*
Comment: Applying the integrating factor $x$ gives $$(xy(x))'=-x^{-2}\cos(x^{-1}).$$ Now $(\sin(x^{-1}))'=\cos(x^{-1})(-x^{-2})$ so that indeed $xy(x)=C+\sin(x^{-1})$, which gives exactly the expression for $y_C$.
Answer: For $|C|<1$ the same applies as for $C=0$, since the minima of $C+\sin(1/x)$ are negative and the maxima positive, so each up and down-swing of $y_C$ covers an increasingly large interval around $0$ the closer you get with $x$ to $0$.
For $C=1$ the minima of $C+\sin(1/x)$ are exactly $0$, so that the oscillations only reach negative values, for $C=-1$ the oscillations only reach positive values.
Comment: Very nice. *Comment to the case $C=1(-1)$:* Since $x<0$ the range of oscillation probably should be reversed.


Function to toggle Boolean value in spreadsheet cell

Question: I want this function to toggle the Boolean value in cell D38 from true to false, or from false to true.
function changeState() {
  var a=SpreadsheetApp.getActiveSheet().getRange('D38');
  a=!a;
  SpreadsheetApp.getActiveSheet().getRange('D38').setValue(a);
};

It's not currently doing what I want: It will convert a TRUE to FALSE, but will not convert a FALSE to TRUE no matter what.
Why is it behaving like this, and how do I fix it?
Comment: Do you have anything in your JavaScript console?
Comment: You're likely going to need to post a link to a fiddle or to your code -- there's not enough information here to diagnose your problem.

a = !a should work to flip the value whether you're dealing with a string 'true' or a proper boolean.
Comment: Welcome to Stack Overflow! If one of the answers below are helpful, please click the accept checkmark on the best one to the left of the answer. Otherwise, comments about the answer are appreciated!
Answer: From the documentation, getRange returns an object of type Range. The problem is that !a is negating the truth value of this object, not the value stored in the cell. So regardless of what the actual value is stored within that cell this will always return false (unless a is null).
You need to get the actual value from the cell using the appropriate getValue / setValue methods:
function changeState() {
   var a = SpreadsheetApp.getActiveSheet().getRange('D38');
   var value = a.getValue();
   value = !value;
   a.setValue(value);
};

Or more simply:
function changeState() {
   var a = SpreadsheetApp.getActiveSheet().getRange('D38');
   a.setValue(!a.getValue());
};


Largest k for $\displaystyle (a+b+c)^5 \ge\frac{k}{\sqrt{5}}(ab+bc+ca)(a-b)(b-c)(c-a)$

Question: The following problem ate up my mind , If $a,b,c$ are distinct non-negative real numbers then find the largest value of the constant $k$ auch that the following inequality is satisfied,
$\displaystyle (a+b+c)^5 \ge \frac{k}{\sqrt{5}}(ab+bc+ca)(a-b)(b-c)(c-a)$
Comment: i would write$$\frac{(a+b+c)^5\sqrt{5}}{(ab+bc+ca)(a-b)(b-c)(c-a)}\geq k$$
Comment: @Dr.SonnhardGraubner that would not be an equivalent restatement as the denominator can be negative.
Answer: I think it's better to find a maximum value of $k$ for which an inequality
$$(a+b+c)^5\geq k(ab+ac+bc)(a-b)(b-c)(c-a)$$
is true for all non-negatives $a$, $b$ and $c$.
The answer is $25\sqrt5$.
Indeed, we can assume $k>0$ and $a\geq c\geq b$ and since
$(ab+ac+bc)(a-b)(a-c)(c-b)\leq(a-c)a^2c^2$ it's $(a-c)(a^2+ac+c^2-ab-bc)\geq0$,
it remains to find a maximal value of k, for which the inequality
$$(a+c)^5\geq k(a-c)a^2c^2$$
is true for all non-negatives $a$ and $c$ such that $a\geq c$.
It's enough to take $a>c>0$.
Let $a=xc$.
Hence, $x>1$ and $k_{max}=\min\limits_{x>1}\frac{(x+1)^5}{x^2(x-1)}=25\sqrt5$.
The last statement is obvious by AM-GM.
Comment: How do you show that the answer is $ 25\sqrt5$?
Comment: @GohP.iHan I fixed my post for you.
Comment: Please help me understand the lines $(ab+bc+ca)(a-b)(a-c)(c-b)\le (a-c)a^2c^2$ and from here to $(a+c)^5 \ge k(a-c)a^2c^2$
Comment: @Aditya Narayan Sharma if we'll prove that $(a+c)^5\geq k(a-c)^2a^2c^2$ so $(a+b+c)^5\geq(a+c)^5\geq k(a-c)^2a^2c^2\geq k(ab+ac+bc)(a-b)(a-c)(c-b)$


What do the different tubes in an amplifier do?

Question: Preamp vs Phase Inverter vs Reverb vs Power vs Rectifier.
Many people get really, really confused when they try to understand anything about tubes. I spent a very long time myself trying to understand it enough to be able to perform basic maintenance and tweak the tone of my amplifier. So, the question for the community would be this:
What do the different tubes in an amplifier do? How does each tube affect the amplifiers tone?
Answer: The pre-amp valves do exactly that; they pre-amplify the signal from you guitar to a level high enough to be consumed by the power valves; tone adjustable's such as EQ, pre-amp gain and presence are all part of the pre-amp section, this is all done with analogue circuitry and the pre-amp valves amplify and apply gain to the result of you dialling your tone in.
The power amp valves then take this signal and 'really' amplify it; usually the more driven the amp (the louder you crank it), the more the power amp valves affect the tone, generally the more you crank the more break up/distortion/wideness of sound you get from the amp; the choice of power amp valve has a huge effect on this.
The rectifiers takes alternate current(AC) and convert it to the direct current(DC) required by the valves.
Check out this article The Secret life of valves
Comment: And phase-inverters flip the signal 180 degrees, so when the signal is at its peak coming in, it's at its bottom exiting the circuit. This is useful for providing negative-feedback to the circuit, helping tighten the sound.
Answer: DRL's answer is a good summary of pre-amp/power-amp/rectifier tubes.  Here are some specific examples of tubes used and how they affect tone.
For the pre-amp, far and away the most popular tubes used are 12AX7's, although sometimes you see 12AT7's used to drive the reverb or effects loop (if the amp has these features).
For the power amp section, the tubes used fall into two camps:

6V6 & 6L6: Fender is known for using 6V6's in their smaller amps and 6L6's in their larger amps.  Either way, these tubes have a lot of clean headroom, so you get more volume from the amp before they start to distort.  When they do break up, however, the sound can sometimes be a bit harsh.
EL34 & EL84: Marshall is known for using EL34's and EL84's in their heads.  These have less clean headroom, so they'll distort at lower volumes, but the distortion is usually warmer and smoother.

This explains why, historically speaking, Fender amps were/are popular with country/western guitarists who wanted a cleaner tone, while Marshall heads were/are often used by rock musicians wanting a great distorted tone (as with all generalizations, of course, there are exceptions).
Another factor involving tubes and tone include whether the power amp uses a Class A or Class A/B circuit design.  A Class A design is typically less efficient and thus produces less volume, but with (subjectively, of course) better tone.  Vox amps and smaller Fender tube amps often are Class A.  Class A/B amps get more volume due to greater efficiency, but their sound isn't quite as sweet.  Larger Fender amps and Marshall amps are usually Class A/B.
Finally, a hybrid amp will typically use tubes for the pre-amp section, but a solid-state power amp.  The idea here is to use tubes for the portion of the amp that affects the tone the most, and then save money and weight in the power amp section, which is designed to be as clean as possible.  Of course, these amps can't provide the really wonderful power-amp distortion of a great all-tube head set to 11, but that's the trade-off.
Comment: Just reading this makes me want to go and turn my (1970 Marshall) right up and hear all the stuff you've mentioned dripping out of the speaker. Great info !