Which subvarieties of $P^3$ are isomorphic to $P^2$?

Question: What are all the subvarieties $X$ in the projective space $P^3$ such that $X$ is isomorphic to $P^2$?
Comment: What do you mean *exactly* by "subspace"?
Comment: "Any hypersurface of $P^3$ is isomorphic to $P^2$".
What???
Comment: The question becomes perfectly clear, non-trivial and legitimate just by changing "subspaces $X$" to "subvarieties $X$", as Nicolas Hemelsoet's answer confirms. I'm voting to reopen, after making the suggested modification.
Comment: It is extremely unfortunate that this question was closed. Many interesting answers could have been given in terms of: self intersection of canonical divisor, or arithmetic genus, or Euler characteristic, or signature of the underlying oriented smooth manifold, or... These answers would have had great pedagogical value to students of algebraic geometry.
Answer: I am assuming you want to know which hypersurface $X \subset \Bbb P^3$ is isomorphic to $\Bbb P^2$. First, it is clear that any linear equation $f(x,y,z,w) = 0$ defines such an hypersurface. Conversely, for $d \geq 2$ a surface of degree $d$ is not even diffeomorphic to $\Bbb P^2$ as an easy Euler characteristic computation shows, so any hypersurface isomorphic to $\Bbb P^2$ should be given by a linear equation.
Comment: @GeorgesElencwajg : I have to admit that I don't understand why such a question was closed. This system is pretty unfortunate ...
Comment: @GeorgesElencwajg : I found another question (https://math.stackexchange.com/questions/2354053/rigid-and-nef-implies-numerically-trivial/2354085) where such thing happens as well (I had to do a bit of research but hopefully I could find it). As you said, a question is useful for the OP, but also for all the students in algebraic geometry who wants to learn new things. Maybe it should be possible to ask a moderator ?
Comment: Yes, it is very unfortunate that five people with zero qualification on a given subject (I do not refer specifically to the present case) can prevent tens of thousands of users  from  reading interesting answers by very knowledgeable experts.
Comment: Could you please explain your "easy" Euler characteristic computation ?
Comment: @GeorgesElencwajg : you are right, I should have not written "easy" : first one needs to show that all smooth hypersurfaces of fixed degree are diffeomorphic using Ehresmann's lemma. Then, it is enough to compute the Euler characteristic of $x_0^d + \dots + x_n^d = 0$ which can be done by induction, noticing that the projection onto $(x_0, \dots, x_{n-1})$ is a branched covering of $\Bbb P^{n-1}$, branched precisely at $x_0^d + \dots + x_{n-1}^d = 0$. When $n=3$, one needs to compute the Euler characteristic of a curve which is simply the genus-degree formula.
Comment: @GeorgesElencwajg : Dear Georges, thanks also for your comment ! I should have also said that alternatively one could use the Euler sequence and Chern classes.
Comment: Dear Nicolas: I'm happy  that you could answer before the question was closed by five people whose contribution to algebraic geometry on this site varies from minimal to non-existent.


Google Sheets: Map Not Rendering with Custom Markers

Question: I am trying to render a map in Google Sheets and set custom markers. I have followed the App Script Docs that go over this topic: Visualization: Map. The map is rendering with the icons in the correct places, but the icons are the default set.
I checked my img URLs (by setting them as the default) and they work (the below urls are fake). I believe the issue is somewhere around matching the options.icons.keys with the data that is in the dataTable 3rd column.
Here is the raw data that is pulled from <?= jsonPoints ?>
[[29.59260664700021,-95.77028110299972,"Red"],
[29.591301814000055,-95.76907472100011,"Green"],
[29.591178932000005,-95.76802742100018,"Red"],
[29.587551849000003,-95.77229599100004,"Blue"]]

And here is the function that creates the map:
function drawMap() {
  points = <?= jsonPoints ?>;

  var data = new google.visualization.DataTable();
  data.addColumn('number', 'Latitude');
  data.addColumn('number', 'Longitude');
  data.addColumn('string', 'Point Type');
  data.addRows(JSON.parse(points))

  var url = 'https://image.ibb.co/';
  var options = {
    showTooltip: true,
    showInfoWindow: true,
    useMapTypeControl: true,
    icons: {
      Red: {
        normal:   url + '/red.png',
        selected: url + '/red.png'
      },
      Blue: {
        normal:   url + '/Blue.png',
        selected: url + '/Blue.png'
      },
      Green: {
        normal:   url + '/Green.png',
        selected: url + '/Green.png'
      }
    }
  };
  var map = new google.visualization.Map(document.getElementById('chart'));
  map.draw(data, options);
};

I have tried putting quotation marks on the options.icons.keys, like "Green", but that did not work.
Any thoughts?
Thank you!
Answer: Figured it out. Added a fourth column that essentially had the same data. One column goes to the tooltip, the other is used as the marker:
  data.addColumn('number', 'Latitude');
  data.addColumn('number', 'Longitude');
  data.addColumn('string', 'Tooltip_Data');
  data.addColumn('string', 'Marker');

Now icons are rendered!


Apenas um campo como True por id de outra tabela

Question: Possuo uma tabela contendo produtos e outra contendo as imagens relacionadas. Consegui fazer com que apenas um item ficasse com o campo "padrao" como True, mas isso está aplicando na tabela como um todo. O que eu gostaria é que apenas uma imagem ficasse como padrão, porém por produto. Essa padrão vai ser utilizada como thumbnail. O método save esta impedindo que tenha mais de um campo 'padrao' como true, pra evitar de pegar 2 imagens no thumbnail. O que eu estou tentando fazer seria uma espécie de filtro onde esse lance de apenas um true seja aplicado por produto, e não todos os produtos da tabela.
Exemplo de como estou tentando fazer:
Produto_1.Imagem1.padrao = True
Produto_1.Imagem2.padrao = False
Produto_1.Imagem3.padrao = False

Produto_2.Imagem1.padrao = False
Produto_2.Imagem2.padrao = True
Produto_2.Imagem3.padrao = False

Exemplo de como está:
Produto_1.Imagem1.padrao = True
Produto_1.Imagem2.padrao = False
Produto_1.Imagem3.padrao = False
Produto_2.Imagem1.padrao = False
Produto_2.Imagem2.padrao = False
Produto_2.Imagem3.padrao = False

Produtos.models.py (resumido):
class Produto(models.Model):
    nome = models.CharField(max_length=255, unique=True)

class ProdutoImagem(models.Model):
    produto = models.ForeignKey(Produto, on_delete=models.CASCADE, null=False, blank=False)
    padrao = models.BooleanField(default=False)
    imagem = models.ImageField(upload_to='produto/produto', max_length=255, null=False, blank=False)

    def save(self):

        #  SÓ UMA IMAGEM COMO PADRÃO
        if self.padrao:
            produto_imagens = ProdutoImagem.objects.filter(padrao=True)
            for produto_imagem in produto_imagens:
                produto_imagem.padrao = False
                produto_imagem.save()
        super().save()

Comment: Não estou conseguindo pegar a lógica da sua condição no método `save`; se a imagem a ser salva estiver com o atributo `self.padrao == True` ele vai transformar o valor de ***todas* as outras** para `False`? Se for o caso, o problema com isso é a falta de referência à chave estrangeira `produto` ao fazer o filtro em `produto_imagens = ProdutoImagem.objects.filter(padrao=True)` — no caso você precisaria especificar também o objeto de `produto` (p.ex. `produto=self.produto`) que está relacionado para conseguir obter somente as imagens associadas àquele produto.
Comment: O método save esta impedindo que tenha mais de um campo 'padrao' como true, pra evitar de pegar 2 imagens no thumbnail. Mas falta justamente o que falou, o filter para separar um true apenas por produto. Mas já perdi a noite toda tentando fazer isso. kkkk
"ele vai transformar o valor de todas as outras para False" - Não deveria, ele deveria ter um padrao==true por produto.id.
Answer: RESOLVIDO
Por fim tentei a coisa mais simples e só adicionei mais um campo para filtrar no método save. Obrigado Rfroes87 pela luz.
class ProdutoImagem(Base):
    produto = models.ForeignKey(Produto, on_delete=models.CASCADE, null=False, blank=False)
    padrao = models.BooleanField(default=False)
    imagem = models.ImageField(upload_to='produto/produto', max_length=255, null=False, blank=False)

    def save(self):
        if self.padrao:
            produto_imagens = ProdutoImagem.objects.filter(padrao=True, produto=self.produto.pk)
            for produto_imagem in produto_imagens:
                produto_imagem.padrao = False
                produto_imagem.save()
        super().save()

Comment: Sua resposta pode ser melhorada adicionando informações fundamentais. Basta [edit] para adicionar mais detalhes, como citações ou documentação para que outras pessoas possam confirmar que sua resposta está correta. Você pode encontrar mais informações sobre como escrever boas respostas [na Central de Ajuda](/help/how-to-answer).


Is there a way to instantiate DeviceClient without a connection string in java [Azure-IoT-Hub] edge module?

Question: Is there a way to instantiate DeviceClient without a connection string in java?
Maybe with the use of ModuleClient object and DeviceClientConfig?
I do not want to set the DeviceConnectionString in the environment variables.
Comment: I do recommend to use a leaf certificate.
Comment: Thanks @RomanKiss, Could you please provide any links which has some sample?
Answer: There is nothing that forces you to use environment variables to store your device connection string, even though that's what the code samples are using. You are free to store the connection string in whatever system suits you best (encrypted local data store, database, config file, secure module, ...).
Comment: Thanks for your reply. I am developing a java edge module with spring-boot-webflux. I need to to some C2D messaging. The problem with passing on the Device connection string to instantiate the DeviceClient object is that the DeviceConnectionString changes on the azure portal often (for eg:- once in 4 days). Then I need to again take the new connection string from portal and update it.
Comment: Are you sure about the fact that the connection string changes once in 4 days? What subscription are you on? What exactly it changes inside the connection string, because the hub and device name should be the same. Is it the SharedAccessKey that is different?
Comment: Dear @Amicis, I have provisioned the edge device using TPM. Only the SharedAccessKey changes but not exactly after every 4 days but whenever the edge device is restarted or approximately after 4 or 5 days even if it is not restarted. Now I am trying to instantiate DeviceClient exacly like it is mentioned in this question (https://stackoverflow.com/questions/59793319/connecting-to-azure-iot-hub-using-tpm), I am also getting the same exception "activateIdentityKey first before signing"


Infinite cube and divisible sums

Question: Given is an infinite cube, extended infinitely in all directions. Is it possible to place each positive integer exactly once, so that for any positive integer $n$, the sum of the numbers in any $n\times n\times n$ cube is divisible by $n$?
The condition is trivial when $n=1$, but already gets interesting for $n=2$. If we only care about $n=2$, it should not be hard by iterative construction to make sure that the sum of any $2\times 2\times 2$ cube is even. The difficulty comes in because of higher $n$. For values of $n$ that are coprime (such as $2$ and $3$), it may be helpful to use the Chinese Remainder Theorem, though it is unclear how we would maintain the requirement that every positive integer gets used exactly once.
Comment: for $n=3$ the number of values that are 1 mod 3, 2 mod 3 have to have a difference in quantity divisible by 3.
Answer: I'll give an inductive construction -- sorry this turned out to be a long answer, I probably included too many details. The main idea is that since we're in three dimensions (in fact this works for any number of dimensions $\geq 2$), the constraints are actually not so restrictive, so there's enough freedom to insert whatever numbers are missing as we go.
Let's say a labelling of the points in $C_n := \{0, \dots, n-1\}^3$ (i.e. a function $C_n \to \mathbb{N}$) is $k$-good if the sum of the numbers in each $k \times k \times k$ subcube is divisible by $k$, and say that the labelling is good if it is $k$-good for each $1 \leq k \leq n$. Note that by the CRT, to show a labelling is good, it suffices to show that it's $k$-good for all prime power $k$ in this range.
Similarly say that a labelling $C_n \to \mathbb{Z}/p^k\mathbb{Z}$ is $p^\ell$-good (where $\ell \leq k$) if the same condition holds, and is good if it is $p^\ell$-good for $1 \leq \ell \leq k$. Then it follows that $f : C_n \to \mathbb{N}$ is good if and only if $f$ mod $q$ is good for each maximal prime power $q \leq n$ (where $q = p^k$ is maximal if $p^{k+1} > n$).
We will show the following:
Proposition. Given a good labelling $f : C_n \to \mathbb{N}$ with all labels distinct, such that $\{1, \dots, n\}$ appear as labels, we can extend $f$ to a good labelling $f' : C_{n+1} \to \mathbb{N}$ with all labels distinct, such that $\{1, \dots, n+1\}$ appear as labels.
Step 1: For each prime $p \leq n+1$, extend $f$ mod $p$ to a $p$-good labelling $f_p : C_{n+1} \to \mathbb{Z}/p\mathbb{Z}$.
For a candidate $f_p$ extending $f$ mod $p$, since $f$ is $p$-good the only constraints we need to check are that
$$\sum_{y \in C_p} f_p(x - y) \equiv 0 \text{ (mod $p$)}$$
for each $x = (x_1, x_2, x_3) \in C_{n+1} \setminus C_n$ with $x_1, x_2, x_3 \geq p-1$. Each such constraint uniquely determines $f_p(x)$ for such an $x$ in terms of $f_p(x')$ for $x'$ with $x_1' + x_2' + x_3' < x_1 + x_2 + x_3$. It follows that we are free to set the values of $f_p(x)$ for those $x \in C_{n+1} \setminus C_n$ with some $x_i < p-1$ (particularly $x = (n, 0, 0)$), and $f_p(x)$ will be uniquely determined for the other points $x \in C_{n+1} \setminus C_n$.
Step 2: If $p^k$ is not maximal, given a good labelling $f_{p^k} : C_{n+1} \to \mathbb{Z}/p^k\mathbb{Z}$ which extends $f$ mod $p^k$, find a good labelling $f_{p^{k+1}} : C_{n+1} \to \mathbb{Z}/p^{k+1}\mathbb{Z}$ extending $f$ mod $p^{k+1}$.
We will take a candidate $f_{p^{k+1}}$ extending $f$ mod $p^{k+1}$ which agrees with $f_{p^k}$ mod $p^k$. Then using $f_{p^k}$ to denote the corresponding function $C_{n+1} \to \{0, \dots, p^k-1\}$, we can write $f_{p^{k+1}}(x) = f_{p^k}(x) + p^k g(x)$, for some $g : C_{n+1} \to \{0, \dots, p-1\}$. Note that $g(x)$ is determined for $x \in C_n$ since we assumed that $f_{p^{k+1}}$ extends $f$. We know that $f_{p^{k+1}}$ is $p^\ell$-good for $\ell \leq k$, since we assumed that $f_{p^k}$ was good. Thus we only need to check that it is $p^{k+1}$-good, and since $f$ was $p^{k+1}$-good, the only constraints to check are that
$$\sum_{y \in C_{p^{k+1}}} g(x - y) \equiv - \frac{1}{p^k} \sum_{y \in C_{p^{k+1}}} f_{p^k}(x - y) \text{ (mod $p$)}$$
for each $x = (x_1, x_2, x_3) \in C_{n+1} \setminus C_n$ with $x_1, x_2, x_3 \geq p^{k+1}-1$. Similar to the argument in step 1, we are free to choose the values of $g(x)$ for $x \in C_{n+1} \setminus C_n$ with some $x_i < p^{k+1} - 1$ (including $x = (n, 0, 0)$), and $g(x)$ is uniquely determined on the rest of $C_{n+1} \setminus C_n$.
Step 3: Given $f_q$ for all maximal prime powers $q \leq n+1$, construct an extension $f'$ of $f$ to $C_{n+1}$ which agrees with each $f_q$ mod $q$.
For a candidate $f'$ agreeing with $f$ on $C_n$, the only constraints are that $f'(x) \equiv f_q(x)$ (mod $q$) for all $x \in C_{n+1} \setminus C_n$ and maximal $q$. By the CRT, these constraints indeed admit solutions, and in particular, since they only determine $f'(x)$ modulo some large factor, we can choose these labels $f'(x)$ so that all labels are distinct. If $n+1$ was already a label appearing in $f$, then any such choice of $f'$ will do. In the case where $n+1$ did not appear, then since in steps 1 and 2 we could freely set each $f_{p^k}(n, 0, 0)$, we can ensure that each $f_q(n, 0, 0) \equiv n+1$ (mod $q$), in order to label $f'(n, 0, 0) = n+1$. Since $f_q = f'$ mod $q$ is good for each $q$, $f'$ is good, and so it satisfies all of our conditions.
Iteratively extending the initial labelling $f(0, 0, 0) = 1$, we get the desired labelling of $\{0, 1, 2, \dots\}^3$, which includes each positive number exactly once. If you wanted a labelling of $\mathbb{Z}^3$, that can also be done by instead using the domain cubes $\cdots \subset \{-n, \dots, n\}^3 \subset \{-n, \dots, n+1\}^3 \subset \{-n-1, \dots, n+1\}^3 \subset \cdots$.

Infinite cube and divisible sums


Display Suite Fields not showing

Question: I created a bootstrap sub theme and and have enabled display suite.  I have enabled ds extra fields and chose a layout for my content type for full view display.  When going to the full view page of my content none of the ds fields are showing.
I have enabled title, author, post date, submitted by but none of these are showing.  Is there something special you must do to get ds to work on a subtheme?
Answer: Which version of Drupal are you using? If 8.3 you may wanna update to DS 8.x-3.0-beta3 which no longer requires the layout plugin module, instead uses "Layout Discovery" in core.
https://www.drupal.org/node/2871283

Display Suite Fields not showing


Feller - Question on two throws of three dice

Question: I am stuck at the following question.

What is the probability that two throws with three dice each will show the same configuration if (a) the dice are distinguishable (b) they are not.

Solution.
(a) $P(\text{Two throws of three dice s.t. each show the same configuration})=6^{3}/6^{6}=1/216$.
(b)Firstly from the second set of throws, the $3$ dies with the same face value as the first ones can be chosen in $3!=6$ ways.
Place $r=3$ dies in $n=6$ cells, such that order does not matter with repetition, can be done in ${{3+6-1}\choose{3}}={8\choose 3}=56$
${\displaystyle P(\text{Two throws of three indistinguishable dice show the same configuration})=\frac{56\times6}{6^{6}}}$
However, my answer to the second part of the problem is incorrect. Could someone help me think correctly about the problem.
Comment: 2 throw of 3 dice is equals to one throw of 6 dice. You want same number on all six dice?
Comment: You mean if in first throw we have (1,2,3) then in next throw we have exact (1,2,3) same pattern.
Comment: 1-2-3 is more likely to be repeated than 6-6-6  - can you see why?  Then can you use this to calculate the probability?  (this is in the indistinguishable case)
Comment: what you've got wrong in b) is that if you roll 6-6-6 then you have only 1 way of doing this again, but if you roll 1-2-3 then you have [how many?] ways of doing this again.
Comment: My understanding is, the problem asks for the probability of getting the same configuration - for e.g. if the first throw results in (5,6,6), what is the likelihood that the second throw also results in, perhaps (6,5,6)?
Comment: after the first throw, the probability of then getting the same configuration is effected by the first configuration - if you first get 6-6-6 then there is only a 1/216 of getting that again.  Therefore you can calculate the prob of getting 3 of a kind, 2 of a kind , or 3 unique  - then multiply by the prob of repeating that - the chaces of repeating is different for each initial roll type
Comment: @Cato, when all three faces are distinct, the probability of rolling an ace, deuce and trey again are $6/216$.
Comment: @KanwaljitSingh, in the next throw I must have (1,2,3) in any order, is what I understand.
Comment: @Cato, thanks for leading me in the right direction! Cheers. :)
Comment: @quasar - cool!
Answer: (b)
Three distinct faces :
$$P(\text{getting the same configuration}) = \frac{(6\cdot5\cdot4)\times(3\cdot2\cdot1)}{6^6}$$
One repetition:
$$P(\text{getting the same configuration}) = \frac{{3\choose2}(6\cdot5)\times{3\choose2}}{6^6}$$
Two repetitions:
$$P(\text{getting the same configuration}) = \frac{6}{6^6}$$
Thus, the required probability is,
$$P(\text{getting the same configuration}) = \frac{996}{6^6}$$
Answer: Simulation: Two successive throws of three fair dice with faces 1 through 6. Probability of same three faces showing: (a) if dice are indistinguishable,
(b) distinguishable.
In the distinguishable case, it may help to imagine the dice are colored
red, green, and blue, respectively. The probability is pretty clearly
$1/6^3 =  0.00462963.$ In simulating for the indistinguishable dice, we sort the
outcomes before comparison because color does not matter.
m = 10^6;  same.i = same.d = numeric(m)
for (i in 1:m) {
  roll.1 = sample(1:6, 3, repl=T)
  roll.2 = sample(1:6, 3, repl=T)
  same.d[i] = sum(roll.1==roll.2)
  same.i[i] = sum(sort(roll.1)==sort(roll.2)) }
mean(same.d==3);  mean(same.i==3)
## 0.004632
## 0.021579

With a million iterations, probabilities should be accurate to
three places (a little more for very small probabilities), so
the first simulated answer is consistent with $1/63.$ And, the
second answer is consistent with with @Quasar's $996/6^6 = 0.02134774.$ (+1)
For a little more detail, my same.d and same.i are numbers
of faces that agree for distinguishable and indistinguishable dice, respectively.
here are the histograms of their respective distributions.
(The probabilities mainly at issue here are the ones for 3 matches.)
Comment: I'm getting my hands wet at R, it's a lot of fun to simulate these games and see astonishing results. I liked your sort() trick in the indistinguishable case.
Comment: I see you are fairly new to this site, and welcome. If you will do a search on my user number, you will see that I have posted a _lot_ of R simulations (too many for the tastes of some users, I suppose). These tend to use 'for loops' which is not the greatest style in R (and they don't run as fast as they might), but some of the more sophisticated object oriented R structures would not be as easy for non-R users to understand. (So 'steal' whatever of my tricks you like, but try to develop a more sophisticated style than I feel comfortable using here.)
Comment: @BruceET,  Your R programming is good . But where did you get $\frac{1}{63}$.Answer to the first question where distinguishable dice are used is $\frac{1}{216}$.
Comment: It's $1/6^3 = 1/216.$ In R, `1/6^3` returns 0.00462963, `6^3` returns 216
and `1/216` returns 0.00462963.


PostgreSQL - Column name of a table is the name of a function

Question: There is a table in my database where on of the column names is called "end". End is a timestamp.
When I try to run a simple query such as:
select end
from driver_shift_log

I get a syntax error because it is interpreting end not as a column name, but as a SQL function. Any tips on the best way to fix this?
Answer: Try this way:
select "end"
from driver_shift_log

Sql Fiddle Demo