Energy functional and Euler Lagrange equation

Question: We know that for potential energy functional, its derivative is called the Euler Lagrange equation and physically, it means that at the given point there is a force balance. Now if the energy functional is not convex, it could also have local maxima, which also indicates force balance. But physically, we want to minimize the energy, so what do the maxima mean for the energy functional? It seems that the maxima also solve the Euler Lagrange equation, which means that is a force balance. But why is it physically not correct?
Comment: Why incorrect? Think of the inverted pendulum that is positioned at its upper equilibrium point. It has the force balance and the maximum potential energy. But it is unstable, so with the smallest deviation it falls down to the stable minimum energy point.
Answer: As A.G. stated, the (strict) local maxima of potential energy are unstable equilibria.  E.g., a ball at rest at the top of a sphere, or a pendulum balanced at its highest position. These can't be sustained in reality, due to inevitable perturbations (air motion, etc).
A non-strict local maximum may happen to be neutrally stable if the potential energy is constant in its neighborhood (i.e., this local maximum is also a local minimum). This is an idealized scenario, like a ball resting on a perfectly flat and perfectly horizontal surface.
Comment: Thank you for your comments! And do also the saddle points have their properties in physics? Or are they also unstable points like the local maximas?


React Redux - element not rendering on page but React not throwing error

Question: I seem to be having an issue with my react-redux app. I'm currently using next.js, which tends to act a little weird when working with redux so i'm not sure if that's the issue. That said, I'm trying to render a component that loops through an array of objects. very simple. my mapState function is working and when I set info to state.aboutMe[0] i received the first value. Once I remove this and try to iterate through the array, Initially, I got an error that says "A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object." but I was able to resolve that by wrapping my my info.map in a
 el.
I checked out the other questions and refactored my function in a class that extends the React.Component class but still no luck with iterating. In that case, it just prints nothing to the screen. I've added that code at the bottom as well. Please let me know if I can clear anything up. Thanks in advance!
// This code IS working
// Needed to wrap inner return statement in JSX
const heading = ({info}) => {
    console.log(info);
    return (

{
    info.map(x => {
    return (

{x.title}

    )
    })
  }

  )
  }

  // Same code without inner return
  const heading = ({info}) => {
    console.log(info);
    return (

      {
        info.map(x => (

{x.title}

          )
        )
      }

  )
}

// prints info in console
    const heading = ({info}) => {
   console.log(info);
  return (

{
    info.map(x => {

{x.title}

    })
  }

  )
}

const mapState = state => ({ info: state.aboutMe })
const Heading = connect(mapState)(heading);

// EXAMPLE WITH CLASS
// Prints nothing to the screen but doesnt throw error
class homePage extends React.Component {
  render() {
    const { info } = this.props;
    console.log(info);
    return (

 {
      info.map(x => {

{x.title}

{x.text}

      })
      }

    )
  }
}
const mapState = state => ({ info: state.aboutMe })
const Heading = connect(mapState)(homePage);

Comment: Your anonymous arrow function doesn't return anything. Once you use curly-braces you lose the implicit return. It doesn't throw an error because there's no error. Unrelated, but I'd make a tiny component for the title so you end up with this: https://gist.github.com/davelnewton/1214c9bb3f7103ff3d0264a95892c999
Answer: should be
return (

    {info.map(x => (

{x.title}

{x.text}

)
    )}

)

because the div inside the map isn't really being returned
Comment: @ThomasGreco I've updated the code. There should be no {} inside the map function
Comment: this is throwing an error `SyntaxError: Unexpected token`. I believe it's due to JSX having one parent element.
Comment: wow! awesome, that worked. i understand what you're saying but i'm going to update the example with brackets and without so people can see.
Comment: where do i do that at ?
Comment: here. you should see a check mark at the left side of the answer.
Comment: lol yes, i meant where in this page but appreciate the clarification. got u
Answer: Try explicitly using a return inside map.


Jade template inheritance block content not working

Question: I have layout.jade:
html
include includes/head
body
 header
  h1 Jumplink design
  p web design+creative solutions
 include includes/nav
    block content

and my about.jade which is supposed to extend the layout gets parsed but nothing shows.
extends layout

block content
h3 About me

In my navigation, I have a link to about.jade.I don't know what's going on, nothing works.
Comment: Ok, I m really a Linux newbie. The problem was my file permissions of the folder where the views are.oops..
Answer: I wish I could close this question. The problem was that my file permissions where not the same on all the files.


Test for significant differences on gender between two groups in R

Question: I need to compare the significance of Gender between the two groups.
Here is the table:
df <- data.frame(No = c(1:15),
                 Group = sample(1:2, 15, replace=T),
                 Gender = sample(c("F","M"), 15, replace=T))

Ge_M <- df %>%
  filter(Gender == "M") %>% group_by(Group) %>%
  summarise(Value = n()) %>%
  pull(Value)

Ge_F <- df %>%
  filter(Gender == "F") %>% group_by(Group) %>%
  summarise(Value = n()) %>%
  pull(Value)

t.test(Ge_M, Ge_F)

Output :
Welch Two Sample t-test

data:  Ge_M and Ge_F
t = -0.82199, df = 1.0555, p-value = 0.5561
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -36.65746  31.65746
sample estimates:
mean of x mean of y
      2.5       5.0

Question:
Am I using it in the right way? I want to know if I have significant a difference between the two groups but the output seems not what I want.
What's the right method to do the test?
Thank you!
Comment: You have many zeros in your data. What is the explanation for them? Looking at the data I have doubts that the assumptions of a t-test are sufficenctly fulfilled.
Comment: Using your code it works for me,
`data: Value and Group
F = 2.6127, num df = 1, denom df = 18, p-value = 0.1234.`
Answer: Answer to the current version
It is not clear to me what you are trying to do here since the new df misses the response (see below). But one critique may be that you may want to check for the homoscedasticity assumption first, using say var.test or any other test for equality of variances. And if the homoscedasticity assumption cannot be rejected, then you can use a t-test with var.equal = TRUE.
Answer to the original version of the post
The problem here is with the use of df which is an R function (df computes the density of an F distribution, run ?df to check it). Using another name, say dd, fixes the issue. Note that in the case of two groups, you can also use the $t$-test.
dd <- read.table("data.txt", header = F,row.names = 1)
names(dd) <- c("ID", "group", "value")
str(dd)

 > oneway.test(value ~ group, data = dd, var.equal = TRUE)

    One-way analysis of means

data:  value and group
F = 2.6127, num df = 1, denom df = 18, p-value = 0.1234

# or the equivalent version via t-test
 > with(dd, t.test(value~group, var.equal = TRUE))

    Two Sample t-test

data:  value by group
t = -1.6164, df = 18, p-value = 0.1234
alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0
95 percent confidence interval:
 -8.580329  1.118425
sample estimates:
mean in group 1 mean in group 2
       2.385714        6.116667

Remark Furthermore, as also highlighted in the comments by Roland, value under group 1 has many zeros, i.e.
> with(dd, table(value[group == 1]))

   0    2  4.3  6.6  8.3 12.2
   9    1    1    1    1    1

This casts doubts on the normality of such a variable and thus the p-value of the t-test (or ANOVA) may not be correct.


Reset text field on ajax submit

Question: My code is not resetting the field back to nothing:

Reset text field on ajax submit


Getting "No input file specified." when trying to set up PHP-FPM under Apache 2.4 (Windows)

Question: I'm not having success in setting up PHP-FPM in a specific folder of Apache 2.4 HTTP server.
I've tried to use all three ways to set up PHP-FPM like in this question but all of them resulted in "No input file specified."
I already have PHP 5.6 running as a module in Apache 2.4 server (Windows).
I would like to upgrade PHP to 7.3.4 for all applications on the server but many of them are not currently ready for this. The decision was to have two PHP versions running at the same time.
PHP 5.4.60 will continue to run as a Apache 2.4 module
PHP 7.3.4 will run as PHP-FPM for specific folder 'd:/www/htdocs/php7/'
I have already run PHP-FPM with:
<code>php-cgi -b localhost:8734
</code>
(I have also used -C option in the command above but result did not change)
Extract of httpd.conf:
<code>    <VirtualHost *:80>
        DocumentRoot "d:/www/htdocs/"
        <Directory "d:/www/htdocs/php7/">
            <Files ~ "\.(php|phtml)$">
                SetHandler "proxy:fcgi://localhost:8734/"
            </Files>
        </Directory>
    </VirtualHost>
</code>
Apache error log shows (among other 'sending env var' lines):
<code>    [proxy:debug] [pid 1308:tid 760] mod_proxy.c(1246): [client 10.16.32.48:49607] AH01143: Running scheme fcgi handler (attempt 0)
    [proxy_ajp:debug] [pid 1308:tid 760] mod_proxy_ajp.c(739): [client 10.16.32.48:49607] AH00894: declining URL fcgi://localhost:8734/D:/www/htdocs/html/phpinfo.php
    [proxy_fcgi:debug] [pid 1308:tid 760] mod_proxy_fcgi.c(1019): [client 10.16.32.48:49607] AH01076: url: fcgi://localhost:8734/D:/www/htdocs/html/phpinfo.php proxyname: (null) proxyport: 0
    [proxy_fcgi:debug] [pid 1308:tid 760] mod_proxy_fcgi.c(1028): [client 10.16.32.48:49607] AH01078: serving URL fcgi://localhost:8734/D:/www/htdocs/html/phpinfo.php
    [proxy:debug] [pid 1308:tid 760] proxy_util.c(2317): AH00942: FCGI: has acquired connection for (*)
    [proxy:debug] [pid 1308:tid 760] proxy_util.c(2371): [client 10.16.32.48:49607] AH00944: connecting fcgi://localhost:8734/D:/www/htdocs/html/phpinfo.php to localhost:8734
    [proxy:debug] [pid 1308:tid 760] proxy_util.c(2580): [client 10.16.32.48:49607] AH00947: connected  to localhost:8734
    [proxy:trace2] [pid 1308:tid 760] proxy_util.c(3014): FCGI: fam 2 socket created to connect to *
    [proxy:debug] [pid 1308:tid 760] proxy_util.c(3046): AH02824: FCGI: connection established with 127.0.0.1:8734 (*)
    ... (many 'sending env var' lines) ...
    [proxy_fcgi:trace8] [pid 1308:tid 760] mod_proxy_fcgi.c(680): [client 10.16.32.48:49607] .....s..         0106000100730500
    [proxy_fcgi:trace4] [pid 1308:tid 760] util_script.c(568): [client 10.16.32.48:49607] Headers from script 'phpinfo.php':
    [proxy_fcgi:trace4] [pid 1308:tid 760] util_script.c(571): [client 10.16.32.48:49607]   Status: 404 Not Found
    [proxy_fcgi:trace4] [pid 1308:tid 760] util_script.c(571): [client 10.16.32.48:49607]   X-Powered-By: PHP/7.3.4
    [proxy_fcgi:trace4] [pid 1308:tid 760] util_script.c(571): [client 10.16.32.48:49607]   Content-type: text/html; charset=UTF-8
    [proxy_fcgi:trace8] [pid 1308:tid 760] mod_proxy_fcgi.c(680): [client 10.16.32.48:49607] FastCGI header (8 bytes)
    [proxy_fcgi:trace8] [pid 1308:tid 760] mod_proxy_fcgi.c(680): [client 10.16.32.48:49607] ........         0103000100080000
    [proxy:debug] [pid 1308:tid 760] proxy_util.c(2332): AH00943: FCGI: has released connection for (*)
</code>
What am I missing here?
Comment: No, you have not run php-fpm. You ran php-cgi, which is for CGI, not FastCGI, two very different protocols.
Comment: You must have misunderstood something. php-fpm is the FastCGI Process Manager, and generally preferable over CGI. php-cgi is the older CGI sapi. I have never heard that php-fpm doesn't work on Windows.
Answer: For the same error message (no input file selected) another reason can be if you applied "open_basedir" restriction incorrectly, which prevents you from opening the php file. You should see some indication in the log.


