Question in do Carmo's book Riemannian geometry section 7

Question: I have a question. Please help me.

Assume that $M$ is complete and noncompact, and let $p$ belong to $M$.
  Show that $M$ contains a ray starting from $p$.

$M$ is a riemannian manifold. It is geodesically and Cauchy sequences complete too. A ray is a geodesic curve that its domain is $[0,\infty)$ and it minimizes the distance between start point to each other points of curve.
Comment: Maybe you want $M$ to be non-compact?  (Oh, and  by the way, it is better to, when responding to comments asking for clarifications, edit the clarifications into the question text itself, instead of just putting it in the comments.)
Comment: It would help if you said what $M$ is (perhaps a manifold?) and also define what it means for such $M$ to be complete. (does it just mean convergent Cauchy sequences have limits, or what?) One more thing: is a ray a geodesic emanating from $p$ ? If so any manifold has such rays; maybe they must extend to infinity...
Comment: Using your definitions (previous comment), the claim is false. Consider the sphere. (It is geodesically complete, but the geodesics [great circles] are not length minimizing on all its domain.)
Comment: M is reimannian manifold . it is  geodesically  and Cauchy sequences complete too.ray  is a geodesic curve that its domain is [0.infinite) and it minimizes the distance between start point to each other points of curve
Answer: Take a sequence of points $(x_i)$ in the manifold whose distance from $p$ tends to infinity, and connect each of them to $p$ by a minimizing geodesic $\gamma_i(s)$.  Choose a convergent subsequence $\gamma'_{i_k}(0)$ at $p$.  Then the limit of the sequence is the desired direction of a ray.
Comment: @Vim:  Complete + bounded implies compact.  If there is a point $p$ for which every point in $M$ is a distance at most $d$ from $p$, then consider the closed ball $B$ of radius $d$ in $T_p M$.  This is a compact subset of $T_ pM$.  Further, completeness tells us that $\exp_p$ is defined on $B$.  Thus, $M = \exp_p(B)$ is the continuous image of a compact set, so is compact.
Comment: Could you please elaborate on how completeness + noncompactness imply unboundedness? Is it a consequence from the Heine Borel property (which the Riemannian manifold assumes of my memory serves)?
Answer: (This is more of a comment to Mikhail's perfectly fine answer, but it got too long.)
I just wanted to append a proof that your suggested $\gamma$ really does work.
To be more explicit, we assume $d(x_i, p) \geq i$ and that each $\gamma_i(t) = \exp_p(t\gamma_i'(0))$ (which connects $p$ to $x_i$) is unit speed.  Since the unit sphere in $T_p M$ is compact, the sequence $\{\gamma_i'(0)\}$ must have some convergent subsequence, say, with limit $v$.  I will abuse notation and use $\gamma_i'(0)$ to refer to this subsequence.  Set $\gamma(t) = \exp_p(tv)$.
Lemma:  For any fixed $t$, we have $\lim_{i\rightarrow \infty} d(\gamma(t), \gamma_i(t)) = 0$.
Proof:  Because $d$ and $\exp_p$ are continuous, $$\lim_{i\rightarrow \infty} d(\gamma(t),\gamma_i(t)) = d(\gamma(t), \exp_p(\lim_{i\rightarrow\infty} t\gamma_i'(0))) = d(\gamma(t), \gamma(t)) = 0.$$ $\square$
Now, assume for a contradiction that there is some time $t$ for which $\gamma(t)$ is not minimizing.  That is, assume there is a $t>0$ for which $d(p, \gamma(t)) < t$.
For any $i > t$, we know $d(\gamma_i(t), p) = t$.  From the lemma, we know that there is an $I$ with the property that for all $i > I$, $d(\gamma_i(t), \gamma(t)) < t -d(\gamma(t), p)$.
Then, for any $i \geq \max\{t,I\}$, the triangle inequality gives $$t = d(\gamma_i(t), p) \leq d(\gamma_i(t), \gamma(t)) + d(\gamma(t),p) < t - d(\gamma(t), p) + d(\gamma(t), p) = t$$ which gives a contradiction.
Comment: Thank you for your comment!
Comment: @Fyhswdsxjj:  It's in the line "For any $i>t$, we know $d(\gamma_i(t),p) = t$".  This is because $\gamma_i$ is minimizing from $p$ to $x_i$, so minimizes for time at least $i$.  Thus, for any $t < i$, it also minimizes.
Comment: Could you please tell me the use of "$d(x_i,p)\ge i$?
Comment: @Jason DeVito: Thank you! Is $\gamma_i(i)$ equal to $x_i$?
Answer: Otherwise suppose every geodesic emitting from p will fail to be a segment after some distance s. Since the unit sphere in the tangent plane that parameterizing these geodesics is compact, s has a maximum $s_{max}$. This means that the farthest distance from p is $s_{max}$, among all points of the manifold. So the diameter of the manifold is bounded by $2s_{max}$, by the triangle inequality. So the manifold is bounded and complete, by the Hopf–Rinow theorem, it is then compact.
Comment: I just wanted to point out that this exercise appears *before* Do Carmo has proved the fact that the distance-to-the-cut-locus function is continuous (as a map to $\mathbb{R}\cup \{\infty\}$ with the natural topology).  The existence of the max $s_{max}$ implicitly uses this continuity assumption.  That is, you have a map $d:S^{n-1}\rightarrow \mathbb{R}$ with $d(v) = s$ if the geodesic in the direction of $v$ stops minimzing at time $s$.  If you know $d$ is continuous, it has a max.  But otherwise, more work must be done.  So, this answer is correct (+1), but uses a fact not yet available.
Comment: "So the manifold is bounded and closed, as a metric space, it is then compact." I'm not sure how things are about manifolds, but it's definitely not true for general metric spaces.
Comment: @Vim: thanks. Edited referencing the Hopf–Rinow theorem.


How can I return actual JSON using Drupal?

Question: I'd like to implement a simple AJAX function locally that allows me to autocomplete node titles of already existing nodes as the user types. To that end, I need the ability to have an API that I can search on node titles. The problem is that when I output raw JSON, it comes surrounded by tags. So, no matter what I do, I keep getting...

 {json here}

I've tried implementing a custom page template that only outputs content already, that produced the same results. Here is how I am currently doing this, in my module file...
<?php

/**
 * Implementation of hook_menu()
 */
function content_relation_menu() {
    $items = array();
    $items['api'] = array(
        'title' => 'Search',
        'page callback' => 'content_relation_get',
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function content_relation_get($term = '') {
    drupal_add_http_header('Content-Type', 'application/javascript; utf-8');
    $var = json_encode(
        db_query("SELECT nid,title FROM {node} WHERE title LIKE :title LIMIT 5", array(":title" => $term.'%'))->fetchAll()
    );
    echo $var;
    exit(0);
}

How can I return JUST raw JSON?
Comment: You want the `drupal_json_output` function. See [here](http://drupal.stackexchange.com/questions/13887/an-ajax-autocomplete-textfield-in-drupal-7-doesnt-work-in-chrome) or [there](http://timonweb.com/how-create-ajax-autocomplete-textfield-drupal-7) for working examples.
Comment: Can some one show an example for Drupal 7
Comment: This is a real life example for Drupal 8: https://github.com/npinos/drupal8-greenhouse. It includes controller and routing, and returns a node count in JSON,  exposed as an endpoint.
Answer: For Drupal 6, you can use drupal_json
function content_relation_get($term = '') {
    $result = db_query("SELECT nid,title FROM {node} WHERE title LIKE :title LIMIT 5", array(":title" => $term.'%'))->fetchAll()
    );
    drupal_json($result);
    exit;
}

For Drupal 7, change it to use drupal_json_output
function content_relation_get($term = '') {
    $result = db_query("SELECT nid,title FROM {node} WHERE title LIKE :title LIMIT 5", array(":title" => $term.'%'))->fetchAll()
    );
    drupal_json_output($result);
    drupal_exit();
}

It would also probably be safer to parse out the query to sanitize, error check, etc, instead of just trying to return the result.
Comment: Just a quick note: it's generally preferable to use drupal_exit() instead of exit() after printing JSON.
Comment: @geerlingguy  Good catch; didn't notice that.  For those who don't know the difference, calling drupal_exit() will invoke hook_exit(), teardown the session, etc.
Answer: I saw that there was no answer provided for Drupal 8.
In order to process JSON in Drupal 8, use the following code:
  <?php
     use Symfony\Component\HttpFoundation\JsonResponse;
     // ...
     $options = _menu_get_options(menu_get_menus(), $available_menus, array('mlid' => 0));
     return new JsonResponse($options);
  ?>

You can read more about it here


How to get the time difference between two times in Javascript?

Question: I have two times, say timeS = '00.00.00' and timeE = '10.00.00'
I want to get the time difference between the two times. One way is the following manner,
//create date format
var timeStart = new Date("01/01/2007 " + timeS).getHours();
var timeEnd = new Date("01/01/2007 " + timeE).getHours();

var hourDiff = timeEnd - timeStart;

Here, I had to get the desired result using the Date format. Is there any other way to achieve this, without explicitly making a Date object?
Note: Instead of marking it a duplicate, do observe that I am asking for some other alternative ways.
Comment: Why is making Data object so bad for you?
Comment: @NoOorZ24, No its not bad for me. All I am interested in is to find some alternative solutions. You can call it a touch of "curiosity"
Comment: `'10:00:00'.split(':').reduce((sum, curr) => sum * 60 + +curr, 0)`
Comment: Do not use the built-in parser, particularly for non–compliant strings. See  [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results)
Answer: Convert the hh.mm.ss format into equivalent seconds by parsing.

var timeS = '00.00.00';
var timeE = '10.00.00';

function convertToSeconds(timeString) {
    var timeSplit = timeString.split('.');
    return timeSplit.reduce((result, item, index) => {
        return result + Number(item) * Math.pow(60, timeSplit.length - index - 1)
    }, 0);
}

const secondDifference = convertToSeconds(timeE) - convertToSeconds(timeS);

console.log(secondDifference);
Comment: The arrow function can be reduced to `return timeSplit.reduce((result, item, index) => result + item * Math.pow(60, timeSplit.length - index), 0)`. ;-)
Comment: @Saswat just fixed a bug in this, if you copied this for use, please note.
Answer: You need to convert this time to a Date first
var convertToMS = time => {
   var d = new Date(1,1,1);
   d.setHours.apply( d, time.split(".").map( Number ) );
   return d.getTime();
};

var diffOutput = convertToMS( timeE ) - convertToMS( timeS );

Demo

var convertToMS = time => {
  var d = new Date();
  d.setHours.apply(d, time.split(".").map(Number));
  return d.getTime();
};

var timeS = '00.00.00';
var timeE = '10.00.00';

var diffOutput = convertToMS(timeE) - convertToMS(timeS);
console.log(diffOutput)

Edit
As suggested by @RobG, check this alternate solution using UTC
var convertToMS = time => Date.UTC(1,1,1, ...time.split('.'));

Comment: This is prone to rare bugs due to daylight saving affecting the time value. A Date object should really only be used where dates are involved.
Comment: @RobG How is the above code prone to bugs due to daylight savings. Please share.
Comment: You're setting the local time. If the first time is before the daylight saving change and the second time is after, there will be a discrepancy equal to the daylight saving offset, either minus or plus, depending on whether going into or out of daylight saving respectively.
Comment: @RobG In that case, if I change it to use `new Date(1,1,1)`, then all invocations will use the same data and given time only, right?
Comment: Yes (noting that creates a date for 1901-02-01) and assuming it doesn't coincide with a daylight saving boundary anywhere (which seems likely), or use UTC, so the function becomes `var convertToMS = time => Date.UTC(1,1,1, ...time.split('.'))`.


R - how to transform the similarity matrix to distance matrix for performing hierarchical clustering?

Question: I am trying to cluster nodes (C1, C2, C3...) of a graph using hclust and my similarity metric is number of links between nodes.
I have data like
c = matrix( c(0,1,3,1,0,5,3,5,0), nrow=3, ncol=3)

Basically this is a similarity matrix
    C1  C2  C3
C1  0   1   3
C2  1   0   5
C3  3   5   0

This is an undirected graph where similarity between C1 and C3 is 3 links. I need to transform this data to a suitable dist.matrix like
    C1  C2
C2  1
C3  1/3   1/5

format based on my similarity metric (#links between two nodes). How do I do this?
Answer: It looks like you just want your distances to be 1/c.
The print method for a distance matrix prints it in the format you want.
Which suggests as.dist(1/c).
> as.dist(1/c)
          1         2
2 1.0000000
3 0.3333333 0.2000000

Is that what you're after?
If you want the diagonal distances to be zero, then you might replace 1/c there with (say) ifelse(c==0,0,1/c). It should still print the same.
Comment: Appreciate your efforts. [This](http://stackoverflow.com/questions/27004890/how-to-transform-the-following-similarity-matrix-to-distance-matrix-for-performi) is more appropriate to what I need.


What class of non linear functions can be modeled by a neural network

Question: If machine is viewed as function approximation, what class of functions are modeled by a neural network?
Comment: Without any further restrictions, the answer is: any class. That's because you could have a neuron for each function in your function class.
Comment: Basically any function if you can do it, and no functions if you cannot.
Comment: @fabee: Not if your function class is infinite (most are). A reasonable assumption is with finite neurons *and* finite training samples, maybe linear in the number of neurons.
Comment: @Nimrod: That's not what the OP asked. I agree that the question gets much more interesting when phrased your way.
Answer: Artificial neural network: computational power (Wikipedia):

The multi-layer perceptron (MLP) is a universal function approximator,
  as proven by the Cybenko theorem. However, the proof is not
  constructive regarding the number of neurons required or the settings
  of the weights.
Work by Hava Siegelmann and Eduardo D. Sontag has provided a proof
  that a specific recurrent architecture with rational valued weights
  (as opposed to full precision real number-valued weights) has the full
  power of a Universal Turing Machine using a finite number of
  neurons and standard linear connections. They have further shown that
  the use of irrational values for weights results in a machine with
  super-Turing power.

Cybenko, G.V. (1989). Approximation by Superpositions of a Sigmoidal function, Mathematics of Control, Signals, and Systems, Vol. 2 pp. 303–314.
Siegelmann, H.T. and Sontag, E.D. (1994). Analog computation via neural networks, Theoretical Computer Science, v. 131, no. 2, pp. 331–360.
Answer: Actually a three layer neural network can model arbitrary function with the linear and logistic functions, which was proved by Kolmogorov in 1957 (Kolmogorov, Andrei Nikolaevich. "On the representation of continuous functions of many variables by superposition of continuous functions of one variable and addition." Dokl. Akad. Nauk SSSR. Vol. 114. No. 5. 1957.).
Comment: not "arbitrary" -- see "continuous."


Armazenar CSS em string

Question: .ql-snow .ql-tooltip{background-color:#fff;border:1px solid #ccc;box-shadow:0 0 5px #ddd;color:#444;padding:5px 12px;white-space:nowrap}.ql-snow .ql-tooltip::before{content:"Visit URL:";line-height:26px;margin-right:8px}.ql-snow .ql-tooltip input[type=text]{display:none;border:1px solid #ccc;font-size:13px;height:26px;margin:0;padding:3px 5px;width:170px}.ql-snow .ql-tooltip a.ql-preview{display:inline-block;max-width:200px;overflow-x:hidden;text-overflow:ellipsis;vertical-align:top}.ql-snow .ql-tooltip a.ql-action::after{border-right:1px solid #ccc;content:'Edit';.ql-snow .ql-tooltip a.ql-action2::after{border-right:1px solid #ccc;content:"Cancel";}

Existe algum site online que converte HTML, ou CSS em string, para jogar tudo dentro de uma variável?  Por exemplo:
Coloco no form isso:
body {
 margin:0;
 padding: 0;
}

Ele me retornaria algo como isso, fazendo toda tratativa de escape:
var css = 'body{margin:0;padding:0}';

Se fosse em PHP, eu faria assim:
$var =  <<<END
   .ql-snow .ql-tooltip{background-color:#fff;border:1px solid #ccc;box-shadow:0 0 5px #ddd;color:#444;padding:5px 12px;white-space:nowrap}.ql-snow .ql-tooltip::before{content:"Visit URL:";line-height:26px;margin-right:8px}.ql-snow .ql-tooltip input[type=text]{display:none;border:1px solid #ccc;font-size:13px;height:26px;margin:0;padding:3px 5px;width:170px}.ql-snow .ql-tooltip a.ql-preview{display:inline-block;max-width:200px;overflow-x:hidden;text-overflow:ellipsis;vertical-align:top}.ql-snow .ql-tooltip a.ql-action::after{border-right:1px solid #ccc;content:'Edit';.ql-snow .ql-tooltip a.ql-action2::after{border-right:1px solid #ccc;content:"Cancel";}
END;

Preciso fazer isso para gerar um PDF:
var valor1 = 'aqui viria o css minificado com as aspas escapada';
var valor2 = 'mais CSS aqui...';

 $('.main').prepend('');

OBS: Minha pergunta está clara, o problema é que as pessoas não entenderam, e por isso estou tendo que que acrescentar mais informação, para esclarecer para aqueles que não conseguem compreender o que está óbvio:

1 - Não estou procurando uma solução para minificar o CSS
2 - Estou procurando uma solução para jogar o CSS minificado dentro de uma variável com uma string dentro de aspas.
3 - Não quero fazer a string manualmente (ou seja, não quero digitá-la), quero gerar uma string no formato de string e não do seu valor.
Comment: Não é capturar o valor e remover as quebras de linha e espaços?
Comment: Sim, eu preciso desse css em valor... Mas não só esse... manualmente, dá muito trampo.
Comment: Eu tentei [nesse site](https://www.freeformatter.com/javascript-escape.html), mas não achei nada.
Comment: Não dá trabalho, veja a resposta do jbueno.
Answer: Eu não sei se entendi bem o que você quer, porque não entendi a utilidade disto, mas acho que tudo que precisas é remover as quebras de linhas e espaços do texto.

document.getElementById('btn-remover').addEventListener('click', fnClick);

function fnClick(){
  var val = document.getElementById('txt-css').value;
  val = val.replace(/[\s]/g, ' ');
  console.log(val);
}
textarea {
  height: 300px;
  width: 300px;
}
<textarea id="txt-css"></textarea>

<button id="btn-remover">Remover</button>
Comment: ué, explique o que "não deu certo" então para o autor melhorar a resposta.
Comment: @IvanFerrer nesse caso você precisa detalhar o que não deu certo.
Comment: É quase isso, só que não deu certo.
Comment: Pois é, eu tou ainda esperando o _feedback_ XD
Comment: O que não deu certo, o resultado do seu filtro, não dá pra colar entre aspas simples. o 'Edit' e o "Cancel" continuam com as mesmas aspas. Se for aspas simples, deveria ser 'Cancel' e \"Cancel\" ,inversamente, "Cancel"e '\Cancel\' .
Answer: Fiz este exemplo me baseando na resposta do @jbueno tentando mexer no que eu acho que era sua expectativa. Veja se te atende.

document.getElementById('btn-remover').addEventListener('click', fnClick);
var str = document.getElementsByTagName('style')[0].firstChild.data;
var textArea = document.getElementById('txt-css');

function fnClick() {
  var val = str.replace(/\s+/g, ' ');
  console.log(val);
  textArea.innerHTML += val;
}
textarea {
  height: 150px;
  width: 300px;
}
<textarea id="txt-css"></textarea>

<button id="btn-remover">Remover</button>

ESCAPANDO ASPAS
Aqui o código troca todos os " por \":

document.getElementById('btn-remover').addEventListener('click', fnClick);
var str = document.getElementsByTagName('style')[0].firstChild.data;
var textArea = document.getElementById('txt-css');

function fnClick(){
  var val = str.replace(/\s+/g, ' ');
  var newVal = val.replace(/"/g, '\\"');
  console.log(newVal);
  textArea.innerHTML += newVal;
}
textarea {
  height: 150px;
  width: 300px;
}
.escaped {
  content: "http://urlAleatório.com";
}
<textarea id="txt-css"></textarea>

<button id="btn-remover">Remover</button>

DENTRO DE ASPAS
Aqui, além de trocar as aspas, a variável é criada já dentro das ' '.

document.getElementById('btn-remover').addEventListener('click', fnClick);
var str = document.getElementsByTagName('style')[0].firstChild.data;
var textArea = document.getElementById('txt-css');

function fnClick(){
  var val = str.replace(/\s+/g, ' ');
  var escVal = val.replace(/"/g, '\\"');
  var newVal = "'" + escVal + "'";
  console.log(newVal);
  textArea.innerHTML += newVal;
}
textarea {
  height: 150px;
  width: 300px;
}
.escaped {
  content: "http://urlAleatório.com";
}
<textarea id="txt-css"></textarea>

<button id="btn-remover">Remover</button>

FOLHA DE ESTILO SEPARADA
Esta opção funcionará apenas usando uma folha de estilo separada e fará tudo o que a última opção faz. Esta função também irá substituir todas as aspas simples em aspas duplas escapadas. Se estiver fazendo offline, o Chrome pode dar erro de segurança pois ele não deixa o js fazer esta função. Nesse caso, você precisaria iniciar o Chrome com websecurity disabled, ou fazer o teste com arquivos online.

document.getElementById('btn-remover').addEventListener('click', fnClick);
var textArea = document.getElementById('txt-css');
var str;
$.ajax({
  url: 'style.css',
  success: function(data) {
    str = data;
  }
});

function fnClick() {
  var val = str.replace(/\s+/g, ' ');
  var escVal = val.replace(/"/g, '\\"');
  var escVal = escVal.replace(/'/g, '\\"');
  var newVal = "'" + escVal + "'";
  console.log(newVal);
  textArea.innerHTML += newVal;
}

  <link rel="stylesheet" type="text/css" href="style.css" />

<textarea id="txt-css"></textarea>

<button id="btn-remover">Remover</button>
Comment: A sua resposta é a que mais se aproxima, porém, vc removeu as aspas, eu gostaria de tratar ela para este formato quando for as dupla:  \" neste formato.
Comment: @IvanFerrer Não entendi. Você gostaria que a variável já viesse com aspas em sua volta? Tipo: `'body { repare nas aspas: 0px; }'` ? Seria isso?
Comment: @IvanFerrer Ou você quer transformar todas as `"` em `\"` na string criada?
Comment: @IvanFerrer Botei um EDIT escapando as aspas. Vê se é isso.
Comment: `{
  "message": "Uncaught TypeError: Cannot read property 'replace' of undefined",
  "filename": "https://stacksnippets.net/js",
  "lineno": 30,
  "colno": 16
}`
Comment: @IvanFerrer Você leu minha descrição? Este último exemplo é para folhas de estilo separadas. Logicamente não funciona aí. Pegue o exemplo e use no seu PC com sua folha de estilo e substitua no código o `url: 'style.css',` pelo caminho e o nome da sua folha de estilo. Coloquei 4 exemplos. Algum deve ser o que procura. xD
Comment: ok, vou testar aqui.
Comment: Testei aqui, ele emputou o CSS no textarea, ele até colocou barra invertidas nas aspas, só que continua quebrando, pois tem aspas duplas e aspas simples, não funcionou. Acredito que está invertido..., seria aspas duplas não, para este caso... a string, fecha com aspas duplas?
Comment: @IvanFerrer Completa pra mim. O que exatamente você quer que aconteça com cada tipo de aspas? Aspas simples: `'` devem virar o que? Aspas duplas: `"` devem ser o que?
Comment: Nesse exemplo eu fiz com que já tivesse aspas simples no início e no fim, se bem entendi, você quer que eu transforme todas as aspas internas em `\"`. Correto?
Comment: @IvanFerrer Fiz uma nova edição, por favor leia o que está escrito em cima do exemplo. Presta atenção somente que este código já bota aspas simples em volta do resultado, se preferir dá para tirar esta opção.
Comment: funcionou, só tive que trocar assim:  `var newVal = "\"" + escVal + "\";";`
Comment: @IvanFerrer Show! Boa sorte aí agora! :)
Answer: Talvez seja isso:
<!DOCTYPE html>

Click the button to display the style properties of this document.

<button onclick="myFunction()">Try it</button>

Fonte
Comment: Sua resposta é interessante, porém, meu estilo está vindo de um arquivo style.css, então não tem como eu fazer desta forma.

Armazenar CSS em string


If an integer number is a square and a cube, then it can be writen as $5n,5n+1$, or $5n+4$

Question: I want to show that if an integer number is a square and a cube, then it can be writen as $5n,5n+1$, or $5n+4$.
I tried the following. There are integers numbers $x,y$ such that $n=x^{2}=y^{3}.$ By using Euclidean division, then $x$ and $y$ can be writen as $5k,5k+1,5k+2,5k+3$ or $5k+4.$ If $x=5k$ and $y=5l$ we have $n=5(5k^{2})=5(5^{2}l^{3})$. If $x=5k$, then we must have $y=5l.$ I don't know what to do. Any hint?
Comment: Use unique factorization to see that if $n$ is both a square and a cube, then it must be a sixth power. Then show that $(5k+r)^6$ has one of those three forms for $r=0,1,2,3,4$.
Comment: The y^3 restriction is irrelevant. $0^2 \equiv 0 \pmod 5,$ then $1^2 \equiv 1 \pmod 5,$  then $2^2 \equiv 4 \pmod 5,$  then $3^2 \equiv 4 \pmod 5,$  then $4^2 \equiv 1 \pmod 5.$ Or, for instance, if $x = 5 k + 1,$ then $x^2 = 25 k^2 + 10 k + 1 = 5 (\mbox{stuff}) + 1.$ Or,   if $x = 5 k + 3,$ then $x^2 = 25 k^2 + 30 k + 9 = 5 (\mbox{stuff}) + 4.$
Comment: Try listing the first few squares and cubes and seeing what remainder you get when you divide by 5. That should not take long and may reveal a pattern you can prove.
Answer: Already if an integer is a square it must be of the shapes you have described.
It is easiest to prove this using congruence notation. Any integer is congruent to $0$, $1$, $2$, $3$, or $4$ modulo $5$. Note now that $0^2$, $1^2$, $2^2$, $3^2$, and $4^2$ are respectively congruent to $0$, $1$, $4$, $4$, and $1$ modulo $5$, so never to $2$ or to $3$ modulo $5$.
If we do not want to use congruence notation, calculate the remainder when $(5k)^2$, $(5k+1)^2$, $(5k+2)^2$, $(5k+3)^2$, and $(5k+4)^2$ are divided by $5$. As a sample, let's do it for $(5k+3)^2$. This is $25k^2+30k+9$, which is $5(5k^2+6k+1)+4$, so it has remainder $4$ on division by $5$.
Out of curiosity, let us explore the cubes modulo $5$. Note that $0^3$, $1^3$, $2^3$, $3^3$, and $4^3$ are congruent respectively to $0$, $1$, $3$, $2$, and $4$ modulo $5$. So, unlike squares, cubes can take on any value modulo $5$.
By looking at the numbers $0$, $1$, and $64$, which are all perfect squares and perfect cubes, we can see that indeed a number which is a perfect square and a perfect cube can be of any of the shapes described.
Answer: Hint $\ $ The squares mod $5$ are $\rm\:\{0,\pm1, \pm2\}^2 \equiv \{0,1,4\},\:$ so the cube condition is redundant.
Answer: Very late but here's a slightly different way (similar to that of Andre's):
$$
n=a^3=b^2
$$
clearly means, a is a square of some integer and b is a cube of some (other) integer, so
$$
n=x^6=(10*m+n)^6.
$$
since, we are concerned only with the first digit, the sixth powers (mod 10) for the first 10 numbers:
$$
0, 1, 4, 9, 6, 5, 6, 9, 4, 1
$$
which are of the form
$$ 5k, 5k+1, 5k+4 $$


Struts2 + spring autowiring actions by-name without exposing certain properties

Question: I am using Struts 2 and Spring autowiring. Right now, the default strategy is set to by-name, but usually we use the constructor and the fallback works to autowire in properties when only one implementing class is available.
There is one property however that I'd like to wire into an action class that has several implementing classes, so I made the Action a java bean, with the properties as fields that can be set. Unfortunately, the only ways that these will be used (apparently) is if they have a public getter/setter, which also exposes them to the type converter at request time. In other words, if a client adds their name to the request as form fields or parameters, Struts will attempt to write those values to them.
So my question is, is it actually possible to use by-name autowiring without exposing properties like that (which may or may not be a security hazard), or am I better off just using XML and defining the Action as an object with scope prototype?
Comment: I am not sure what you mean by `type converter at request time`
Comment: @UmeshAwasthi I've tried to clarify that further.
Comment: you can easily tell S2 param interceptor to excludes certain parameters being set in your action class
Answer: I did eventually track down the documentation for the ParametersInterceptor which actually lists three ways you can limit what parameters are set by the interceptor.

Configuring excludeParams in the parameter configuration, which is a global regex which applies to all actions (not what I want, also possibly deprecated as it is no longer described in the most recent class docs).
Setting excludeMethods (does the same as the previous, the preferred method for global excludes)
Implementing ParameterNameAware, which is the closest to what I wanted. Here  you can whitelist what parameters are used.

In the end, defining the action as a prototype object in the normal Spring configuration seemed to be the most prudent. Letting the action manage what parameters it has means another place where parameters need to be explicitly white listed every time a change is made.
Comment: I'm not sure what you are doing... but you can inject into protected and private members. Here is a short example: http://struts2.myxwiki.org/xwiki/bin/view/Struts2/Adding+Spring+Dependancy+Injection+to+Struts2+Project In this case Test is a protected member.
Comment: @Quaternion I'm not using annotation based config. When I try to just rely on automatic autowiring, it only injects them when they're public. If you use your approach, does it scope the actions properly?


Please clarify values for STM32 SYSCFG_EXTICR registers

Question: The following is an excerpt from the STM32F0x1 reference manual:

There are a lot of x's in play here. They all seem to be referring to the external interrupt number (i.e. EXTIx), but what is the x circled in red? It's a part of the binary number, so it is either 0 or 1, not the interrupt number or pin number. The documentation mentions nothing about what it means when it's 0 and when it's 1. If I dig through the header files, it seems this x is always zero.
Is the documentation just incomplete, or did I miss something or am I misunderstanding?
Answer: The documentation states that the meaning of the x-bit (the left-most bit) is reserved - i.e. it has no documented meaning for the time being.
As you indicate that the header-files always leave it as 0, this is what you want to use yourself.
It is usually documented this way because a new variant of the MCU might be offered later with a different configuration (i.e. other peripherals or similar) - and in those configurations the bit could then be documented to have a distinct meaning.


2D standardization of a matrix

Question: Given an n-by-n matrix $A$, and using only linear transformation on each of the rows and columns of $A$ (total of $2n$ transformations), is there a way to double-standardize a matrix, so that each row and each column have zero mean and unit variance?

Define centering matrix as follow:
$$ C_n = I_n-\frac{1}{n}O_n $$
where $I_n$ is the identity matrix of size $n$ and $O_n$ is an n-by-n matrix of all 1's.
An n-by-n matrix $X$ is called doubly-centered if:
$$ X = C_n X C_n $$
A matrix is doubly centered, iff the mean of each row and each column is $0$.
It's a common practice in many fields to standardize data into zero mean and unit variance, given a set of numbers with mean $\mu$ and standard deviation $\sigma$, the following linear transformation will standardize that set:
$$ g(x) = \frac{x-\mu}{\sigma} $$
It's easy to double-center a matrix, using only row/column linear transformation, by subtracting the mean of every row/column and adding back the grand mean of the whole matrix.
It's also easy to standardize all rows (or columns) of a matrix using only $n$ linear transformations, one for each row (see $g(x)$ above).
What I'm trying to do is to simultaneously standardize all rows and columns of a matrix in a similar way, is it possible?
Comment: I assume the problem could be solve iteratively until the error will be as small as desired but it's not the kind of solution I'm looking for
Answer: This can be solved iteratively, see Olshen & Rajaratnam 2010.  The solution is not unique: the outcome depends on whether you start with rows or columns first.

2D standardization of a matrix


How to selectively deep-copy in python?

Question: I have multiple python classes.  Objects of one of the classes (say, class1)has a large amount of data in it (it will not be altered during runtime). Another class (say class2) has a member variable which maps to one of the objects of class1.  Assume class1 and class2 have other both mutable and immutable member variables.
Now i want too do a deepcopy of an object of class2.  It will also make a deepcopy of the class1 object in class2.  but to save memory, i want to avoid that. how do i do this?
class class1:
    def __init__(self):
        self.largeData = None
        self.mutableVar = None
        self.immutableVar = None

class class2:
    def __init__(self, objc1: class1):
        self.objc1 = objc1  # of the type class1
        self.mutableVar = None
        self.immutableVar = None

c1_1 = class1()
c1_2 = class1()

c2_1 = class2(c1_1)

c2_1Copy = copy.deepcopy(c2_1)
# i want c2_1Copy to reference the same objc1 as c2_1,
# but different mutablevar and immutablevar

c2_2 = class2(c1_2)  # Note: cannot use static variable

please help me with this...
thanks in Advance
Comment: Implement your own `copy` and `deepcopy` in `class2`. See [Best practice to implement copy method](https://stackoverflow.com/a/45094347/8150685)
Comment: You can implement `__deepcopy__` as to not copy some members for that class.
Answer: Use the __deepcopy__ hook method to customize how your objects are deep-copied.
import copy

class LargeDataContainer:
    def __init__(self):
        self.data = "x" * 800

class Thing:
    def __init__(self, large_data: LargeDataContainer):
        self.large_data = large_data
        self.x = [1, 2, 3]

    def __deepcopy__(self, memo):
        new_inst = type(self).__new__(self.__class__)  # skips calling __init__
        new_inst.large_data = self.large_data  # just assign

        # rinse and repeat this for other attrs that need to be deepcopied:
        new_inst.x = copy.deepcopy(self.x, memo)
        return new_inst

ldc = LargeDataContainer()

t1 = Thing(ldc)
t2 = copy.deepcopy(t1)
assert t1 is not t2
assert t1.large_data is t2.large_data
assert t1.x is not t2.x

How to selectively deep-copy in python?


Given results of an A/B Test which variation should be preferred in tests?

Question: It's my first question here, so please pardon if I don't formulate everything correct.
Let's imagine we are running an time-independent test of 2 variations that both have a probability to achieve a goal (f.e. conversion on a website).
Now let's say we have done 10,000 tries and each variation got 5000 of those tries/users. One variation is leading, but we don't know who the winner is with enough statistical significance.F.e. A has a 1.5% conversion rate and B a 1% conversion rate.
Is it still better to give both variations equal tests, or is it likely that more tests for A or B would lead us to a statistical significance faster?
Answer: It depends on the variance of the population. If it turns out that conversions from A have a higher variance than conversions from B, then to achieve equal bounds on each estimate, you'll need more tests of the former than the latter.
It seems that in proportion testing people often assume the maximum variance for establishing the number of tests to perform (see the Wiki entry ). But in general, how "long" it takes to converge on a mean value will depend on the population variance.
Comment: I think "conversion" here means something like "visited webpage version A and then bought the product" not "changed from A to B".
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/123086/discussion-between-julian-wagner-and-user20672).
Comment: Thanks @Henry. It's still earlier where I'm at :)
Comment: Variance in that case could be depending on the probability. So the one p closer to to 0.5 will be the one with higher variance. Implying that at same n level the variation with as said p closer to 0.5 should get the next try. Ideally you would calculate the variance of both before each test and give the one with the higher variance your next try? Is that correct?
Comment: If it were me, I would boostrap the samples I have right now to estimate the variance in the conversion rate for both populations given a fixed bootstrap sample size, say $m=1000$. Then I would choose my next test (A or B) propotional to the ratio of the variances $\sigma_A^2 / \sigma_B^2$. Let me know if you need me to clarify that strategy at all
Comment: To relate it to your comment @JulianWagner, I probably would not recompute the variance each time and test the more uncertain of A or B. Instead, I would establish how much more often I need to test one than the other to get equal confidence in each and randomly schedule by that proportion (which happens to be the ratio of variances that I mentioned estimating with a bootstrap). After you've accrued a lot more samples, re-estimate the variances and adjust the ratio.
Comment: No I could understand your strategy just fine. I don't have practical implementations anyway. I was just wondering why none of the established A/B test platforms offer a strategy like this.
Comment: Great question. If you assume out-of-the-gate that "hey these should have pretty much the same variance in conversion, right?" then you'll arrive mathematically at the conclusion to test A and B the same amount. However, it's not clear that assumption is always true; so, it does seem like a good feature to support. It also has me thinking about other questions like "is it enough to compare the average conversion? Or do we care about the flow of conversions, i.e., is it better to have some conversions consistently or more conversions, but inconsistently?" A robustness question, of sorts
Comment: Following up on my previous comment, someone might be more interested in the coefficient of variation of the conversion rates, $\mu / \sigma$,  for example, which essentially normalizes by the uncertainty.
Comment: It could also be that the potential win is just too small, but the biggest problem with AB tests is they take time. And it's not just on websites. There are tons of tests/algorithms that might be improved by a feature like this. For websites one could argue that results get flawed if you show different weights on different times. For example if A gets shown more often Tuesday, but Tuesday is better than Friday this would alter the results
Comment: You raise another good point. If you have observable correlation between the outcome and other factors, e.g. the day of the week, then these should be discerned and accounted for. You can and should disentangle the effects. I could go on about this all day, but I think I've already had to edit my comments to satisfy the character limit twice now lol, so I should probably bite my tongue instead
Answer: This is really about power calculations, finding the sample sizes that maximise the probability that the test rejects the null hypothesis that the two conversion rates are equal, when in fact a specific alternative hypothesis is true.
It is sensitive to a large number of factors, including the precise test used, the  statistical significance criterion used, and population rates, as well as the underlying distribution and parameters (here a binomial distribution - so discrete).  There is also the question that you would be doing the test because you are not certain whether there is a difference, and so would not have a justification for making the sample sizes different if you do not have to.
The chart below gives my calculations for the power for different sample sizes for $B$ and the rest of the $10000$ for $A$, using a chi-squared test (no continuity correction) with significance $0.95$ if the true population probability of conversion is $0.015$ for $A$ and $0.01$ for $B$.
It suggests that the power in this case is maximised when the sample size for $A$ is slightly less than half, possibly because this gives $B$ more chance of producing some conversions close to the population proportion; this is not a simple variance argument, as the Bernoulli variance $p(1-p)$ is higher for $A$.  It also suggests some local volatility: the power for $4572$ is about $0.6346$ while for $4573$ is noticeably smaller at about $0.6136$, but this is consequence of the precise values of $0.95$ and $0.015$ and $0.01$ and this step down could disappear if they were marginally different.
I think the message from this is that, given the choice, make the two sample sizes broadly equal.  If for some reason that is not possible, then consider oversampling the less common scenario so as to make the effective sample sizes less unequal, in order to increase the power.
Comment: To clarify, what I suggest in the comments looks at the variance in the estimator $\hat{p}$, not the variance of samples drawn from the distribution. This wasn't clear in my answer though
Comment: Though my argument is for equal confidence in each estimator, rather than significance in a hypothesis, so your point is taken


Real analyticity of a function

Question: This is copy of statement in this link.
If $f$ is an infinitely differentiable function defined on an open set $D \subset \mathbb{R}$, then the following conditions are equivalent.

$f$ is real analytic.
For every compact set $K \subset D$ there exists a constant $C$ such that for every $x \in K$ and every non-negative integer $k$ the following estimate holds:
$$ \left| \frac{d^k f}{dx^k}(x) \right| \leq C^{k+1} k!$$

It is also said that a function is analytic if and only if its Taylor series converges to that function. please let me know how these two statements are equivalent. Also I don't understand the term 'estimate' in the second statement.
Comment: "Estimate" just means "inequality."  Also, the _definition_ of "analytic (at a point $x = a$)" is that the function's Taylor series (centered at $x = a$) converges to that function.
Comment: If possible someone please make the text in the question uniform with equations visible. I am not able to figure out how to do this.
Comment: @Rajesh: Is this ok?
Comment: @Theo Buehler : thank you. Please let me know how you did this.
Comment: First of all, I removed the blanks at the beginning of the paragraphs (four blanks result in a `code` section). Second, I replaced `1)` and `2)` by `1.` and `2.` in order for it to be displayed as a ordered list. Third, I replaced the single dollar signs `$...$` in the displayed formula by `$$...$$` and dit some minor LaTeX-tweaking. The details can be seen by clicking on "x mins ago" above my name.
Comment: @Theo Buehler : thank you
Comment: Since $K$ is compact and $f$ infinitely differentiable you can obviously pick $C_N$ such that for every $k\leq N$ we have $|\partial^k f(x)|\leq C_N^{k+1}k!$ for every $N\in\mathbb N$. Now use convergence of the taylor expansion to show that for $N$ large enough $2C_N$ satisfies your constraints locally, then use compactness again to get a "global" version.
Answer: We say that $f\colon D \to \mathbb{R}$ is analytic if for every $x_0 \in D$ we have
$$f(x)=\sum_{n=0}^\infty \frac{f^{(n)}(x_0)}{n!}(x-x_0)^n$$
for all $x$ in a neighborhood of $x_0$. If this is the case, then we can consider the following complex power series
$$F(z)=\sum_{n=0}^\infty \frac{f^{(n)}(x_0)}{n!}(z-x_0)^n$$
which is convergent in a complex neighborhood of $x_0$. This procedure yields an analytic complex function $F$ of one complex variable that extends $f$ and can be used to obtain claim $2$ from claim $1$.
To see this fix $x_0 \in D$ and $r >0$ so small that the complex disc $D(x_0, r)$ centered at $x_0$ and of radius $r$ is contained in the domain of $F$ with its boundary. By the Cauchy's integral formula we can express every derivative of $F$ in integral terms:
$$F^{(n)}(x_0)= \frac{n!}{2 \pi i}\int_{\{\lvert z- x_0\rvert = r\}} \frac{F(z)dz}{(z-x_0)^{n+1}}$$
yielding the estimate
$$\lvert F^{(n)}(x_0) \rvert \le \frac{n!}{2\pi r^{n+1}}2 \pi r \max_{z \in D(x_0, r)} \lvert F(z) \rvert =\frac{n!}{r^n} \lVert F \rVert_{\infty, D(x_0, r)}.$$
Observe that $F$ and $f$ agree in $x_0$ with all their derivatives, so the last formula is very similar to claim 2. To conclude the proof choose an arbitrary compact $K \subset D$. We can cover it with a finite number of intervals $[x_1-r_1, x_1 + r_1] \ldots [x_p - r_p, x_p +r_p]$ like the ones in the previous step. In particular every disc $D(x_j, r_j)$ is contained in the domain of $F$. Call $H$ the union of such discs: obviously $\lVert F \rVert_{\infty, D(x_j, r_j)} \le \lVert F \rVert_{\infty, H}$. So for all $x \in K$ we have (edited shaded area)

$$
\begin{split}
\left\lvert \frac{d^n f}{dx^n}(x) \right\rvert &\le n!\left(\dfrac{1}{\displaystyle \operatorname{min}_{j=1\ldots p}r_j}\right)^n\lVert F \rVert_{\infty, H}\\
&=n! (C_{K, f})^n \|F\|_{\infty, H},
\end{split}
$$
  where $C_{K, f}$ stands for "a positive number that depends only on $K$ and $f$". Now observe that $\|F\|_{\infty, H}\le \|F\|_{\infty, K}$ and that
  $$(C_{K, f})^n \|F\|_{\infty, K}\le\tilde{C}_{K, f}^{n+1}, $$
  with $\tilde{C}_{K, f}=\max(C_K, 1)\cdot\max(\|F\|_{\infty,K}, 1)$. (We put an exponent $n+1$ to encompass the case $n=0$ as well). We conclude that
  $$\left\lvert \frac{d^n f}{dx^n}(x) \right\rvert\le \tilde{C}^{n+1}_{K, f} n!, $$
  which is claim 2. (Note that the "constant" is not really so since it depends on $K$ and $f$. The crucial fact is that it does not depend on $n$).

To see the converse we don't need any complex analysis. Fix $x_0 \in D$ and expand $f$ in a Taylor series up to order $n$ with Lagrange remainder form:
$$f(x)=\sum_{k=0}^n \frac{f^{(k)}(x_0)}{k!}(x-x_0)^k+ \frac{f^{(n+1)}(\xi)}{(n+1)!}(x-x_0)^{n+1}.$$
We need to prove that, for all $x$ in a neighborhood of $x_0$,  $$\lim_{n \to \infty}  \frac{f^{(n+1)}(\xi)}{(n+1)!}(x-x_0)^{n+1}=0.$$
This follows from claim 1 because
$$\left\lvert\frac{f^{(n+1)}(\xi)}{(n+1)!}(x-x_0)^{n+1}\right\rvert \le C^{n+2}\lvert x-x_0 \rvert^{n+1}=C(C \lvert x-x_0 \rvert)^{n+1}$$
and $(C \lvert x-x_0 \rvert)^{n+1}\to 0$ if $\lvert x-x_0 \rvert < 1/C$.
Comment: I bumped into this and I just want to ask: How did you conclude "So the last formula is essentially claim 2 if the chosen compact K is the interval $[x_0−r,x_0+r]$?" The inequality holds for $x_0$. But choosing a different $x$ from that interval will have effect on the Cauchy estimate; namely, the $r$ will have to be made smaller.
Comment: Hoping to get a reply from you. Thanks.
Comment: @AlexStrife: Hi, sorry for the delay. I edited the answer, trying to improve clarity. The compactness argument that follows that remark you noticed is there precisely to eliminate that dependence on $r$.
Comment: Let's see if I am getting this right. I also really want to understand this. Let's consider $[x_1 - r_1, x_1 + r_1]$. It is clear to me that $|\frac{d^n f}{dx^n} (x_1)| \leq \frac{n!}{r_1^n} \cdot \lVert F \rVert_{\infty, D(x_1, r_1)}$. Now, what if we have $x_1' \neq x_1$ but which is also in $(x_1 - r_1, x_1 + r_1)$? I believe the inequality should now be $$\left| \frac{d^n f}{dx^n} (x_1') \right| \leq \frac{n!}{(r_1-x_1')^n} \cdot \lVert F \rVert_{\infty, D(x_1, r_1)},$$ which might not be consistent with the uniform bound on $K$ that you gave.
Comment: @AlexStrife: I edited again, trying to be as careful as I can with constants and bounds. Please let me know if you find it satisfactory now, thank you
Comment: The part you've edited is not the part I have a problem with actually. I'll just ask this: if $a \in (x_1 - r_1, x_1 + r_1)$, then is it true that $$\left| \frac{d^n f}{dx^n} (a) \right| \leq \frac{n!}{r_1^n} \cdot \| F \|_{\infty, D(x_1,r_1)}?$$
Comment: Of course, $a$ there is an arbitrary element of that interval. Thanks for entertaining my questions.

Real analyticity of a function


finitely generated ideal and number of generators

Question: let $I$ be a finitely generated ideal of ring $R$.
Suppose $I/I^2$ as an $R/I$ module is generated by $r$ elements then question is to prove that $I$ is generated by $r+1$ elements..
I have tried induction on number of generators of $I$ but could not succeed..
I have then tried to prove for $r=0$..
Suppose $r=0$ i.e., $I/I^2=0$ i.e, $I=I^2$..
Now, $I$ is finitely generated ideal and we have $IM=M$ for $M=I$..
Then by nakayama lemma, we see that there exists $a\in I$ such that $(1+a)M=0$
Let $m\in I$ then $(1+a)m=0$ i.e., $m=-am$..
Thus, $I\subseteq (-a)$.. Other inclusion is trivial. so, we have $I=(-a)$ generated by $1$ element...
I am thinking of using same idea for $r\neq 0$..
Suppose $r=1$ then we have $I/I^2=\langle a+I^2\rangle$ i.e., $I=\langle a \rangle +I^2$.. Now,I want to write $I=\langle a \rangle +I^2=JI$ for some
ideal $J$ and repeat the same as in the case of $r=0$. But could not think of any such $J$.. Please help me to solve this...
Please do not write answers, give some hints..
Comment: Here is something stronger and useful. With your hypothesis, let $f\in R$ be any element. Then the ideal generated by $I$ and $f$ is generated by $r+1$ elements. Taking $f=0$, you prove what you want, but $f$ can be arbitrary!
Comment: @Mohan, this is indeed a very nice result to remember, I would like to see the argument if you have time.
Comment: @user114539 Using the notation in my answer below, $i'$ is generated by the image of a single element $a\in I$ and as pointed out in the question above, we may assume $a$ is idempotent in $I'$. Then $I+fR$ is generated by $J$ and $a+(1-a)f$.
Answer: If $I/I^2$ is generated by $r$ elements, you can pick $r$ elements in $I$ which generates $I/I^2$. Let $J$ be the ideal generated by these $r$ elements and then consider $S=R/J$ and $I'=I/J$ an ideal in $S$. Then $I'/I'^2=0$ and you have your argument for this case, showing $I'$ is generated by one element and thus $I$ is generated by $r+1$ elements. My statement, which is stronger can also proved fairly easily and I can write it if you wish.
Comment: I think i got it.. for $r=1$ we have $I=\langle a\rangle +I^2$.. Consider $J=\langle a\rangle$... Let $m\in I$ then, $m\in \langle a\rangle +pq$ for some $p,q\in I$ i.e., $m-pq\in  \langle a\rangle$ i.e., $m+ \langle a\rangle=(p+ \langle a\rangle)(q+ \langle a\rangle)$ i.e., $I/J=(I/J)^2$... Now, as $I$ is finitely generated then so is $I/J$... then by same argument as that in my question i would get $m\in I/J$ such that $I/J=\langle m+J\rangle$ then, $I= \langle a\rangle+ \langle m\rangle$.. This is the case for any $r$..
Comment: So, as of now, i understand how does this work... I will be glad if you can give some motivation how did you come up with this idea.....
Comment: I mean to say $I= \langle a,m\rangle$


Configuração de um slider de imagens

Question: Estudei um pouco de HTML e CSS, vendo algumas aulas no YouTube e fazendo as lições do Code Academy e agora estou criando meu primeiro site.
Quero adicionar um slider de imagens, pelo que pesquisei, a melhor opção será com jQuery mesmo, mas deste eu não entendo absolutamente nada, então tentei utilizar alguns modelos prontos, seguindo a documentação desses, e o que gostei mais foi o bx slider, então decidi usá-lo.
Segui as instruções do próprio site do bx slider e o slider apareceu certinho no site, mas os "estilos", os botões de next e prev, os botões de paginação e tal não aparecem como nos exemplos do bx slider, aparecem apenas textos sem nenhuma formatação.
Aqui o código HTML (ocultei o header pois acho que não influência no slider):
<!DOCTYPE html5>

        <meta charset="utf-8" />
    <title></title>
    <link href="css/styles.css" rel="stylesheet" type="text/css">
        <link href="/lib/jquery.bxslider.css" rel="stylesheet" />

        ...

O FAQ do bx slider indica que esse problema pode acontecer pois as imagens talvez não estejam na mesma pasta do arquivo CSS, mas já conferi e está tudo certinho.
Comment: Esta pergunta parece ser descontextualizada porque é demasiado pontual e o problema não é possível de reproduzir.
Comment: esse doctype está incorreto. `` creio que você "quis dizer" ``
Comment: Ahh, obrigado por avisar, não sei de onde tirei esse doctype! haha Mas não resolveu o problema... :(
Comment: Acho uma boa verificar se os arquivos `.css` e `.js` estejam nos caminhos indicados. Em seguida, testar se `$().bxSlider` retorna vazio ou existe (é a função chamada para inicializar o slider). Se ainda assim não funcionar, acho que só olhando/depurando o código do bxslider para saber ao certo.
Comment: Muuuuuuito obrigado! O href do jquery.bxslider.css estava errado! Nossa, tinha conferido isso algumas vezes já e não tinha percebido! Obrigado Dang!
Comment: Não sei muito bem ainda como funciona o stackoverflow, mas pelo que entendi precisa de uma resposta pra marcar como resolvido, se quiser postar esse comentário como resposta, eu marco ele como "resolvedor"! haha
Comment: @Sergio Tecnicamente, é fácil de reproduzir: é só colocar o caminho do JS diferente de onde o arquivo está de fato. RISOS
Comment: Me desculpem pela confusão pessoal, o problema já foi resolvido, obrigado a todos.
Answer: Pode começar verificando se os arquivos .css e .js estão nos caminhos indicados.
Em seguida, testar se $().bxSlider retorna vazio ou existe (é a função chamada para inicializar o slider).
Se ainda assim não funcionar, acho que só olhando/depurando o código do bxslider para saber ao certo.

Configuração de um slider de imagens


java swing resize

Question: I am writing a library where i am passed in a Container (usually JPanel)
and have an xml specification for different controls, their locations, size and other attributes. i have to create those controls at runtime and add it to the component. What's a good way to handle resizing of the parent Container?
Answer: If the XML specifies the absolute locations then there is probably no way to elegantly resize the components. You could create a custom LayoutManager that would scale them linearly but that would probably look bad for most components.
EDIT: Here is a version that might be helpful:
<code>public class LinearScaleLayout {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Linear Scale Layout Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBounds(100, 100, 200, 200);

        JPanel scalePanel = new JPanel(new LinearScaleLayoutManager());
        scalePanel.setBorder(new EmptyBorder(5, 5, 5, 5));
        scalePanel.add(new JTextField(), new Rectangle2D.Double(0, 0, 1, 0.2));
        scalePanel.add(new JScrollPane(new JEditorPane()), new Rectangle2D.Double(0, 0.25, 0.45, 0.75));
        scalePanel.add(new JSlider(), new Rectangle2D.Double(0.55, 0.25, 0.45, 0.75));

        frame.getContentPane().add(scalePanel);
        frame.setVisible(true);
    }

    private static class LinearScaleLayoutManager implements LayoutManager2 {
        private final HashMap<Component, Rectangle2D> rectMap = new HashMap<Component, Rectangle2D>();

        @Override
        public void layoutContainer(Container parent) {
            synchronized (parent.getTreeLock()) {
                Insets insets = parent.getInsets();
                int clientWidth = parent.getWidth() - insets.left - insets.right;
                int clientHeight = parent.getHeight() - insets.top - insets.bottom;
                if (clientWidth > 0 && clientHeight > 0) {
                    for (Component component : parent.getComponents()) {
                        Rectangle2D rect = rectMap.get(component);
                        if (rect != null) {
                            component.setBounds(new Rectangle(insets.left + (int)(rect.getX() * clientWidth),
                                    insets.top + (int)(rect.getY() * clientHeight), (int)(rect.getWidth() * clientWidth),
                                    (int)(rect.getHeight() * clientHeight)));
                        }
                    }
                }
            }
        }

        @Override
        public void addLayoutComponent(Component comp, Object constraints) {
            rectMap.put(comp, (Rectangle2D)constraints);
        }

        @Override
        public void removeLayoutComponent(Component comp) {
            rectMap.remove(comp);
        }

        @Override
        public Dimension minimumLayoutSize(Container parent) {
            return new Dimension(0, 0);
        }

        @Override
        public Dimension preferredLayoutSize(Container parent) {
            return new Dimension(100, 100);
        }

        @Override
        public Dimension maximumLayoutSize(Container target) {
            return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
        }

        @Override
        public void addLayoutComponent(String name, Component comp) {
        }

        @Override
        public float getLayoutAlignmentX(Container target) {
            return 0;
        }

        @Override
        public float getLayoutAlignmentY(Container target) {
            return 0;
        }

        @Override
        public void invalidateLayout(Container target) {
        }
    }
}
</code>

java swing resize


Possible causes for error while saving file in python while running on nginx?

Question: I have a .py script that saves a base64 file to a png file
# SAVE BASE64 STRING TO PNG IMAGE
timestr = time.strftime("%Y%m%d%H%M%S")
filename = "/user_score/"+self.user.username+timestr+".png"
saved_file = MEDIA_ROOT+"/"+filename
fh = open(saved_file, "wb")
fh.write(imgbase64.decode('base64'))
fh.close()

This is being called through an AJAX function to an URL like this one
http://example-domain.com/score/save_image/?img=iVBORw0KGgoAAAANSUhEUgAAA4QAAAJYCAYAAAA6xSjbAAAgAElEQVR4Xu3b0ZYUN7KGUfz%2BD92z2mMYzDRUZkkKhfLf59ZFSrFDXHyLM399fHx8fPN%2FBAgQIECAAAECBAgQIBAn8JcgjNu5gQkQIECAAAECBAgQIPC3gCD0EAgQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvg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BAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgk8B%2B6jaetVJ6%2FbAAAAABJRU5ErkJggg%3D%3D

It is working fine when I run on django runserver, both on local and production environments.
However it gives me an 502 when running on production with NGINX.
So everything points out to NGINX.
This is the NGINX conf file, though I can't access the error logs (another programmer did the setup)
user www-data;
worker_processes 5;
pid /var/run/nginx.pid;

events {
        worker_connections 6000;
        multi_accept on;
        use epoll;
}

http {

        ##
        # Basic Settings
        ##
        client_max_body_size 30M;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 300;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    #timeout
    #proxy_read_timeout 1200;
    uwsgi_read_timeout 1200;
    client_body_timeout 120;
    client_header_timeout 120;
    send_timeout 100;
    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    #client_max_body_size 8m;
    large_client_header_buffers 4 32k;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}
Any ideas appreciated.
Comment: Without a specific error there's not a whole hell of a lot we can do for you...
Comment: Are you using gunicorn? If yes this could be the reason: http://serverfault.com/a/564468/158607
Comment: Check your nginx error log.
Comment: Please provide static_root, static_url, media_root settings, urls, views.
Please provide your nginx log as well.

Also for static serve you can create  url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
Comment: @ohrstrom Yes, spot on! that was the problem indeed. Though I couldn't change that because it's needed server security and performance I updated my function to an AJAX post instead of sending the the data through URL and that solved the issue. I'll post an answer with the combination of yours and this additional info.
Comment: OK :) beside that - is there a reason why you send the image encoded in the query string? Why not a `POST` request with the data in the body? Not sure - but there also could be issues with extremely long query strings with proxies or security appliances... (ah sorry - just noted that you did this...)
Answer: This was solved by a comment by ohrstrom, who linked to this answer:
https://serverfault.com/questions/564464/nginx-request-line-too-large/564468#564468
These parameters:
client_header_buffer_size 1k;
large_client_header_buffers 4 32k;

Were blocking the call.
Aside from that it was a VERY bad idea on my side sending such a large amount of data in the url. I ended up using a POST with the base64 data on the body and that solved the problem.


Change of Variable (conformal map)

Question: Suppose $f$ is an analytic function defined on the unit disk, $D$.   I want to evaluate
$\int_{D} f(\omega) dA(\omega)$
using a change of variable.   Suppose $\phi$ is a conformal map of the $D$ onto itself.
Does
$\int_{D} f(\omega) dA(\omega) = \int_{D} f(\phi(z)) |\phi^{'}(z)|^{2}  dA(z) $?,
where $\phi^{'}$ is the derivative of $\phi$.
Answer: Because $|\phi'(z)|^2$ is the determinant of the Jacobian of $\phi$, this follows from the substitution formula for open sets in $\mathbb{R}^n$, as seen for example in this Wikipedia article, which contains further references for the more general result.  Technically, to apply the result directly you would break up each side into real and imaginary parts.

Change of Variable (conformal map)


What happens if every city withdraws bids to host the Olympics?

Question: According to this article,

Budapest will withdraw its bid to host the 2024 Summer Olympics, leaving only Los Angeles and Paris in the race

What happens if both Paris and Los Angeles also withdraw their bids to host Summer Olympics 2024?
Based on official rules/statements or examples of similar situations in the past, how would the International Olympic Committee select a host city?
Comment: I disagree with the close vote. This can be answered with enough research, as the IOC must have some ground rules concerning Olympic bids. Maybe some precedent of such a situation, as we now have summer, winter and youth olympics too?
Comment: Voting to close as opinion based: we don't know what the IOC would do. But I'm sure they'd find a way.
Answer: The IOC has actually had to backtrack quite a few times at much later points in the process than host selection, 8 years out.
The 1904 Olympics in St Louis and 1908 Olympics in London both were originally set to be staged in different cities and apparently moved within about 2 years of the games.
Now, obviously those were a different era in the scale and spectacle of the Olympics.  And there's also not great information out there on how early St Louis/London showed interest...
But there's a lot of information on the mess that was the bidding for the 1976 Winter Olympics.
4 countries entered the final round of bids in 1970:

Denver, US
Sion, Switzerland
Tampere, Finland
Vancouver, Canada

Denver won.
Then withdrew 39 months before the game after voters blocked funding.
Then Whistler, near Vancouver, was selected. They turned it down due to a government change.
Then the US suggested Salt Lake City as a replacement. SLC withdrew their offer due to economics.
Then the US suggested Lake Placid.
Finally the IOC opted to put it in Innsbruck, Austria just 36 months before the games.  Austria had not bid previously.
But that gives a suggestion as to what would happen if everyone withdrew (or if something came up that would prevent hosting): a recent host would end up with the games.  They have the infrastructure, they have the experience, and they would need less preparation time.  It would seem a straightforward fit.  (Innsbruck had held the Winter Games 12 years earlier)
Similar has happened in the World Cup, when in 1982 Colombia withdrew from hosting the 1986 World Cup after being the only country to have put in a bid.  A new bidding round was requested and three countries made entries; Mexico, which had hosted 16 years prior, was unanimously selected.
A more recent extreme example is the 2015 Africa Cup of Nations.  Morocco and South Africa made bids.  Morocco won.  Then Morocco apparently withdrew just THREE month before the tournament over fears from the Ebola outbreak.  2012 co-hosts Equatorial Guinea took it on, even in a climate where many others refused to consider it.
So it would seem likely that there would be some combination of a rebid round or private negotiations, and that it would likely end up moving back to a recent host.
And if no one still was interested?
Well, the IOC could pay to hold the events themselves, without any direct assistance from the cities.  Smaller sporting events do this all the time.
Or they could cancel.
But doubt we'll come to that any time soon, even with the economic benefits of hosting being uncertain.  The Olympics are a huge world event, with plenty of attention and fame.  Someone will do it.
(You can see the entire history of Olympic bids on Wikipedia)
Comment: It's *extremely* unlikely that both Paris and LA would drop out, of course, but it's an interesting hypothetical in the current IOC atmosphere, as you mention. Recent hosts Rio would be highly unlikely to step up as much of their infrastructure was temporary and costs were a problem. The IOC would likely look to London or even Beijing.


Load users environment variables in a cronjob

Question: How can I load the users environment variables in a cronjob?

I have a cronjob which should start a script every minute on my Ubuntu machine:
* * * * * /home/user/myscript.sh;

In this script I want to use environment variables like $JAVA_HOME and $M2_HOME to automatically start a build process. The problem is that those variables are set in the .bashrc via export JAVA_HOME=/../...
Therefore I source these files before executing my script:
* * * * * source ~/.bash_profile; source ~/.bashrc; /home/user/myscript.sh;

However, the variables aren't set! To test this I echo the environment variables via env to a log file:
env >> ~/env.log
echo $M2_HOME >> ~/env.log

The log file still doesn't contain the variables. Only the following are appended to the file (no $M2_HOME etc.):
LANGUAGE=en_US:en
HOME=/home/user
LOGNAME=user
PATH=/usr/bin:/bin
LANG=en_US.UTF-8
SHELL=/bin/sh
PWD=/home/user

If I run the script right in my shell all of the variables are print out to env.log.
The same happens when I put the source commands into the script file. Only if I remove the export keyword before the declaration of the variable it is visible by the echo $var command. But this is not a solution because I don't manage these declarations.

I tried the solution of @tripplee with the limited sh shell problem, but it still doesn't work. I further reduced it to a very simple cronjob without a second script to show the problematic:
* * * * * . $HOME/.bash_profile; . $HOME/.bashrc; env > $HOME/env.log;

cat /home/user/env.log:
LANGUAGE=en_US:en
HOME=/home/user
LOGNAME=user
PATH=/usr/bin:/bin
LANG=en_US.UTF-8
SHELL=/bin/sh
PWD=/home/user

Comment: Take a look in http://stackoverflow.com/questions/15557777/crontab-job-does-not-get-the-environment-variables-set-in-bashrc-file
Answer: The cron job syntax is restricted to sh only so you cannot use Bashisms like ~.  Fortunately, the fix is easy -- just replace it with $HOME.  Similarly, source needs to be replaced with . (just a dot).
Of course, the scripts you source mustn't use Bash syntax either if you intend to use them from sh.  Probably the easiest fix is to migrate these things to your script (or create a wrapper script for Cron to run).
Because inside your script, you can use bash if you like, provided of course that the shebang line is correctly #!/bin/bash (adjust the path if you have to) rather than #!/bin/sh.
If you don't like that for some reason, you can inline Bash in your crontab file by specifying it explicitly:
* * * * * bash -c 'source ~/.bash_profile; source ~/.bashrc; ./myscript.sh'

You should be able to see source: command not found and export: command not found in the emails sent by cron when things go wrong.  Examining the error output is really important for troubleshooting.
Of course, if you have the standard .bashrc on Ubuntu, it will bail out immediately if you try to source it from a noninteractive script.  Maybe better then to put the settings you want in a noninteractive use in another file (maybe .profile which will be read by sh by default)?
Comment: Oh, if the Bash start-up files contain Bash-only syntax, that won't work either -- you'll get `export: command not found` instead.  Better really to put these in a Bash script and call that from Cron.  Updated answer.
Comment: That is usefull. Though, the result is still the same. I updated the question.
Comment: You forgot to fix the `source: command not found` error. Sorry about not mentioning it in my very initial answer.
Comment: And I'm sorry to tell you that this doesn't work either. Same result. But thx for the hint! I updated the question again.
Comment: Still doesn't work! :/
Comment: Added stuff from http://stackoverflow.com/a/15574078/874188 -- thanks @FedericoSierra.
Comment: The problem was a different one (too). I added an answer: http://serverfault.com/a/673498/98187
Answer: To add on to tripleee's answer, you can cause all of your crons to be evaluated in bash (or the shell of your choice) by specifying the shell in the crontab.
SHELL=/bin/bash
* * * * * . $HOME/.bash_profile; . $HOME/.bashrc; env > $HOME/env.log;

edit and if you really want to see what it's doing, the following command should make it sufficiently verbose:
/bin/bash -x -c '. $HOME/.bash_profile; . $HOME/.bashrc; env > $HOME/env.log' > /tmp/cron.`date +\%s`

set -x or the -x flag on the commandline will cause most shells to print every line evaluated.
To test on the commandline remove the \ from the date command. This is needed to prevent cron from evaluating %s as standard input.
Answer: You don't have a full tty in cron. But if you run it via sudo -i you'll get one.
* * * * * sudo -u user -i bash -c '. $HOME/.bash_profile; . $HOME/.bashrc; env > $HOME/env.log;'

Or to start the script:
* * * * * sudo -u user -i bash -c '. $HOME/.bash_profile; . $HOME/.bashrc; /home/user/myscript.sh;'

If you put the source commands in a Bash script which starts the target script you'll get a neat:
* * * * * sudo -u user -i /home/user/mystarter.sh;

Comment: This post is partly based on http://serverfault.com/a/673487/98187
Comment: If that's the case, then Federico Sierra's comment would have worked for you. The problem is the interactive shell detection is causing your profile to short-circuit out before it gets to the export statements.


Universal cover of a riemannian manifold inherits the metric of space

Question: I read on http://mathworld.wolfram.com/UniversalCover.html that any property of X can be lifted to its universal cover, as long as it is defined locally, the riemannian metric of a manifold $(X)$ is defined locally, so the I want to think that the unviersal cover have a metric deffined by the metric of $X$, but I don't know how to prove this or where to find it. If you can give me some book that help me with this would be very helpfull. Thanks.
Comment: It depends on what you're looking for exactly. There's not much more to say about this particular fact, but covering spaces come up in Riemannian geometries in important ways, like the classification of constant curvature spaces and Hadamard's Theorem. Lee's *Riemannian Manifolds* at least mentions some results along these lines.
Comment: It would help to have a little more context here, to know what kind of an answer you're looking for. The short answer is that if $\pi$ denotes the canonical projection and $g$ the metric on $X$, then the induced metric on the universal cover is just the pullback $\pi^* g$.
Comment: Oooo now its kind of obvious, but I would like a book that can give me more context about this. (Specially the part of the Riemannian metric)
Answer: If $(M,g)$ is a Riemmanian manifold and $p: \tilde M \to M$ is a covering space projection, then in particular $p$ is a local diffeomorphism.  (Note: $\tilde M$ does not need to be the universal cover.  It can be any cover, since all we'll use is that $p$ is a local diffeomorphism.)
Then for $x \in \tilde M$, the differential of $p$ is an isomorphism $p_*: T_x \tilde M \tilde\rightarrow  T_{p(x)} M$, which allows us to define an inner product $\tilde g_x$ on $T_x \tilde M$ from the inner product $g_{p(x)}$ on $T_{p(x)} M$.
Explicitly: $\tilde g_x(Y,Z) := g_{p(x)}(p_*Y,p_*Z)$.
Doing so for each $x\in \tilde M$ defines a metric $\tilde g$ on $\tilde M$, whose smoothness follows from smoothness of $g$ and the fact that $p$ is a local diffeomorphism.


Sample size calculation for the rate of infections between two groups

Question: I am in the progress of calculating the sample size for a treated/untreated group comparison.
The data provided is a mean infection rate (mean/100 years) of a literature recherche.
Assuming the infections are poisson distributed. So the SD=sqrt(mean).
The alternative hypothesis would be: Treatment lowers the rate of infection.
I am using sas to do all calculations.
proc power;
    twosamplemeans test=diff_satt
    groupmeans = 0.05 | 0.025
    GROUPSTDDEV = 0.224 | 0.158
    power = .1 to .8 by 0.1
    ntotal = .
    sides=l;
run;

Are my assumptions and procedures correct?
BR
Lukas
Comment: I have doubts about this. I think `twosamplemeans` assumes normality, whereas you have count data.
Comment: For sample size calculations you need to propose a *quantitative* alternative hypothesis.  "lowers the rate" doesn't give you any usable information.  The sample size will also depend on the background infection rate: after all, the smaller the rate is, the more people you will have to select in order to observe any infections at all.
Comment: I do not use SAS but is there not an option for comparing rates rather than means?
Answer: As pointed out by @Robert Long and @mdewey a comparison in means would not be valid for a poisson distributed proportion.
Hence I moved to the twosamplefreq method which is the calculation for a chi-square test.
@whuber: Since I did not receive any expected outcome for the treatment group I simulated five scenarios.
proc power;
twosamplefreq
  groupproportions = 0.05 | 0.01 to 0.03 by 0.005
  sides=L
  alpha=0.025
  power=.
  NTotal=50 to 1000;
run;

Comment: Was this intended as an answer or as a modification to the question?


Implication statements involving a variable

Question: I just learned the definition of implication and have been considering a few problems.
Given $x$ is real, prove $x = 1 \Rightarrow x = 2$.
Either $x = 1$ or $x \neq 1$. If $x=1$, then the implication is false, and if $x \neq 1$ is true, then the implication is true. Since we don't know the value of $x$, then this statement cannot be proved.
Also consider given $x$ is real, prove it is false that $x \ge 0 \implies \text{abs}(x) > 0$.
Textbook answers usually go: when x is $0$, $\text{abs}(x)$ is $0$ and therefore the statement is wrong.
But isn't this the proof of the NEGATION of the UNIVERSAL statement (for all real $x$, if $x\le 0$, then $\text{abs}(x) > 0$) by proving there exists a value of $x$ (i.e. 0) such that $\text{abs}(x)$ is not greater than $0$?
To prove this statement false, we need to prove $x \ge 0$ AND $\text{abs}(x) \le 0$. But we don't know the value of $x$, so rigorously speaking, we cannot prove this, right?
Maybe there is some sort of convention regarding this question?
However,
suppose now the question is instead if $x > 0$, prove $\text{abs}(x) >0$. In this scenario, to me, it is clear that it is the question about this SPECIFIC value of x that we do not know that is being asked (it just sounds right, and you often see problems start with an unknow e.g. the possibility of something is p...), even though the universal statement about all $x$ implies this and is probably most people would use to deduce this statement.
So it seems like there is some convention regarding proving the falsehood of such a statement, but not for the truth?
Comment: When we say a statement such as "Given $x$ is real, $P(x)$" we mean to say that for all $x$ in the universe of discourse we are interested in (*in this case all real numbers*) the statement $P(x)$ holds true.  The first example you give, that $x=1\implies x=2$ is false so long as you are considering a universe in which $1$ is an element and $1\neq 2$, which you imply you are when you said "given $x$ is real."
Comment: The implication $A\implies B$ is false if and only if $A$ is true and $B$ is false. $x>0\implies |x|>0$ can be proven since we can show that for every $x>0$ we also have $|x|>0$ (in fact , $x>0$ implies $|x|=x$). So, the value of $x$ need not be known in general to determine the truth of such an implication.
Comment: @JMoravitz If asked to prove something is false, should I prove that statement is false for all values of variables (x, y, z, etc.), or should I prove the falsehood of the universal statement involving all the variables(i.e. to prove there exists some values that the statement is false)?
Comment: Make sure you understand the difference between "$P(x)$" and "$(\forall x) P(x)$".  When you talk about "*that statement*" it is unclear whether you mean $P(x)$ or whether you mean $(\forall x)P(x)$.  To prove "$(\forall x)P(x)$" is false (*in other words proving $\neg((\forall x)P(x))$ is true*) you need only find one example of an $x$ in the universe of discourse such that $\neg P(x)$ (*though there may be multiple $x$ that you can do this for*).  This is different than trying to prove $(\forall x)\neg P(x)$.
Comment: @JMoravitz You mentioned "When we say a statement such as "Given x is real, P(x)" we mean to say that for all x in the universe of discourse we are interested in (in this case all real numbers) the statement P(x) holds true." So if asked to prove it is false that Given x is real, P(x), you prove  ¬((∀x)P(x)) rather than (∀x)¬P(x), right? It is confusing because one could have tried to prove Given x is real, it is false that P(x).
Comment: Correct.  Negation flips a universal quantifier to an existential quantifier
Answer: Hint 1: Proving $\neg \forall x:[x\in R \to [x=1 \to x=2]]$
Suppose to the contrary. Assuming $~1\in R~$ and $~1\neq 2$, obtain a contradiction.

Hint 2: Proving $\neg \forall x:[x\in R \to [x\leq 0 \to |x|\gt0]]$
Suppose to the contrary. Assuming $~0\in R, ~|0|=0,~0\leq 0$ and $~0 \ngtr  0$, obtain a contradiction.
Answer:
Given that $x$ is real, prove that $$x = 1 \implies x = 2.\tag1$$
Since we don't know the value of x, then this statement cannot be proved.

given that $x$ is real, prove that it is false that $$x\geq0\implies\textrm{abs}(x) >0.\tag2$$
To prove that this statement false, we need to prove that $x\geq0$ AND $\textrm{abs}(x) \leq 0.$ But we don't know the value of $x,$ so, rigorously speaking, we cannot prove this, right?

$(1)$ and $(2)$ are open formulae and thus not statements, let alone provable statements. However, if we treat them as being implicitly universally quantified, i.e., $$\forall x\,\big(x = 1 \implies x = 2\big)\tag{1a}$$ and $$\forall x\,\big(x\geq0\implies\textrm{abs}(x) >0\big)\tag{2a},$$ then the counterexamples $x=1$ and $x=0,$ respectively, show that they are false statements.

If asked to prove something is false, should I prove that statement is false for all values of variables (x, y, z, etc.), or should I prove the falsehood of the universal statement involving all the variables(i.e. to prove there exists some values that the statement is false)?

The latter. Providing the counterexamples above is essentially disproving $(1\mathrm a)$ and $(2\mathrm a)$ by proving their negations $$\exists x\,\big(x = 1 \;\text{and}\; x \ne 2\big)\tag{1n}$$ $$\exists x\,\big(x\geq0 \;\text{and}\; \textrm{abs}(x) \leq0\big)\tag{2n}.$$