zend 2 view rendering template with same name from a different module

Question: I'm working with reusable modules in Zend2 and I have a little problem which concerns code duplication.
I have an User module, which has i.e an HTML template register (template path: user/user/register).
It contains some basic HTML but in one of my projects, I need to embed this template with a
 for CSS stylization (the rest of the HTML page doesn't change).
After the User module, I load my Application module where I can overwrite the user/user/register template and put new code but I'm unable to render the original user/user/register template through it.
Example of code in Application module -> user/user/register:

<?=$this->render('user/user/register')?>

This causes an endless loop and I don't want to copy/paste all the HTML from my user/user/register template in User module.
Anyone can help me ?
Thank you !
Answer: What you're trying to achieve won't work. You can not have two templates with identical names. The Module that loads the key the latest will always have priority.
You have to understand that templates are just a key inside a big array.
'view_manager' => array(
    'template_map' => array(
        'layout/layout' => 'my\layout.phtml'
    )
)

So if you have two modules providing this configuration, it doesn't change the fact that both use the key layout/layout. Therefore whatever Module loads later, wins.
TL/DR You can only overwrite templates, not extend them. In your case you have to create a separate template.
Comment: I understand the principle, what I was just asking is a way to not duplicate code between 2 templates which one IS EXACTLY the content of the second plus some html code around. As I don't find a solution for, I just duplicated the template code but it creates a lot of code debts for further updates of the template.

Is there a way to reach a template path in a specific module ? Like I want to render user/user/register in the User module from the template user/user/register in Application module ?
Comment: you should NOT have identical template names, that's the whole idea. Templates should be namespaced just like classes. name ur 2nd module "user2/user/register" and then render a partial "user/user/register" and you're good
Comment: Ok, I get it.
My Application module has to rewrite the route user/register and tells it to use "ApplicationUser" as controller (instead of User controller) then my "ApplicationUser" controller -> registerAction forwards the request to my User module (registerAction) and returns the result. The view called is now application/application-user/register and this renders a partial " user/user/register" template.

Thx a lot.


When should I use JobService in BroadCastReceiver.onReceive()?

Question: I am reading the BroadcastReceiver.onReceive() documentation but I do not understand

If you need to perform any follow up background work, schedule a JobService with JobScheduler

I would be glad if someone could tell me what are the use-cases of such an approach.
Thank you in advance.
Comment: It depends on your requirement. What do you want to do after consuming/receiving the broadcast?
Comment: @roshana-pitigala I retrieve GPS coordinates and send an SMS back. It works but I was worried it might not be the best approach
Comment: and not asynchronously
Answer: BroadcastReceiver may cause an ANR if the work inside onReceive takes a considerable amount of time. Because of that, you should consider moving long-running jobs to the worker, such as JobService, or using jetpack WorkManager.
Comment: Thank you for your precious answer. I have a follow-up question just for the sake of curiosity: I can understand why an ANR can be raised if the UI's thread is blocked, but why will it be raised if a background thread is doing a task? Furthermore if the background thread blocks, also the JobService might block


Retornar valores do modal para tela principal usando jQuery

Question: Tenho um modal do Bootstrap onde eu preencho um "formulário" com 2 campos inputs e três opções de radio. Segue código abaixo! Ao preencher esses campos eu tenho um button (Gerar) que vai colocando os valores digitados na tabela do modal. O que eu não consigo é ao finalizar pegar os valores dessa tabela modal mais o radio, e retornar para a tabela da tela principal usando o button (Usar)...
OBS: desculpe pelo CSS desordenado foi aquele ctrl+c/ctrl+v!

function GerarTabela() {
  var valor = $("#txtParcela").val();
  var data = $("#datepicker1").val();
  var tabela = $(".myBody");
  tabela.append(`<tr><td>${data}</td><td>${valor}</td></tr>`);
}

function LimparTabela() {
  $(".myBody tr").remove();
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#gridSystemModal">Gerar Fluxo</button>

      Fluxo

      Data
      Valor

 Valor do Radio Marcado

Gerar Fluxo

Valor Parcela

              R$
              <input type="text" id="txtParcela" />

Primeiro dia

              <input type="text" id="datepicker1" />

                Caso o dia do fluxo não seja dia útil:

                  <input type="radio" class="custom-control-input" id="defaultGroupExample1" name="radioDiaUtil" />
                  Manter o fluxo neste dia.

                  <input type="radio" class="custom-control-input" id="defaultGroupExample2" name="radioDiaUtil" />
                  Levar o fluxo para o dia útil seguinte.

                  <input type="radio" class="custom-control-input" id="defaultGroupExample3" name="radioDiaUtil" />
                  Trazer o fluxo para o dia útil anterior.

                      Fluxo

                      Data
                      Valor

              <button type="button" id="btnGerar" class="btn btn-info" onclick="GerarTabela()">Gerar</button>

              <button type="button" class="btn btn-danger" onclick="LimparTabela()">Limpar</button>

              <button type="button" id="btnUsar" class="btn btn-success">Usar</button>

              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

Answer: Primeira coisa é colocar um id no label que receberá o texto do radio marcado, para não confundir com os outros label existentes no HTML:
 Valor do Radio Marcado

Depois é criar um event handler para o botão Usar. Ao ser clicado, ele irá enviar os valores (linhas da tabela da modal + o texto do radio checado) para a tabela principal bem como fechar a modal:
$("#btnUsar").on("click", function(){

   var linhas_modal = $(".modal-body .myBody").html(); // pega o HTML da tabela da modal
   var radio = $(".modal-body :radio:checked").next().text(); // pega o texto do radio checado
   $(".firstBody").append(linhas_modal); // insere as linhas na tabela principal
   $("#valor_radio").text(radio); // insere o texto do radio na label
   $('#gridSystemModal').modal('hide') // fecha a modal

});

Exemplo:

$("#btnUsar").on("click", function(){

   var linhas_modal = $(".modal-body .myBody").html();
   var radio = $(".modal-body :radio:checked").next().text();
   $(".firstBody").append(linhas_modal);
   $("#valor_radio").text(radio);
   $('#gridSystemModal').modal('hide')

});

function GerarTabela() {
  var valor = $("#txtParcela").val();
  var data = $("#datepicker1").val();
  var tabela = $(".myBody");
  tabela.append(`<tr><td>${data}</td><td>${valor}</td></tr>`);
}

function LimparTabela() {
  $(".myBody tr").remove();
}

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#gridSystemModal">Gerar Fluxo</button>

      Fluxo

      Data
      Valor

 Valor do Radio Marcado

Gerar Fluxo

Valor Parcela

              R$
              <input type="text" id="txtParcela" />

Primeiro dia

              <input type="text" id="datepicker1" />

                Caso o dia do fluxo não seja dia útil:

                  <input type="radio" class="custom-control-input" id="defaultGroupExample1" name="radioDiaUtil" />
                  Manter o fluxo neste dia.

                  <input type="radio" class="custom-control-input" id="defaultGroupExample2" name="radioDiaUtil" />
                  Levar o fluxo para o dia útil seguinte.

                  <input type="radio" class="custom-control-input" id="defaultGroupExample3" name="radioDiaUtil" />
                  Trazer o fluxo para o dia útil anterior.

                      Fluxo

                      Data
                      Valor

              <button type="button" id="btnGerar" class="btn btn-info" onclick="GerarTabela()">Gerar</button>

              <button type="button" class="btn btn-danger" onclick="LimparTabela()">Limpar</button>

              <button type="button" id="btnUsar" class="btn btn-success">Usar</button>

              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

Comment: Muito obrigado pela ajuda!


Is there an easy way to include a Facebook remarketing tag in my D7 site?

Question: Adding Google Remarketing Script tags to Drupal 7 website shows how to add a Google remarketing tag using a module. Is there a similar solution for adding a Facebook remarketing tag easily?
I would use the drupal_add_js hook if that were so easy, but the issue is that the remarketing tag also includes an  element (the pixel) in a  tag, so I can't include that easily in the same hook.
Answer: Turned out to be very simple. All I had to do was paste the code into the  part of html.tpl.php from within the /templates/ folder.
Comment: I don't think it matters where in the header tag; I put it near the bottom.
Comment: Just where you want in the header tag? above all header-tag content?
Comment: By "Header" you meant the head tag yes? (Just to make sure it's not a HTML5 header tag).
Comment: @benos Ah you're correct - I mean the head tag. Editing my answer.


Unable to check if user is a member of distribution list using Powershell

Question: i am trying to add a user to Distribution group using Power Shell. But  i want to check if user is already a member of the Distribution List and if he is the member of the Distribution List  i want to store the result in a variable so that i can make further decision. So far i have tried the below script but it gives the list of all the member. Please help me with this.
<code>$dl=Get-DistributionGroupMember -Identity DL_Name
</code>
if i can store a result in some variable then further logic can be made.
Comment: You can either check if the user is member of this DL by querying the DL or you query the user and check if the DL is in the memberOf attribute.
Comment: Thanks for your response. Please share the script to query the DL. It will be very helpful
Answer: If I understand correctly and the code you are currently using provides you with a list of all members then all you need to do is check to see if that list contains the member you want to add before adding.
<code>if ($dl -notcontains $userToAdd) {
  Add-DistributionGroupMember -Identity DL_Name -Member $userToAdd
}
</code>


What does the .x function on nvd3 implements?

Question: I am trying to start using the nvd3.js library but not been able to find any documentation.
On the cumulativeLine for example
where can I research about the various functions like .x .y etc. ? Are those nvd3 specific or
they are d3 functions ?
Is there a clear distinction on which of the code represents d3 functionality and which nvd3 ?
Answer: The functions you are referring to are D3 functions that are documented on the wiki. As a general rule, anything that you don't find in the D3 documentation is probably nvd3.


A counterexample

Question: Let $f:\mathbb{R}\to(0,\infty)$ a locally integrable function. I want to compare these two conditions
$$\limsup_{r\to + \infty}\frac{r}{\int_{-r}^r f(x)dx}<+\infty. \tag{1}\label{1}$$
and
$$\limsup_{r\to + \infty}\frac{r^{\frac{1}{p}}\left(\int_{-r}^r f(x)^qdx\right)^\frac{1}{q}}{\int_{-r}^r f(x)dx}<+\infty, \tag{2}\label{2}$$
with $p,q>1$ and $\frac{1}{p}+\frac{1}{q}=1.$
We can see that if $f$ is bounded then $\eqref{1}$ is stronger than $\eqref{2}$, because we would have
$$r^{\frac{1}{p}}\left(\int_{-r}^r f(x)^qdx\right)^\frac{1}{q}\leq M 2^\frac{1}{q}r.$$
Now if $\inf_{s\in\mathbb{R}}f(s)=c>0$, we have $\eqref{2}$ stronger than $\eqref{1}$. Because
$$c\ 2^\frac{1}{q} \ r\leq r^{\frac{1}{p}}\left(\int_{-r}^r f(x)^qdx\right)^\frac{1}{q}.$$
Of course if we have $c\leq f(s)\leq M$ with $c>0$, then $\eqref{1}$ and $\eqref{2}$ are equivalent.
I found that for example $f(x)=e^x$, $f$ satisfies $\eqref{1}$ but not $\eqref{2}$. I don't know if I can find a function $f$ which satisfies $\eqref{2}$ but not $\eqref{1}$. To search it, $f$ must necessarily satisfy $\inf_{s\in\mathbb{R}}f(s)=0$.
Answer: Provided $-\frac{1}{q}<\alpha<0$, the function $f(x)=x^\alpha \cdot 1_{(1,\infty)}$ does what you want.
Indeed, since $\alpha +1>0$ and $\alpha<0$,
$$\frac{r}{\int_{-r}^rf(x)dx}=(\alpha+1)\frac{r}{r^{\alpha+1}-1}\sim \frac{\alpha + 1}{r^\alpha}\longrightarrow +\infty
$$
and since $\alpha q+1>0$,$$
\frac{r^\frac{1}{p} \left( \int_{-r}^r f(x)^qdx \right)^\frac{1}{q}}{\int_{-r}^rf(x)dx}= \frac{\alpha +1}{(\alpha q+1)^\frac{1}{q}}\frac{r^\frac{1}{p}\left(r^{\alpha q+1}-1\right)^\frac{1}{q}}{r^{\alpha+1}-1}\sim \frac{\alpha +1}{(\alpha q+1)^\frac{1}{q}} \frac{r^\frac{1}{p}r^{\alpha +\frac{1}{q}}}{r^{\alpha+1}}=\frac{\alpha +1}{(\alpha q+1)^\frac{1}{q}} .$$

A counterexample


How to play the note on the 24th fret of the 1st string when my guitar only has 22 frets

Question: I have been learning songs on the guitar, but in numerous guitar tabs especially during solos the 24th fret on the first string is required to be played. However, my Fender Stratocaster only has 22 frets.
Is there any possible way to play this note?
Answer: You could bend the 22nd fret up a whole step. You could use a slide, ring, maybe even a fingernail to "fret" it in approximately the right place (compression or distortion would help and you should use vibrato to hide the inevitably poor intonation). You can try sliding the first string down off the edge of the fret board so it both stretches and "frets" against the side of the fretboard and see what note you get - it might be close. And my last idea is push it down against the neck pickup and maybe bend it to try to get it in tune.
The first one (bending the 22nd fret up) is the only that you can be sure will work and that will give you solid control over the intonation. The rest are just tricks of dubious value - but I thought I'd throw in every idea I had.
My solution to this problem was to troll music stores for used guitars with 24 fret necks and floyd rose tremolos, which eventually yielded a great deal on a guitar that turned out to be pretty good for the price after a little work.
Oh yeah, Dom's answer about harmonics is a good one, although you want the 5th fret which is two octaves higher than open, not the 12th.
Comment: The same note could also be achieved by accessing the harmonic located above the neck pickup - easier to grab than fretting down to 5th fret.
Comment: Unlike with the natural harmonic, the bending-up also works for other pitches in that region, not only e'''. And it works also to get even higher on an instrument that already _has_ 24 frets, for instance I quite often play the a' on my four-string bass this way. — Regarding ultrasonic slide playing, I recommend [watching this](https://www.youtube.com/watch?v=XdCGdL3R0n0)...
Answer: Well, use a harmonic.  Two octaves up means that you can touch either at 3/4 of the string length (meaning that you can just use a harmonic where the 24th fret would be) or at 1/4 of the string length.  The "natural" note at 1/4 of the string length corresponds to the 12*log(3/4)/log(1/2)th fret.  Which happens to be quite close to the 5th fret.
But unless that high note is quite an outlier, doing the harmonic over the would-be 24th fret is likely to fit better with your current hand position.
Comment: Nah, I think leaping back to fifth fret for that one note is definitely better.
Answer: You'll have to do a full bend (a bend of a whole step) up to the note on the 22 fret to get that note. You could also theoretically get that note off the harmonics on the 5 fret.
Comment: That 5th fret harmonic has a twin at the '24th' fret. Usually above the neck pup. The player's hand is likely to be nearer that part of the neck at the time.
Answer: You could use pinched harmonics which might make it easier (after much practice) to play the note as part of a melody. A melody of all harmonics will sound more fluid than many fretted notes with just a few harmonics (although that can also sound cool).
You can find this note by fretting the 12th fret and pinching at the (would-be) 24th fret, or by fretting the 5th fret and pinching at the 12th fret (ie. an artificial "7th-fret harmonic", 4th + Octave+5th == 2 Octaves). This last option makes it (relatively) easy play even higher notes accurately (since there are still frets to orient the pinching).
Comment: I'm reminded of a comment in an instructional video by JOE SATRIANI: "I get the pinch harmonic if I'm lucky....."
Answer: Another thought is to fret a different note entirely. Ask yourself what the guitarist may have done given only 22 frets... you could start with hitting something a 5th lower or even a whole octave lower... whatever, as long as it still sounds good: experiment and find something cool and original.


An explicit form of an isomorphism $\operatorname{End}(V^* \otimes V) \simeq \operatorname{End}(\operatorname{End}(V))$

Question: Let $V$ be a finite dimensional vector space, $A: V^* \to V^*$ and $B: V \to V$ are linear maps. We know that there is an isomorphism $V^* \otimes V \simeq \operatorname{End}(V)$, so operator $A \otimes B$ induces a map $\operatorname{End}(V) \to \operatorname{End}(V)$. How to find out the explicit form of this operator?
Comment: That depends on what exactly you mean by the "explicit form"
Comment: @BenGrossmann, knowing matrices of $A$ and $B$ in standart basis. Or for example we have operator $e^{- \mathrm{i} \tau_0 H} \otimes e^{\mathrm{i} \tau_1 H}: \mathcal{H}^* \otimes \mathcal{H} \to \mathcal{H}^* \otimes \mathcal{H}$ and want to know it's view as operator $\operatorname{End}(\mathcal{H}) \to \operatorname{End}(\mathcal{H})$.
Answer: To determine the action of $A \otimes B$ on $\operatorname{End}(V)$, it suffices to determine its action on the rank-1 linear maps and extend by linearity. Every rank-1 linear map in $\operatorname{End}(V)$ can be written in the form $vf$ (my shorthand for the map $[vf](x) = f(x)v$) for some $v \in V,f \in V^*$. The canonical isomorphism between $\operatorname{End}(V)$ and $V^* \otimes V$ maps $vf$ to $f \otimes v$.
Let $\Phi:\operatorname{End}(V) \to V^* \otimes V$ denote this canonical map
and let $\alpha$ denote the map induced by $A \otimes B$ on $\operatorname{End}(V)$, so that $\alpha = \Phi^{-1} \circ (A \otimes B) \circ \Phi$. We find that
$$
\alpha(vf) = \Phi^{-1}(A \otimes B)\Phi(vf) = \Phi^{-1}((Af) \otimes (Bv)) = (Bv)(Af).
$$
For an arbitrary element $\tau = \sum_i v_i f_i$, we thus have $\alpha(\tau) = \sum_i (Bv_i)(Af_i)$.
Comment: Thanks for the answer!


Prove that (1+j)^n + (1-j)^n is a real number for every n>0

Question: I personally tried to use DeMoivre's Theorem to solve this.
Since (1+i)^n can be written in it's polar form as:
z^n = r^n (cos(nθ)+isin(nθ))
<code>= √(2)^n (cos(nπ/4)+isin(nπ/4))
</code>
and (1-i)^n as:
z^n = √(2)^n (cos(n(-π/4))+isin(n(-π/4)))
so (1+i)^n + (1-i)^n can be written as
(1+i)^n + (1-i)^n = (√(2)^n (cos(nπ/4)+isin(nπ/4))) + (√(2)^n (cos(n(-π/4))+isin(n(-π/4))))
<code>              = √(2)^n (cos(nπ/4)+isin(nπ/4) + cos(n(-π/4))+isin(n(-π/4)))
</code>
Although once I got here, I was unsure as to where to go.
If DeMoivre's Theorem the right approach here?
Comment: $z+\overline z$ is real for every complex number $z$.
Comment: Please see https://math.meta.stackexchange.com/questions/5020/
Answer: You seem to have lost track of where you're going.
You've partially carried out a calculation of separating this quantity into real and imaginary parts — you should finish this process.
And if you succeed, this gives an easy way to answer the given question: a complex number is real if and only if its imaginary part is zero.
Answer: You just have to chcek that the imaginary part vanishes.
$$i \sin\left( \frac{n\pi}4 \right) + i \sin \left( - \frac{n\pi}4\right)=i \sin\left( \frac{n\pi}4 \right) - i \sin \left(  \frac{n\pi}4\right)= 0$$
Answer: It suffices to observe that
$$\bar w=\overline {(1+j)^n+(1-j)^n}=(1-j)^n+(1+j)^n=w$$
and
$$\bar w=w\iff \Im(w)=0$$
Indeed recall that for any $z=re^{i\theta}$

$\overline {(z^n)}=r^ne^{-in\theta}=(\bar z)^n$


$A^3+A=0$ We need to show $\mathrm{rank}(A)=2$

Question:
Let $A\ne 0$ be a $3\times 3$ matrix with real entries such that $A^3+A=0$. We need to show $\mathrm{rank}(A)=2$.

$\det A(A^2+I)=0\Rightarrow\det A=0\Rightarrow \mathrm{rank}(A)<3$,  Suppose $\mathrm{rank}(A)=1$, Then I showed one matrix with rank $1$ which do not satisfies the given relation, is my answer is ok? Thank you for help and discussion
Comment: [Strange coincidence](http://math.stackexchange.com/q/389618/264) (deleted question from 10 hours ago asking the exact same thing)? At any rate, the statement is false: if $A$ is the zero matrix, then $A^3+A=0$, but $\mathrm{rank}(A)=0$.
Comment: If it is assumed that $A \ne 0$, edit the problem please.
Comment: Your implication $\det A(A^2+I)=0 \implies \det A=0$ is incorrect (you have it backwards). For example, the matrix \begin{pmatrix}0&1\\-1&0\end{pmatrix} satisfies $\det A(A^2+I)=0$ but $\det A=1$. You need to use the fact that $A$ is $3\times 3$ to rule out the possibility that $A$ is invertible.
Comment: $A$ was not $0$ so far I remember
Comment: Presumably, it's meant to be $\text{rank}(A)\leq 2$.
Comment: @GregMartin: presumably, you meant $$\pmatrix{0&1\\-1&0}$$as with the matrix you mentioned, the square of the matrix is the identity.
Comment: @GlenO thanks, fixed.
Comment: what is true is that
\begin{align}
\det(A^2+I)&= \det((A+iI)(A-iI))\\
&=\det(A+iI)\det(A-iI)\\
&=\det(A+iI)\det(\overline{A+iI})\\
&=\det(A+iI)\overline{\det({A+iI})} \geq 0
\end{align}
Answer: The "standard" way to solve this kind of problems is to examine the minimal polynomial of $A$. Yet, for this particular problem, there are other approaches as well. Here is one of them:

By considering the determinants of both sides of $A^3 = -A$, argue that $\operatorname{rank}(A)\ne3$.
If $\operatorname{rank}(A)=1$, then $A=uv^T$ for some nonzero vectors $u,v\in\mathbb{R}^3$. Show that $A^3+A$ is a nonzero scalar multiple of $A$ and hence it cannot be zero.
As $\operatorname{rank}(A)\ne3,1$ and $A\ne0$ by assumption, the only possibility is that $\operatorname{rank}(A)=2$.
Comment: Where in the OP is it assumed $\,A\neq 0\,$ ?
Comment: @Tsotsi It probably stands for "original post", and is extended to mean "original poster", where "poster" has the new meaning of "someone who posts the message".
Comment: @DonAntonio In his comment. But I think he/she should really fix the question.
Comment: what is OP by the way?
Answer: By the Cayley Hamilton theorem, the minimal polynomial of a square matrix divides its characteristic polynomial. Therefore, since $A \neq 0$ by assumption, $(x^2 + 1) | f_A(x)$ which means that $A$ has at least the eigenvalues $\pm i$. Since these are distinct eigenvalues, the corresponding eigenvectors are linearly independent. Since they lie in the column space of $A$, the rank of $A$ is at least $2$. As you mentioned, a determinant argument can be used to show that it is less than $3$.
Comment: This is not quite correct. First, you say the minimal polynomial divides the characteristic polynomial; what is relevant here is that the minimal polynomial divides any polynomial that vanishes at $A$ - in this case, $x^3+x$. Second, the minimal polynomial might be a proper divisor - in this case, $x$ might be the minimal polynomial. This is impossible if $A$ is assumed to not be the zero matrix, but it shows that that hypothesis is necessary.
Comment: To make this srgument work, you have to think of $A$ as a linear map on $\mathbb C^3$, which may be beyond the scope of OP's course. More directly, by Cayley-Hamilton, if $A\ne 0$, the characteristic polynomial must be $p(t)=t^3+t$, which has $0$ as a single root. Therefore, $\dim E(0)=\dim \ker A =1$, so $\text{rank }A= 2$.
Comment: @TedShifrin could you please tell me how did you calculate $\dim ker A=1$?
Comment: Since the characteristic polynomial must be $p(t)=t^3+t=t(t^2+1)$, $0$ is a root with multiplicity $1$, and so the geometric multiplicity of the eigenvalue $0$ must be exactly $1$. But $E(0) = \ker A$.


Sobolev spaces and the domain of fractional Laplacian

Question: I'm reading this paper on arxiv link.

So far OK.

Now this I don't understand. Take $s=\frac 12$. They say that by density the operator $(-\Delta)^s$ is defined on $\mathbb{H}^s(\Omega)$. Then they say that the theory of Hilbert scales shows that the domain of $(-\Delta)^s$ is $H^1_0(\Omega)$. But in the very next line they claim that $\mathbb{H}^s(\Omega)= H^{\frac 12}_{00}(\Omega)$, which is not $H^1_0(\Omega)$. What do I miss?
Answer: I think the authors are somewhat inconsistent in what they mean by the domain of an operator.   Let's ignore the boundary conditions for now and focus on the order of smoothness.

The domain of $(-\Delta)^s$ as an operator into $L^2$ is a Sobolev space of order $2s$. Indeed, $s$ fraction of the Laplacian is like $2s$ derivatives.
The domain of $(-\Delta)^s$ as an operator from a space into its dual space is a Sobolev space of order $s$. This is because  $\langle (-\Delta)^s f,g\rangle = \langle (-\Delta)^{s/2} f,(-\Delta)^{s/2}  g\rangle$ so having $s/2$ fraction of Laplacian (hence $s$ portion of the gradient) is enough.

When they say that by density, $(-\Delta)^s$ can be extended to $\mathbb{H}^s$, this means as  an operator from $\mathbb{H}^s$ to $(\mathbb{H}^s)'$. Indeed, you can see this from the definition of $\mathbb{H}^s$: if $u=\sum u_k \varphi_k$ then $(-\Delta)^su = \sum u_k \lambda_k^s\varphi_k$ which is not generally in $L^2$ since
$\sum |u_k|^2\lambda_k^{2s}$ need not be finite.
An operator that maps $\mathbb{H}^s$ into $L^2$ is $(-\Delta)^{s/2}$. When they write $\operatorname{Dom}(-\Delta)^{s/2}$, the mean as an operator into $L^2$.
Summary:

when they say "domain is", read it as an operator into $L^2$
when they say "can be extended to", read it as an operator into the dual space.


Expected duration of a conflict

Question: I'm currently struggling with some statistical work, and thus I'm seeking your advice.
I'm trying to investigate the expected duration of a conflict in a) a democracy and b) an autocracy.
What I do know:

the probability of onset of a conflict is:

in democracies: 1%
in autocracies: 2.6%

the probability of continuation of the conflict from the year before (t-1)

in democracies: 83%
in autocracies: 86.1%

Thus, my question is, how do I calculate, how much time a conflict lasts for once started?
Comment: You have to read on Survival and Hazard functions. e.g. https://rpubs.com/daspringate/survival
Comment: What about conflicts causing the countries to become autocracies?
Answer: Given that a conflict has already started, the information about the onset of a conflict does not add to our problem. Depending on your measure of centrality, we may either proceed in any given way. I'd consider estimating the 50% mark on the survival function, that is, the median.
Now, the survival function for a conflict is the function,
$$S(t) = \begin{cases}
        0.83^t & \text{in democracies} \\
        0.861^t & \text{in autocracies}
        \end{cases}, \qquad t \in \{0, 1, 2, ...\}$$
Where we may recognise a geometric distribution (I leave it to you to show that from $S(t) = 1 - F(t)$, for $F(t)$ a geometric distribution obtains). Then, for the median we find $.5 = .83^t \implies t = \frac{\log .5}{\log .83} \approx 3.72$ years in case of a democracy. Giving this an economic interpretation, we expect that 50% of conflicts last at most 3.72 years, assuming ceteris paribus.
In case of an autocracy, we similarly find $.5 = .861^t \implies t=\frac{\log .5}{\log .861} \approx 4.63$ years. So, we find that 50% of conflicts are expected to last at most 4.63 years, again assuming ceteris paribus.

For the expected value, we may proceed in two ways. There is a well-known result which states that the expected survival time $T$ may be expressed as the integral of the survival function, which in the discrete case reduces to,
$$E[T] = \sum_{t=0}^\infty S(t)$$
Doing so yields an expected conflict time of 5.88 years in the case of a democracy, ceteris paribus. For an autocracy, we similarly obtain 7.19 years.
We could alternatively have used our knowledge of the geometric distribution (like in @Aksakal's rule of thumb) to obtain the following,
$$E[T] = \frac{1}{1 - p}$$
Where $p =.83$ in the case of a democracy, yielding again 5.88 years. For an autocracy ($p=.861$), we similarly find 7.19.
Answer: The rule of a thumb is $1/r$ years where $r$ is the survival rate, in this case it's $\approx\frac{1}{1-0.83}$

Expected duration of a conflict


uniform convergence

Question: I'm trying to understand the notion of uniform convergence,
say that I have a squence of functions $(f_n(x)= (1 -\frac{x}{n}\sin(x))^{-n})_{n \in \mathbb{N}}$. We know that it converges to $e^{x\sin{x}}$. How to show from the definition of uniform convergence that it converges uniformly on every bounded interval of $\mathbb{R}.$
We have to show that for an arbitrary bounded interval $I \subset \mathbb{R}$ we have
$$\forall_{\varepsilon >0} \exists_{N} \forall_{n \geq N} \forall_{x \in I} |f_n(x)-f(x)| < \varepsilon.$$
So I fix $\varepsilon >0$ and now I have no idea how to continue. I guess that instead of $\sin{x}$ I could write any continuous function and the proof will be same, but I'm not sure about it. It would be great if anyone could help me.
Comment: Uniformly `on every bounded interval`, hence $[\forall x\in\mathbb R]$ is wrong.
Comment: Is it correct now?
Answer: Let $f_n=(1+\frac {xsinx}{n})^n$(it's the same,for easiest computations) eitherway,
let $g_n(x)=f_n(x)-e^{xsinx}$. Compute $g'_n(x)$=http://www.wolframalpha.com/input/?i=%28%28%28n%2Bx+sin%28x%29%29%2Fn%29%5E%28n-1%29-e%5E%28x+sin%28x%29%29%29+%28sin%28x%29%2Bx+cos%28x%29%29%3D0,find $sup|g_n(x)|_{x\in I}$ and see that for a bounded interval $I$ you have that $sup|g_n(x)|_{x\in I}\to 0$.
Comment: I was expecting the solution involving $\varepsilon$ definition rather than showing that $\sup_{x \in I} |f_n(x)-f(x)| \to 0$ as $n \to \infty$, which is equivalent, but doesn't give me the natural intuition.
Comment: Otherwise you can open the $(1+\frac {xsinx}{n})^n$ in a series  and $e^{xsinx}$ also and see what is left. Take in mind the first terms of each series(the others may go to $0$ or won't be important).This is maybe easier than to find th roots of $g'_n(x)$.

uniform convergence


Computing the value of a Taylor Coefficient

Question: I am having trouble figuring out how to compute the value of the second Taylor coefficient for $e^{\sin(z)}$, with $z=i$. I need to compute the second Taylor coefficient, but I feel after getting help on how exactly to do the first one I can figure it out. This is using $f^k(a)/k!$ of the Cauchy Integral Formula.
Comment: Is this what you mean? $$e^{\sin(z)}$$
Comment: yes, I couldn't figure out how to edit it to look like that.
Comment: I've edited your post. To format it this way, use "e^{\sin(z)}".
Comment: Which coefficient?
Comment: @AdamHughes all the instructions say is 2nd Taylor Coefficient using the equation for f(z) and plugging that into the $f^k(a)/k!$ formula
Answer: To find the second (I assume this means $k=2$, i.e. that there is a "zeroth" coefficient).
This is just
$${f''(i)\over 2!}={1\over 2}\cdot{d\over dz}\bigg|_{z=i}(\cos ze^{\sin z}) = {1\over 2}\cdot e^{\sin i}(\cos^2 i -\sin i)$$
Comment: Alright, so I just do the derivative twice? I was confused as to where the (a) came into play, but plugging in $i$ for it makes sense.
Comment: @Heavenly96 that's correct, $a$ is the point at which you are taking it.


How to parse PHP variables in drupal_add_js in template.php

Question: I'm using drupal_add_js for some inline jQuery - I need to parse some php variables in the inline jQuery, what is the correct way to do it?
drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

I've tried this, and it DOES print the variable, but breaks the JS code in the process (splits the jquery code up and doesnt function) :
drupal_add_js('jQuery(document).ready(function () { alert(" '. print $site_name .' "); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

Comment: While I don't recommend doing this particular task this way (I will comment a link showing the right way) but have you tried swapping the quotes around, like this: drupal_add_js("jQuery(document).ready(function () { alert(' " . print $site_name . " '); });", array('type' => 'inline', 'scope' => 'footer', 'weight' => 5) ); didn't have a chance to try it myself.
Comment: Here is the way forward: http://tylerfrankenstein.com/code/drupaladdjs-setting-example you need to add the site name var as a drupal JS setting, then on ready you can access the var in your jS script which will be in the same place you are placing the var now. This may seem redundant but later on you may need that site name again for another footer-esq script and you would have it easily. If you want me to write an example as an answer just let me know.
Answer: Just remove the print function from your code:
drupal_add_js('jQuery(document).ready(function () { alert(" '. $site_name .' "); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

Looking at the javascript Window alert() Method it has this syntax:

alert(message)

And the message parameter has the type string
PHP's print function prints to the output buffer and returns an int. It has this definition:

int print ( string $arg )

So your code prints the variable $site_name to the output buffer and returns an int, and your string for the alert is then an integer and you have printed to the output buffer which you did not want to do.
Comment: YES YES YES!!! Thank you Sir! Simply removing print fixed the problem.


Bring a selected ListView Item to the top

Question: I have listviews inside a pager adapter, and I'm trying to make it so when I click on an item inside my listview, it will scroll that item to the top. I have an onclicklistener to the item, but I'm not sure how exactly to implement the scrolling given what I have.
<code>public Object instantiateItem(ViewGroup container, int position) {
        List<App> app = this.apps.get(position);

        ListView list = new ListView(this.activity);
        list.setAdapter(adapter);

        container.addView(list);

        return list;
    }
</code>
Answer: First, use ListView's onItemClickListener.
Secondly, use the setSelected() method with the item's position (which you get on the listener).
Answer: smoothScrollToPosition
setSelectedPosition


"No such file or directory" C++ header issue

Question: I'm working on a project that has three cpp files and two header files
All my files are in the same folder.
I've been trying to link the header files with the cpp files for the past few days and I'm struggling so much with it.
Firstly, I tried to add the files in Build Options > Search directories > Compiler > Add
 Image of my setting in Build options
I've ensured that my header files are typed out properly:
vectorfunc.h
<code>#include <vector>
#ifndef VECTORFUNC_H_INCLUDED
#define VECTORFUNC_H_INCLUDED

//my vector functions declaration

#endif // VECTORFUNC_H_INCLUDED
</code>
vectorfunc.cpp
<code>#include <vector>
#include "vectorfunc.h"
#include <iostream>

//my function definitions
</code>
TrackKalman.h
<code>#ifndef TRACKKALMAN_H_INCLUDED
#define TRACKKALMAN_H_INCLUDED

void TrackKalman();

#endif // TRACKKALMAN_H_INCLUDED
</code>
TrackKalman.cpp
<code>#include <valarray>
#include <vector>
#include <iostream>
#include "vectorfunc.h"

//function definition of TrackKalman()
</code>
main.cpp
<code>#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include "TrackKalman.h"

//main function
</code>
Despite all this I still get the error in my compiler:
<code>                                                              ||=== Build: Debug in RadarScanner (compiler: GNU GCC Compiler) ===|
 files\RadarScanner\TrackKalman.cpp -o obj\Debug\TrackKalman.o||No such file or directory|
 files\RadarScanner\main.cpp -o obj\Debug\main.o              ||No such file or directory|
                                                              ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
</code>
I'm using the GNU GCC Compiler
Any help would be greatly appreciated. I can't seem to fix the issue and I definitely don't want to make the whole program in one file.
Comment: I think your problem is caused by the space in your path. There seems to be a space between CPP and files in your path. My advice is to never put spaces in paths you use for projects. Remember that in c++ many of the compilers run on the command line / shell and a space can mean a different argument. The solution to your problem may be putting quotes around the path in your picture or better yet get rid of the space in the path and avoid the problem.
Comment: What IDE are you using?
Comment: It looks like your IDE tries to compile files that don't exist.
Answer: I think you are missing the
<code> #include "TrackKalman.h"
</code>
As first line in TrackKalman.cpp


Aparece null no lugar do nome recuperado

Question: Ao ver a aplicação, vejo que na variável nomedoHumano aparece null, e era para aparecer o nome do usuário.
Logo abaixo do método Onclick, recupero o nome digitado. Já pensei em botar para recuperar acima da String, mas não dá certo.
Segue o código abaixo:
public class MainActivity extends AppCompatActivity {

    private TextView textoNovaFrase;
    private Button botaoNovaFrase;
    private Preferencias preferencias;
    private String nomedoHumano;

    private String[] frases = {
            nomedoHumano + "se você traçar metas absurdamente altas e falhar, seu fracasso será muito melhor que o sucesso de todos",
            "O sucesso normalmente vem para quem está ocupado demais para procurar por ele",
            "Se você não está disposto a arriscar, esteja disposto a uma vida comum"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textoNovaFrase = (TextView) findViewById(R.id.textoNovaFraseId);
        botaoNovaFrase = (Button) findViewById(R.id.botaoNovaFraseId);

        botaoNovaFrase.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Preferencias preferencias = new Preferencias(Conversa.this);
                nomedoHumano = preferencias.getNomeDoHumano();

                Random randomico = new Random();
                int numeroAleatorio = randomico.nextInt( frases.length );

                textoNovaFrase.setText( frases[ numeroAleatorio ] );
            }
        });

    }

Abaixo o codigo do meu SharedPreferences:
public class Preferencias {
    private Context contexto;
    private SharedPreferences preferences;
    private final String NOME_ARQUIVO = "ssistente.preferencias";
    private final int MODE = 0;
    private SharedPreferences.Editor editor;

    //Dados assistente
    private final String CHAVE_NOMEASS = "nomeDoAssistente";
    private final String CHAVE_SEXOMASASS = "seoxMasDoAssistente";
    private final String CHAVE_SEXOFEMASS = "seoxFemDoAssistente";

    //Dados Humano
    private final String CHAVE_NOMEHUM = "nomeDoHumano";
    private final String CHAVE_SEXOMASHUM = "sexoMasDoHumano";
    private final String CHAVE_SEXOFEMHUM = "sexoFemDoHumano";

    private final String CHAVE_SEXOHUM = "sexoEscolhidoHum";
    private final String CHAVE_SEXOASS = "sexoEscolhidoAss";

    // Como foi seu dia?
    private final String CHAVE_DIA = "respostaEscolhida";

    public Preferencias( Context contextoParametro){

        contexto = contextoParametro;
        preferences = contexto.getSharedPreferences(NOME_ARQUIVO, MODE );
        editor = preferences.edit();

    }

    public void salvarDadosNomeeSexo( String nomeDoAssistente, String sexoMasdoAssistente, String sexoFemDoAssistente,
                             String nomeDoHumano, String sexoMasdoHumano, String sexoFemDoHumano,
                             String sexoEscolhidoAss, String sexoEscolhidoHum){

        editor.putString(CHAVE_NOMEASS, nomeDoAssistente);
        editor.putString(CHAVE_SEXOMASASS, sexoMasdoAssistente);
        editor.putString(CHAVE_SEXOFEMASS, sexoFemDoAssistente);
        editor.putString(CHAVE_NOMEHUM, nomeDoHumano);
        editor.putString(CHAVE_SEXOMASHUM, sexoMasdoHumano);
        editor.putString(CHAVE_SEXOFEMHUM, sexoFemDoHumano);
        editor.putString(CHAVE_SEXOASS, sexoEscolhidoAss);
        editor.putString(CHAVE_SEXOHUM, sexoEscolhidoHum);
        editor.commit();

    }

    public void salvarDadosDia(String respostaEscolhida){
        editor.putString(CHAVE_DIA, respostaEscolhida);
        editor.commit();
    }

    public HashMap<String, String> getDadosAssHum(){

        HashMap<String, String> dadosAssHum = new HashMap<>();

        dadosAssHum.put(CHAVE_NOMEASS, preferences.getString(CHAVE_NOMEASS, null));
        dadosAssHum.put(CHAVE_SEXOMASASS, preferences.getString(CHAVE_SEXOMASASS, null));
        dadosAssHum.put(CHAVE_SEXOFEMASS, preferences.getString(CHAVE_SEXOFEMASS, null));

        dadosAssHum.put(CHAVE_NOMEHUM, preferences.getString(CHAVE_NOMEHUM, null));
        dadosAssHum.put(CHAVE_SEXOMASASS, preferences.getString(CHAVE_SEXOMASHUM, null));
        dadosAssHum.put(CHAVE_SEXOFEMASS, preferences.getString(CHAVE_SEXOFEMHUM, null));

        dadosAssHum.put(CHAVE_SEXOASS, preferences.getString(CHAVE_SEXOASS, null));
        dadosAssHum.put(CHAVE_SEXOHUM, preferences.getString(CHAVE_SEXOHUM, null));

        return dadosAssHum;
    }

    public String getNomeDoAssistente(){
        return preferences.getString(CHAVE_NOMEASS, null);
    }

    public String getNomeDoHumano(){
        return preferences.getString(CHAVE_NOMEHUM, null);
    }

    public String getRespostaEscolhida(){
        return preferences.getString(CHAVE_DIA, null);
    }

}

Comment: Você obtém `nomedoHumano` através de  `preferencias.getNomeDoHumano()`, adicione à pergunta o código da classe Preferencias.
Answer: Aparece "null" porque, quando o array frases é construído, o campo nomedoHumano é null.
O que o array guarda na posição 0 é o resultado da expressão
nomedoHumano + "se você traçar metas absurdamente altas e falhar, seu fracasso será muito melhor que o sucesso de todos"

que é a concatenação do valor do campo nomedoHumano, naquela altura, com o expressão entre aspas.
Qualquer alteração posterior do valor do campo não alterará o valor guardado no array.
Comment: e existe alguma forma de eu fazer aparecer o nome?
Comment: Sempre que obter/alterar o valor de `nomedoHumano` reconstrua a posição `0` do array: `frases[0] = nomedoHumano + " se você traçar metas absurdamente altas e falhar, seu fracasso será muito melhor que o sucesso de todos";`


Multiple web apps in Tomcat( using same jars ) leads to perm gen OOM

Question: I am running a Tomcat with two web app instances, the development of the two apps are independent. When I start the tomcat server, and start accessing the applications, it either throws a Perm Gen OOM Exception or a Heap Space OOM Exception. Both these apps use same jars, these jars are bundled inside the respective lib folders of the webapps. Is the perm gen caused because of the repeated loading of the classes? How can I avoid the Perm Gen and Heap space exceptions?
EDIT: I want the best practices to be followed at this scenario. Please advise on the same.
Note: I run the tomcat on a 2008 Server with 12 gb ram. the server also hosts other tomcat servers and a MSSQL server for the DB.
Answer: You have to increase the -XX:PermSize -XX:MaxPermSize size to avoid the issue in the configuration file of the tomcat. Ideally it will be 256, Just increase it to 512.
Answer: Such errors can certainly be caused by memory leaks caused by class loader memory leaks (https://wiki.apache.org/tomcat/MemoryLeakProtection).
You can try increasing permgen space (<code>-XX:PermSize<size> -XX:MaxPermSize<size></code>) and see if it helps. If it just decreases the frequency of OOMs, then you, most likely, have a memory leaks. Unfortnuatelly, finding the solution is not easy. I avoid this by restarting tomcat on application redeployment, a strategy that may or may not work for you.


SSL errors on Heroku (Mixed contents)

Question: I have an app via Drupal 7 on Heroku. You know, myapp.herokuapp.com is default with SSL.
But when I try https://myapp.herokuapp.com get many errors in console like this:
 Mixed Content: The page at 'https://myapp.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://myapp.herokuapp.com/modules/system/system.base.css?ngonpd'. This request has been blocked; the content must be served over HTTPS.

I tried to add this code in settings.php but not working:
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
  $base_url = 'https://myapp.herokuapp.com';
}
else {
  $base_url = 'http://myapp.herokuapp.com';
}

How can I fix this?
Answer: IMO $base_url in settings.php should work
Alternatively you can try
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

or
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Comment: $base_url works for me

SSL errors on Heroku (Mixed contents)


Finding $H_3$ and $H_2$ for $S^3 \setminus K$ where $K$ is a knot

Question: I'm trying to compute (reduced) $H_n(S^3 \setminus K)$ where $K$ is a knot, an embedding of $S^1$ into $S^3$. I'm following a suggestion with the problem that if I let $O$ be a small open tube around $K$ then I can use the Mayer-Vietoris sequence where by homotopy equivalence $H_n(K) = H_n(S^1)$, $H_n((S^3 \setminus K) \cap O) = H_n(S^1 \times S^1)$, and this works fine except around $n = 2, 3$.
My issue is this: Assuming I've done everything else right, I have the exact sequence
$0 \to H_3(S^3 \setminus K) \oplus 0 \to \mathbb{Z} \to \mathbb{Z} \to H_2(S^3 \setminus K) \oplus 0 \to 0$ and I can't figure out the nature of any of the maps in the middle beyond what the sequence already makes obvious. That is, I don't understand how $H_3(S^3)$ maps to $H_2(S^1 \times S^1)$ here (these are the two $\mathbb{Z}$'s in the middle), and I really can't figure out anything about the relationship between the outer groups and the inner ones.
Comment: An easier method: use Alexander Duality.
Comment: $H_3$ will be zero because the complement of $K$ will deformation-retract onto some $2$-complex, which can be constructed by taking loops corresponding to generators of $\pi_1$ of the knot complement and gluing disks according to the relations.
Comment: I don't even know what Alexander Duality is, so I can guarantee it's not in my toolbox.
If I could figure out how the boundary map from H_3(S^3) to H_2(S^1 X S^1) works (I think that both H2 and H3 should be 0, so it *should* be an isomorphism) then I'd be done.
Comment: The system doesn't automatically notify users of comments. You need to ping me with @username. I just happened to come back to look at this question.
Answer: The boundary operator $\partial \colon H_k(X)\to H_{k-1}(A\cap B$ in Mayer Vietoris for $X=A\cup B$ is defined as follows. Given a $k$-cycle $x$ in X, write it as $[x]=[a+b]$ where $a$ and $b$ are chains supported in $A$ and $B$ respectively. Then $\partial a$ is contained in $A\cap B$, and is the image of the MV boundary operator. For the sphere, the generator of $H_3(S^3)$ is represented by the sum of tetrahedra in any triangulation of $S^3$. One can choose such a triangulation to contain a triangulation of $S^1\times S^1$, and let $a$ be the sum of tetrahedra on the outside of the $S^1\times S^1$, while $b$ is the sum of tetrahedra on the inside. $\partial a$ is then the sum of triangles in the triangulation of the torus, so represents the generator of $H_2(S^1\times S^1)$. Therefore the MV boundary map is an isomorphism in this case.
Comment: Thank you, this is at least getting me some clues. But did you mean S^1 X S^1 instead of S^1 X S^2?
Comment: Oops. Yes. I normally work in 4 dimensions. I will edit.
Answer: Alexander duality says that:

If $K$ is a compact, locally contractible, nonempty, proper subspace of $S^n$, then $$\tilde{H}_i(S^n-K;\mathbb{Z})\cong \tilde{H}^{n-i-1}(K;\mathbb{Z})$$ for all $i$.

For a proof see Hatcher Theorem 3.44.


Finding the cardinality of an orbit of an element

Question: Let $A = (1 2 3 \dots n)$ be an element of $P_n$. So that the group $P_n$ acts on itself by means of the action of conjugation, for $B \in P_n$,
$$B · A = B A B^{-1}.$$
Stabilizer of $A$ is subgroup; $$\{A^{c} \mid c = 0, \dots , n-1\}.$$
I want to find the cardinality of $Orb_{P_n}(A)$.
So by applying the Orbit stabilizer theorem:
Then for A to act in itself by conjugation then I have that $Orb_{P_n}(A)=ABA^{-1}$ : where $A$ is an element of $P_n$.
[Provided by my friend Andreas]
Proof of the stabilzer of A:
By applying the orbit-stabilizer theorem, you can count how many n-cycles there are.
The result is $n! / n = (n-1)!$, as each $n$-cycle can be written in $n$ different ways,
$$
(12\dots n) = (23\dots n 1) = \dots.
$$
Since the conjugacy class of $(12\dots n)$ consists of all $n$-cycles, orbit-stabilizer tells you that the stabilizer you are looking for (which is called the centralizer of $A$) has order $n$.
Since there are n distinct powers of A, and they clearly stabilize A, and so forth.
Is this correct :O
-nomad609
Comment: I assume that $P_n$ is the permutation group on $n$ symbols. This is normally denoted as $S_n$. Also, your $G$ is $P_n$? There is a mistake here: $Orb_{P_n}(A)=ABA^ {-1}$, must be  $Orb_{P_n}(A)=\{BAB^ {-1}: B \in P_n\}$. How did you find the stabilizer of $A$?
Comment: Yes you are correct sorry. I couldn't manage to input it correctly. I too was ambivalent about the notation used, but yes it should be Sn. Every correction you applied is right. I will add it in one moment.
Comment: There Sir, I have added it in.
Comment: Does any have any thoughts please/
Answer: It would be this I think:
Suppose that the finite group G acts on the set X, and that x ∈ X.
Then the cardinality of G is the product of the cardinality of the orbit of x and the
cardinality of the isotropy group at x. Writing |S| for the cardinality of a finite set
S, this is
|G| = |G · x| |Gx|.
If anyone can verify this please :)
Answer: The centralizer of $A=( 1 2 3 \cdots n)$ is $\langle A \rangle$, which is a cyclic group of order $n$. Here, centralizer is the same as stabilizer when the action is conjugation. Hence the orbit, in other words, the number of elements in the conjugacy class of $A$ in $S_n$ is $n!/n=(n-1)!$.


Xamarin iOS 6 SDK Xcode 5

Question: Well, I'm new in the Xamarin iOS developing and I think I started with the wrong foot.
I have Xcode 5.0 and Xamarin 4.0.14. I'm looking to make my application work on iOS 6 and iOS 7 as my only testing device is an iPhone 3GS.
My problem is right now everything seems to point as I'm developing for iOS 7, all the buttons are borderless and as far as my knowledge goes, that it iOS 7.
So, how can I make my application work on iOS 6 but still be approved by the Apple Store? (I've read that they'll soon stop accepting iOS 6 app).
P.s I've already read Xamarin.iOS Target iOS 6 SDK
but I'm still not quite there. I've started downloading Xcode 4.6.3 just in case.
Answer: I experienced the same problem. Uninstall Xcode, Xamarin.iOS and Xamarin Studio and install these versions:
Download and install:

Xcode 4.6.3

Go to developer.apple.com/xcode/. Log in. Click View downloads and on the second screen you should see Xcode 4.6.3

Xamarin.iOS 22.214.171.124

In order to download this version log in to xamarin.com/. Click on your account and then Install. Under the big green button click on View all versions. Here you can select Xamarin.iOS 6.4.3 version.

XamarinStudio 4.0.12

The process is the same as for Xamarin.iOS. Only select the third column where you can find other version for XamarinStudio.

If you don't have the latest Xcode and Xamarin.iOS you won't be able to debug your applications with iOS 7 on iOS Simulator.
EDIT
As Peter pointed out, Apple will stop accepting apps which are not built with XCode 5 since February 2014.
Comment: Apple stop accepting apps built with older that Xcode5 on 1st Feb 2014. Hope you got your app submitted in time....
Comment: Perfect answer, but will Apple still accept my Apps as they are made for iOS6? Won't they stop accepting them?
Comment: They will still accept them. We launched our latest app to AppStore this month and it got through revision without problems. We used the same versions which are in my answer.
Answer: You could download Xcode 4.6.3 from the Apple developer portal to developer for iOS 6.  Or, you could follow the information at Is it possible to install iOS 6 SDK on Xcode 5?
Answer: I'd like to point you to my answer to a similar question and add a couple remarks on top.
That said by adjusting your deployment target to version 6.0 you could start developing. The fact that you only have access to an IPhone 3GS has both advantages and disadvantages.
On the plus side you can be pretty sure that your app will be running screaming fast on all recent iOS hardware, if performance is acceptable on such an ancient device as the 3GS.
The major disadvantage of your setup is that youl would have to rely solely on the simulator to ensure iOS7 compatibility. It's a gamble. And you will have to rely on the AppStore reviewers to know the outcome. (Hint: I've been there)

Xamarin iOS 6 SDK Xcode 5


Why do we have key signatures as they are? Could a key with unconventional accidentals make sense?

Question: I mean Western music, classical music, circle of fifths and all that. Why can't I have a key with, for example, three sharps -- though not the usual F, C, and G, but instead some other combination like E, B, and D? I imagine it would sound terribly dissonant. I have heard that the reason there is the conventional progression of sharps/flats (i.e. the circle of fifths) and that there cannot be other strange combinations of sharps/flats is because the keys are "built on each other". However, I'm not sure what that means exactly.
I have a very limited understanding of music theory, and occasionally I have dabbled in (piano) composition and made a few amateur sketches. It is always the case that I find myself "gravitating" toward a certain key in any given attempt. I can never seem to, for example, make a sensible or at least not-terrible-sounding sketch without being in some conventional key, and if I want to introduce anything different I would simply notate accidentals in individual measures (but that would usually only be temporary, e.g. a single one-note dissonance). So what I am wondering is, is it possible to actually compose a solid, structural, perhaps even melodious piece strictly with an unconventional combination of accidentals in the key signature, and where individual measures or segments are not in some conventional key signature (which seems to usually be the case, e.g. a piece may be said to be "in C major" but can be in other keys at different moments), which would usually achieved by introducing accidentals? (I mean, one could put B as the only sharp in the key signature, but then simply add a natural to each B throughout the piece… so effectively it's just C major.)
Could a key with unconventional accidentals make sound, structural, perhaps even harmonic and melodic sense... a key that is perhaps separate and distinct from the conventional key signatures, and maybe even with a different "quality", "temperament", or "feel"?
Comment: Unconventional key signatures are possible, see for instance Ligeti. They might make sense in some cases, but might also confuse the musician.
Comment: Here's just simple proof of existence: https://www.youtube.com/watch?v=zSugkgY-tKA
Answer: As computer scientist I hold, that key signatures are intended as help to reduce the amount of information to be processed at each note, so a piece in G flat major looks quite similar to one in C major. They are a convenient convention, but there is no strict requirement to use key signatures and you could ornament each note with the appropriate accidental instead. (If all F notes receive a sharp, this would be an indication, that you have at least G major, however).
I remember my son received a piece (20th century) to play as prima vista exam, which had the quite unusual signature of one sharp and one flat, so yes, strange pieces exist.
Comment: @Tim, probably Bartók, and probably (non-diatonic) modal as all Hell.
Comment: Could that piece be, as I suggested, in D minor?
Answer: I think there are a couple of aspects of this question - there's the issue of what notes you can choose for your piece and still have it sound harmonious, and there's then the issue of how you notate that.
To tackle the second question first, western music notation (to an extent) assumes use of the diatonic scale - witness the fact that it has 7 notes per octave, as opposed to the 12 notes per octave that might make more sense if everyone were wanting to explore the full range of possibilities within the chromatic scale. All the conventional key signatures are those that comply with this assumption. You could use non-conventional key signatures, but you could argue that you are then going against some of the assumptions of the notation system in the first place. (Of course accidentals and other tactics can be used to make much more flexible use of standard notation, but that doesn't negate the fact that the system takes these assumptions as a starting point.)
As to whether a piece with an unconventional key signature could sound fine, there's no real reason to think not. A piece using the whole tone scale (starting nominally on C) could be said to use an F#, G#, A# key signature, for example. In fact any scale that goes outside the diatonic (e.g. I think some middle eastern and Indian scales, and arguably even blues) is not going to be able to be notated accurately using only the conventional key signatures - It's just that the conventional way round this tends to be the use of accidentals, rather than using an 'odd' key signature.
Answer: Your use of 'gravitate' is the clue. Most Western music has this propensity. It gives the listener a feeling of stability. In fact, the tension and release aspect of a lot of music uses this phenomenon to work. Notes and harmonies that put an edge on the music do the same for the listeners' feelings.
Over many centuries, the keys, their scales, and the distance between each of the notes thereof established themselves - rather than 'humans made it happen', if that makes sense. All we did was formulate what was already there, as accepted form.
Yes, one could write a piece with a strange key sig., but that wouldn't help musicians who are reading it. The key sig. is a sort of code, which gives the reader a clue as to what will be coming. Some pieces in, say, G, with one sharp, could actually sound in the key of Em, somewhat different, but a reader would spot the D# that would often appear. Sometimes, in modal compositions, the 'proper' key sig. of the note name appears, as in, say, one flat for Dm, but if the piece is actually in D Dorian, then all of the Bs get naturalised. This again is a clue for the reader.
I sometimes used to think o.k. this piece is in D minor, which usually has Bb and C#, so why not use those as the key sig...
If the key sig. was, say, B#, as you suggest, and then all the Bs were naturalised, then the process would be pointless.
Answer: It's very common in traditional musics to have 'non-standard' key signatures; Swedish traditional fiddle music, for example, has many examples, picking one of my books of Swedish tunes and flipping through quickly yields key signatures of F# Bb , and C# (only). Music based on modal scales also pushes notation out of the 'standard' key signatures, for musics such as Breton, Hungarian, etc.
Western classical music has imposed the idea of a logical progression of ever-increasing sharps or flats; out in the 'real world' there's all sorts of other key signatures (or, more correctly, scales depicted in standard notation as key signatures) than that.
Answer: It was very much the thinking in your last paragraph, @fioritura, which led me in 1993 to use non-standard key signatures in a book of Swedish fiddle tunes I was putting together. I also had a bit of an ideological point, I think — conventional notation evolved in response to the needs of certain musicians and musics, and doesn't necessarily meet the needs of others.
In retrospect, though, I think it was a mistake. For people who are not fluent and habitual readers, it probably makes very little difference, but for anyone who reads all the time it's a stumbling block — something like a spelling reform, where the change might make things slightly easier to people learning to read but much harder for those who already read well.
Answer: I believe that musical notation has to be seen as one kind of message. You, as the composer writes the message. The notation is the way to transfer the information. The musician interprets the notation, and hopefully comes close to what you the composer wanted it to sound like.
As such you have to consider what the musicians are used to read, to help them on the way. Classical musicians spend most of a lifetime reading notation following a set of rules. So if your message, sorry music, can be massaged to fit into this form it is a good thing to follow the rules (real rules as well as unwritten ones). But then again, if you cannot convey the music using conventional notation, then use other ways. If the music requires it, do write it differently. You can find examples of this if you look around a bit.
But only using a non-conventional set of sharps and flats in the key, to mind mind, really does not convey anything you could not convey following the conventions. But it might, only the result of letting the musicians playing the notation will really show.


Compilation error when deploy ASP.NET web form on server

Question: I used Visual Studio 2017 to create ASP.NET Web Forms with reference: MySql.data.dll. It works well on my Laptop. I upload all files on my server, I get Compilation Error
<code>Compiler Error Message: CS0246: The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)
</code>
Web Forms target Framework: 2.0. My server support ASP.NET version 2.0
I have done many ways that I can search. But nothing change.
The last, I tried change version MySql.Data.dll file, change version framework, use some free hosting to test, but same error
Answer: You need to install the MySql Connector/NET on the web server.
Comment: I use Windows Server, it was installed MySql
Comment: You still need to install the connector
Answer: To solve this problem download MySql.Data.dll from
https://www.cryptool.org/trac/CrypTool2/export/2020/trunk/AppReferences/x64/MySql.Data.dll
Then right click on your project name, click on add reference and select MySql.Data.dll file
Comment: Thank for help but I was tried this way before ask my question


Understanding function of some non-diatonic chords in Jack Johnson's "Belle"

Question: Jack Johnson's "Belle" has the following chord progression:
Gmaj7 Gmaj6 Gm7 Gm6
Gmaj7 Gmaj6 Bm7 Cm6
Am7   Am6   Am7 Ab7
Gmaj7 Cm6   Am7 Ab7 :||

I'm trying to write down the Roman numerals of these chords, but am missing a few.
I  I  ?   ?
I  I  iii ?
ii ii ii  bII
I  ?  ii  bII

The ii-bII-I is a typical tritone substitution of the usual ii-V-I. I'm missing the following:

I don't understand how to analyze the Gm chords.

My ear wants to view this as the beginning of a secondary ii-V-I to the key of F, but there is no such modulation.
Is it correct to simply consider this progression as alternating between I and i (a borrowed chord)?

I don't understand how to analyze the Cm6 chords.

If viewed as a Cm chord, this could be analyzed as a iv chord which is a common borrowed chord. However, it is always followed by the ii chord (rather than being used as the "wistful" iv-I cadence) which makes me doubt this interpretation.
Since it is always followed by the ii chord (A minor), I tried to see if it is some sort of secondary dominant in A minor. The presence of the Bm7-Cm6-Am7 progression suggests this might be a secondary ii-V-i for A minor. But I can't see how Cm6 is a substitute for E7.
Finally, Cm6 can be viewed as part of an F9 chord. But this doesn't seem to help either.
Comment: bII>I won't be tts, unless it's bII **7** >I.
Comment: Video unavailable.
Answer: The analysis goes like this:

I I i i
I I {chromatic D-Eb-E with A common tone}
ii ii ii bII
{chromatic D-Eb-E with G common tone} bII

Consider that

Bm7 is a substitution for GM7. Both contain B-D-F#, and the A of the Bm7 would certainly fit just fine as part of a GM9.
Cm6 is really Am7b5

Thus

I I i i
I I I ii
ii ii ii bII
I ii ii bII

But the key element is the chromatic motion created across the Cm6 (i.e., Am7) chords. Play it as
Bm7/A  Am7b5  Am7
and I think you'll hear it.

Regarding the possibility that the Cm6 could be a iv chord, note that it's not uncommon for a IV/iv chord to progress to a ii/II chord. They share common tones and can both act as pre-dominant chords.
Comment: Thanks for pointing out that it is not uncommon for IV/iv to progress to ii/II! Also, outlining the chromatic motion in `Bm7/A Am7b5 Am7` was helpful.
Answer: This is very reminiscent of classic Brazilian music from composers like Jobim et al. It makes use of a good dose of parallel minor chords, modal interchange and also lots of inner voice movement, all of which are typical to that style. Another element is the use of m6 chords which can be used either for inner voice movement (7-6) or can also be used and interpreted as 7th chords with the 5th in the bass. Playing the 5th in the bass is a common stylistic trait of Brazilian guitarists (check out Rosa Passos, an amazing artist who sings and plays guitar, she does it all the time). I don't know why they do it but I believe it might have come about for wanting to have a lower note in the bass, perhaps when there was no bass player present and no 7 string guitar with the low string tuned to A to play the low root of the 7th chord.
For part 1 of your question, this is reminiscent of the major to minor in bars 17-21 of Jobim's "Triste". "Look to the Sky" has a similar progression in bars 1-4 and also 17-21. I interpret this as simply a I-i, parallel major/minor. The beauty of it is in the inner voice leading of F#-E-F-E.
As for part 2, this chord is a little unusual, not because of what it is but where it goes. It sounds very much like a iv to me but it goes, to ii. It is more common for this chord to go to a I or a iii but it does has a minor sundominant quality to it in this case. It's not unusual to have two subdominant chords in a row, say ii-IV. In this case they go in the opposite direction and incorporate modal interchange.
Another interpretation of this chord is what you mentioned, an F9. You say "this doesn't help" but I also see the F9 as an alternate interpretation, a bVII7 chord with an unresolved or delayed resolution to the tonic 4 bars later. However in this case the previous chord and the C root really draws my ear to the iv interpretation.
One thing you did not comment about is bars nine through 12. You simply referred to this as ii-bII but I see it as more than that. To my ear it is a ii-V(with the 5th in to bass) then a repeated ii-V but with a tritone substitution on the second V. Back in the day it was common to repeat ii-V's (ala Satin Doll), not so much anymore.
This is an homage to classic Bossa Nova and a very nice one at that.
Comment: I'm glad it was helpful to you. The way those m6 chords are usually voiced, which is from bottom to top on say an Am6 or D9/A is from low to high A-F#-C-E. As a m6 it is 1-6-b3-5 and as a 7th it is 5-3-b7-9, a dominant chord with no root in the voicing, which is a common exclusion in jazz and some styles of Latin music.
Comment: Thank you again John for a very informative answer. I really appreciate you explaining the specific connections to Bossa Nova, and the two Jobim examples were great examples of the `I-i` movement. Thank you also for pointing out the interpretation of 6th chords as inversions of 7th chords; the interpretation of the Am6 as a `V` with the fifth in the bass was illuminating.


Probability Homework Question - Use Product Rule to count Number of Permutations?

Question: Below is a homework question I have as part of an assignment. I know what I'm suppose to do such as use product rule to prove the number of permutations that define Events A and B but I'm not sure how to start or finish it.  Any help is greatly appreciated! Thanks :)
Answer: Find $\rm P(A)$ and $\rm P(B)$ and also $\rm P(A.B)$ then show that $\rm P(A)P(B)=P(A.B)$
If you're having problem finding those try them for a while and if you fail try to decipher these:
Spoiler:Hint

 $${\rm P(A)}=\frac{{}^{n}{\rm C}_2(n-2)!}{n!}=\frac{n(n-1)}{2n(n-1)}=\frac12$$

Spoiler:Hint

 $${\rm P(B)}=\frac{{}^{n}{\rm C}_32!(n-3)!}{n!}=\frac{2n(n-1)(n-2)}{6n(n-1)(n-2)}=\frac13$$

Spoiler:Hint

 $${\rm P(AB)}=\frac{{}^{n}{\rm C}_3(n-3)!}{n!}=\frac{n(n-1)(n-2)}{6n(n-1)(n-2)}=\frac16$$

The most exciting thing is that you can obtain those without calculating anything but thinking intuitively.


Could $\sum e^{a_i}$ be simplified? Does it have an identity?

Question: $\sum_{i=1}^n e^{a_i}$ (where $a_i \in \mathbb R$) is expensive for large $n$ (a sum and $n$ exponential operations). I was wondering if there is any way for simplifying this?
Comment: What are your $\,a_i$'s...and what does it mean a series is "expensive"?
Comment: So we could have $a_i = \log(b_i)$ for any sequence $b_i$?  Then you're asking if there's a way of summing $n$ arbitrary numbers without actually adding them up?
Comment: There's no real way to avoid lots of exponentiation calls unless you have nice properties on the $a_i$.
Comment: What are your $a_i$?
Comment: $a_i$ could be any random real number.
Comment: Sorry for using bad terminology. I mean computing the results requires many operations ($n$ exponentiation). I am looking for a faster way to compute the result.
Comment: I don't think that there is, in general, any way to decrease the number of exponential operations needed.
Comment: Thank you for the explanations. I wonder why that is that there is no way to decrease the number of exponential operations required.
Comment: How are the exponential operations being performed? There may be ways to improve the speed based on reformulation in terms of the operation itself.
Comment: @Tim: It's not the additions that are the issue, I think. In your argument, the point would be that evaluating the $b_i$ values themselves is the hard part. ssi is asking if there's a way to reduce the number of exponentiation operations, like you can reduce the number of 8 bit multiplication operations when multiplying large numbers.
Comment: If this were a well-defined sequence there might be a way to reduce the number of additions...but if it's an arbitrary sequence then there's probably no way.
Comment: @GlenO I'm not sure if I correctly understand your question, I have not implemented the operations yet, but I think I will use the standard library of any language I use. Your question gave me an idea that I could probably minimize the operations by looking into how my compiler calculates the exponential operations.
Comment: If you work only with limited precision, another issue may be that you should add in the right order (from small $a_i$ to big) to avoid errors. On the other hand if some (but not too many) $a_i$ are a lot smaller than others, you may ignore their summands altogether.
Comment: @ssi: My first suggestion would be to test whether the "cost" of the operation depends on the size of $a_i$. If it gets larger for values of $a_i$ of higher magnitude, then it may be worth sorting the $a_i$ values in order of magnitude, and then evaluating them sequentially (that is, evaluate $e^{a_{i+1}-a_i}$ and then use multiplication from there).
Comment: I'll write that up as an answer, to make it clearer.
Answer: One possible way to reduce the cost of the exponentiation operation may be to replace exponentiation involving large exponents with multiplications. This is what I mean:
Assume that $\{a_i\}$ is sorted in ascending order (if not, sort them first), so that $a_{i+1}\geq a_i$. Now, let's use the notation
$$
A(n) = \sum_{i=1}^n e^{a_i}
$$
Obviously, $A(1)=e^{a_1}$. Now, we can write
$$
A(2)=A(1)+e^{a_2}
$$
But we could also write this as
$$
A(2) = A(1)+b_1e^{a_2-a_1}
$$
where $b_1=e^{a_1}$. Similarly, we have
$$
A(3)=A(2)+b_2e^{a_3-a_2}
$$
where $b_2=e^{a_2}=b_1e^{a_2-a_1}$. If we define the sequence
$$
b_{i+1} = e^{a_{i+1}-a_i}b_i
$$
with $b_1=e^{a_1}$, then we can write
$$
A(n+1)=A(n)+b_{n+1}
$$
The advantage of this is that, while $a_n$ may be very large, and thus require a lot of computation, it may be much quicker to calculate the various $b_i$. It requires just as many exponentiation operations, but reduces the size of the exponent significantly, which may save on operation cost.
However, it is subject to the exponentiation cost relationship. If the cost of exponentiation remains almost constant with size of the exponent, then this will actually be slower than simply evaluating the exponentials directly, due to the added multiplications.
Comment: @ssi - Have you tested the cost of exponentiation, yet? If not, I suggest you unmark it as the correct answer for the time being, as it may not be of any help to you.
Comment: I have to leave right now to see a friend urgently - I will create the tests when I'm back. Sorry for the delay
Comment: My benchmarks run in Ruby (MRI v1.9.3) and JavaScript (NodeJS v0.10.5) showed that the performance of computing $e^{a_i}$ is not related to the size of $a_i$.
Comment: Computing 50,000,000 operations for $−700.0<a_i<700.0$ on my computer takes $2.16 \pm 0.03$ seconds. For larger values it returns $\infty$ or 0.
Comment: Well, that's unfortunate. It means that there's no reformulation that will accelerate the code as it currently stands. There may, however, be other methods of accelerating the code. How accurate does the exponential have to be? Do you need it at maximum accuracy, or just a good estimate? There are methods that can increase speed by a reasonable factor at the cost of reducing accuracy, for instance.
Comment: Just a good estimate would be fine for what I am doing right now.  (Actually, I just need a continuous bell-like function, ie always zero except in the middle. I'm using the Gaussian function, and that's why I have to optimize the exponentiations.)
Comment: Btw, I really appreciate your answer very much because it is a very interesting approach and might work in other cases that I have not tested yet. Thank you.
Comment: In that case, perhaps something like [this](http://robowiki.net/wiki/Thread:User_talk:Rednaxela/FastTrig/Fast_gaussian_kernel_function) may help - it uses a trick explained [here](http://stackoverflow.com/questions/10552280/) and should be within about 4% of the correct value.
Comment: Thank you, this is really useful :)


How to solve the two-dimensional Laplace equation in this unbounded and multiply-connected domain?

Question: I have the Laplace equation $$\nabla^2 \phi(x,y) = 0$$
where $\phi$ is a function defined on the domain $\mathbb{R^2}\setminus(C_1 \cup C_2)$.
$C_1$ and $C_2$ are two circles of radius $r = 0.5$ and whose centers are $(0,1)$ and $(0,-1)$.
The boundary conditions are $\phi = 0$ on the bottom circumference, $\phi = 1$ on the upper circumference, and $\phi \rightarrow 0.5$ at infinity.
For reference, this problem is related to the calculation of the potential field in a two-wire transmission line. My question is the following: is it solvable analytically and, if so, how does one do it? I suppose this necessitates some sort of expansion into orthogonal functions, but what coordinate system would be the most appropriate?
Comment: There are no solution which as $\mathbf{x}\to\infty$, $\phi(\mathbf{x})$ does not tend to the average of the values on the two boundary circles.
Comment: @user10354138 you're correct, that was a mistake of mine. I'll edit the question right away.
Answer: The easiest way is use the result "harmonic iff locally real part of an analytic function" from complex analysis and transform the domain into something easier to work with.
So identifying $\mathbb{R}^2$ with $\mathbb{C}$, we choose centers $\pm\lambda i$ and send them to $0,\infty$ by a Mobius transformation $T$.  We want the resulting boundary $C_1',C_2'$ to be concentric circles of radii $\rho,1/\rho$ centered at $0$, (this can be achieved by $T(0)=1$) so then we can just "read off"
$$
\phi(z)=\frac{\log\lvert T(z)\rvert+\log\rho}{2\log\rho}
$$
by uniqueness.
So it remains to find $\lambda$, which means solving
$$
\frac{\lambda-\frac12}{\lambda+\frac12}=
\frac{\frac32-\lambda}{\lambda+\frac32}=\rho
$$
so $\lambda=\frac{\sqrt{3}}2$ and $\rho=2+\sqrt3$.
Comment: Impressive solution.
Answer: Hint: The function
$$
\phi(x,y)=\frac{1}{2}+k\ln\left(\frac{x^2+(y+a)^2}{x^2+(y-a)^2}\right)
$$
is a solution to the Laplace equation satisfying $\phi\to\frac{1}{2}$ at infinity and such that the level curves $\phi(x,y)=c$ are circumferences with center on the $y$-axis. To solve your problem, find $a$ and $k$ such that $\phi=1$ on the upper circumference (by symmetry, $\phi=0$ on the bottom circumference).


Showing non-differentiability of a function at $0$

Question:
Starting from a function $f:t\mapsto f(t)$ such that:

$f(0)=0\tag{1}$
$\liminf\limits_{t\to\infty} \sqrt{t}f\left(\dfrac{1}{t}\right)=-\infty\tag{2}$
$\limsup\limits_{t\to\infty} \sqrt{t}f\left(\dfrac{1}{t}\right)=+\infty\tag{3}$

setting:

$f_l(t)=\liminf\limits_{\delta\to0} \dfrac{f(t+\delta)-f(t)}{\delta}$;
$f^u(t)=\limsup\limits_{\delta\to0} \dfrac{f(t+\delta)-f(t)}{\delta}$.

I have to show that:

$f^u(0)=+\infty$;
$f_l(0)=-\infty$.

I succeeded in showing 1. by the following steps:
\begin{align}
f^u(0)=\limsup\limits_{t\to\infty} \dfrac{f\left(\dfrac{1}{t}\right)-f(0)}{\dfrac{1}{t}}&\geq\limsup_{t\to\infty}\sqrt{t}f\left(\dfrac{1}{t}\right)\\&=+\infty
\end{align}
with the inequality coming from $(1)$ plus the fact that $\dfrac{f\left(\dfrac{1}{t}\right)}{\dfrac{1}{t}}=tf\left(\dfrac{1}{t}\right)\geq\sqrt{t}f\left(\dfrac{1}{t}\right)$ for $t\geq1$ and the last equality following from $(3)$.

However, I cannot show 2. (I have tried to show it by the same token used for showing 1., but I did not succeed). Could you please give me some hint?
Answer: $\lim \inf_{t \to 0} \frac {f(t)} t=\lim \inf_{t \to \infty} t f(\frac  1 t)\leq \lim \inf_{t \to \infty} \sqrt t f(\frac  1 t)=-\infty$. [The inequality follows from the fact that $f(\frac 1 t)<0, t>1$ implies $tf(\frac 1 t) \leq \sqrt t f(\frac1  t)$].
Comment: @Strictly_increasing $\lim\inf g(t)=-\infty$  means there is some sequence $t_n \to \infty$ such that $g(t_n) \to -\infty$. For this sequence $g(t_n) <0$ for $n$ sufficiently large.
Comment: Why do you start from $f\left(\frac{1}{t}\right)<0$? Is this due to the starting assumption $(2)$ (i.e. $\liminf\limits_{t\to\infty} \sqrt{t}f\left(\dfrac{1}{t}\right)=-\infty$)?


simplify this css svg animation

Question: I'm working on this to have the rect to change colors. Each rect will change on a 0.1s delay.
Let's say I want to have more rectangles or path, how can I simplify the code? I think it could be simplified using scss but what about using CSS? is there a smarter way to do so rather than the way I have done?

#svg rect:nth-child(1) {
  animation: ani 1.8s linear infinite;
  animation-delay: 0.1s;
}

#svg rect:nth-child(1):hover {
  animation-play-state: paused;
}

#svg rect:nth-child(2) {
  animation: ani 1.8s linear infinite;
  animation-delay: 0.2s;
}

#svg rect:nth-child(2):hover {
  animation-play-state: paused;
}

#svg rect:nth-child(3) {
  animation: ani 1.8s linear infinite;
  animation-delay: 0.3s;
}

#svg rect:nth-child(3):hover {
  animation-play-state: paused;
}

#svg rect:nth-child(4) {
  animation: ani 1.8s linear infinite;
  animation-delay: 0.4s;
}

#svg rect:nth-child(4):hover {
  animation-play-state: paused;
}

#svg rect:nth-child(5) {
  animation: ani 1.8s linear infinite;
  animation-delay: 0.5s;
}

#svg rect:nth-child(5):hover {
  animation-play-state: paused;
}

@keyframes ani {
  0% {
    fill: #0057B8;
  }
  20% {
    fill: #F11E4A;
  }
  40% {
    fill: #F8A527;
  }
  60% {
    fill: #266D7F;
  }
  80% {
    fill: #82A;
  }
  100% {
    fill: #0057B8;
  }
}
<svg id="svg" width="401" height="275" viewBox="0 0 401 275" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="401" height="275" fill="white"/>
<rect x="50" y="91" width="57" height="57" fill="#C4C4C4"/>
<rect x="118" y="91" width="57" height="57" fill="#C4C4C4"/>
<rect x="186" y="91" width="57" height="57" fill="#C4C4C4"/>
<rect x="254" y="91" width="57" height="57" fill="#C4C4C4"/>
</svg>
Comment: What you are asking for is a code review and you should be asking such questions on the [Code Review Stack Exchange](https://codereview.stackexchange.com/)
Answer: For the :hover and base rect animation duplication, they can each be refactored into their own block.
#svg rect {
  --animation-delay: 0.1s;
  animation: ani 1.8s linear infinite var(--animation-delay);
}

#svg rect:hover {
  animation-play-state: paused;
}

I would store the animation delay in a custom property and add it to the lone animation call.
#svg rect {
  --animation-delay: 0.1s;
  animation: ani 1.8s linear infinite var(--animation-delay);
}

Now you can override the delay later when necessary, such as:
#svg rect:nth-child(3) { --animation-delay: 0.2s; }

The delay will automatically update for that child's animation.
Here's the complete code:

#svg rect {
  --animation-delay: 0.1s;
  animation: ani 1.8s linear infinite var(--animation-delay);
}

#svg rect:hover {
  animation-play-state: paused;
}

#svg rect:nth-child(2) { --animation-delay: 0.2s; }
#svg rect:nth-child(3) { --animation-delay: 0.3s; }
#svg rect:nth-child(4) { --animation-delay: 0.4s; }
#svg rect:nth-child(5) { --animation-delay: 0.5s; }

@keyframes ani {
  0% {
    fill: #0057B8;
  }

  20% {
    fill: #F11E4A;
  }

  40% {
    fill: #F8A527;
  }

  60% {
    fill: #266D7F;
  }

  80% {
    fill: #82A;
  }

  100% {
    fill: #0057B8;
  }
}
<svg id="svg" width="401" height="275" viewBox="0 0 401 275" fill="none" xmlns="http://www.w3.org/2000/svg">
  <rect width="401" height="275" fill="white" />
  <rect x="50" y="91" width="57" height="57" fill="#C4C4C4" />
  <rect x="118" y="91" width="57" height="57" fill="#C4C4C4" />
  <rect x="186" y="91" width="57" height="57" fill="#C4C4C4" />
  <rect x="254" y="91" width="57" height="57" fill="#C4C4C4" />
</svg>

jsFiddle
Comment: @Jalene By the way, you can name it anything: `var(--jellybean)`. https://developer.mozilla.org/en-US/docs/Web/CSS/--*
Comment: Thanks!! I didn't know about the `var(--animation-delay)`
Answer: All your :hover effects are the same, and so are your animation properties so you can simplify those to one rule each:
#svg rect {
    animation: ani 1.8s linear infinite;
}

#svg rect:hover {
    animation-play-state: paused;
}

that would already reduce the lines a lot, for the animation delays themselves your method is ok.
Comment: If you can use css variables you can use those and set `animation-delay: var(--delay);` and set the delay on the rect element itself: `` but otherwise no, sadly enough you cannot use the 'n' from 'nth-child' to calculate a property.
Comment: Thanks! is there a better way to handle the `rect:nth-child(N)` ? let's say for 20 rects..
Answer: If you are intrested in a CSS solution you can do something like below. It's a bit different animation but you can easily scale it by keeping the same code.
The trick is to animate the same gradient for all the boxes to simulate the color changes. Note how I made the pseudo element relative to the .box not the child elements to have the same layer

.box {
   display:inline-flex;
   margin:5px;
   padding:50px 20px;
   position:relative;
   background:right/800% 100%;
   background-image:linear-gradient(to left,#0057B8,#F11E4A,#F8A527,#266D7F,#82A,#0057B8);
   animation: ani 1.8s linear infinite;
}
.box > div {
  margin:5px;
  height:55px;
  width:55px;
  background-image:inherit;
  -webkit-mask: linear-gradient(#fff,#fff);
          mask: linear-gradient(#fff,#fff);
}
.box > div:before {
  content:"";
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background: right/1000% 100%;
  background-image:inherit;
  animation: ani 2s linear infinite;
}

.box > div:hover:before {
  animation-play-state:paused;
}

@keyframes ani {
  100% {
    background-position:left;
  }
}

simplify this css svg animation