## arithmetic groups – Small residue in \${bf Z}/n{bf Z}\$

Given $$r$$ a residue of the multiplicative group $${bf Z}/n{bf Z}$$, let $$d$$ be the order of $$r$$.

What’s the smallest number $$D$$ for wich if $$d>D$$ then there exist an element of the cyclic subgroup $$$$ who is $$< (except of course 1).

Thanks a lot.

## arithmetic geometry – Laurent polynomials of the form \$p(x)cdot p(x^{-1})\$

Let $$R$$ be a commutative, associative ring with $$1$$ and let $$tau: R(x^{pm 1})to R(x^{pm 1})$$ be the $$R$$-algebra involution $$tau(x)=x^{-1}.$$ Then it is natural to ask which elements of the invariant subalgebra $$R(x^{pm 1})^tau$$ are of the form $$pcdot tau(p)$$ for some $$pin R(x^{pm 1})$$.

This problem reduces to a question whether each $$a_n(x^n+x^{-n})+ … + a_1(x+x^{-1})+a_0in R(x^{pm 1})^tau$$ in the form
$$p(x)p(x^{-1}),$$ for some $$p(x)=sum_{i=0}^n c_ix^i$$, which leads to the system of equations:
$$begin{cases} c_0^2+…+c_n^2=a_0\ c_0c_1+…+c_{n-1}c_n=a_1\ …\ c_0c_n=a_n. end{cases}$$

I suspect that this problem has been studied already and I am hoping to be pointed in the right direction.
I expect that this system have a solution for algebraically closed fields $$R$$ (at least when characteristic $$ne 2$$), but don’t know the proof.
However, the most interesting case for me is $$R=mathbb Z$$.

## arithmetic geometry – Hochschild-Serre like spectral sequence for \$p\$-adic uniformization of special fiber of Shimura variety?

This question follows from my reading of Fargues’ 2004 paper published in Astérisque, whose notations I borrow. One of the central part of the paper is the construction of a Hochschild-Serre type spectral sequence computing the étale (compactly supported) cohomology of the quotient of an analytic space under the action of a discrete group, Théorème 4.5.1. Here, Berkovich’s theory is used. This is then applied to the case of the $$p$$-adic uniformization of PEL Shimura variety by associated Rapoport-Zink spaces, Théorème 3.2.6 and Théorème 4.5.12. Indeed, if $$K = K_pK^p$$ denotes a level structure, $$phi$$ is an isogeny class of abelian varieties with additional structures and $$I^{phi}(mathbb Q)$$ its automorphism group, then the $$p$$-adic uniformization is an isomorphism of analytic spaces with various actions
$$I^{phi}(mathbb Q)backslash left(breve{mathcal M}_{K_p}times G(mathbb A_f^p)/K^pright) xrightarrow{sim} mathrm{Sh}_K^{mathrm{an}}(phi)$$
And the left-hand side may be re-written as a union $$bigsqcup_{iin I} Gamma_ibackslash breve{mathcal M}_{K^p}$$ for some finite number of properly defined discrete subgroups $$Gamma_i$$ of $$I^{phi}(mathbb Q)$$ (this requires some choices). Here, $$breve{mathcal M}_{K_p}$$ is the level-$$K_p$$ covering of the generic fiber of the Rapoport-Zink space, $$mathrm{Sh}_K^{mathrm{an}}(phi)$$ is the level-$$K_p$$ covering of the analytic tube of the stratum $$widetilde{S}_{K^p}(phi)$$ corresponding to $$phi$$ inside the special fiber of the Shimura variety ; and the group $$G$$ is given by the PEL datum. The spectral sequence then takes the following form for $$ellnot = p$$ :
$$E_2^{p,q} = mathrm{Ext}_{J_b-text{smooth}}^{p}left(mathrm H_c^{2N-q}(breve{mathcal M}_{K_p}widehat{otimes},mathbb C_p,overline{mathbb Q_{ell}})(N), (mathcal A_{rho}^{phi})^{K^p} right) implies mathrm H^{p+q}(mathrm{Sh}_K^{mathrm{an}}(phi),mathcal L_{rho}^{mathrm{an}})$$
where $$rho$$ is some fixed algebraic representation of $$G$$ giving rise to a local system $$mathcal L_{rho}$$ on the Shimura tower, $$mathcal A_{rho}^{phi}$$ is a space of automorphic representations of $$I^{phi}(mathbb Q)$$ which are of type $$rho$$ at infinity and $$N$$ is the dimension of the Shimura variety. Of course, the spectral sequence comes with compatibility with various actions.

My question is, to what extent does the whole construction rely on
Berkovich’s theory of analytic spaces and étale cohomology ?

Let me be more specific. I denote by $$C_0$$ the maximal level structure at $$p$$ (ie. there is no level structure). If I understand correctly, it is necessary to introduce the generic fiber $$breve{mathcal M}$$ of the Rapoport-Zink space $$mathcal{M}$$ in order to define the tower $$(breve{mathcal M}_{K_p})$$ for $$K_psubset C_0$$ an open compact subgroup. So when one is interested in higher level structures or in the whole tower, analytic spaces seems inevitable. But what if one is only interested in the maximal level $$C_0$$, it looks like everything can be done at the level of special fibers and fair $$overline{mathbb F}_p$$-schemes.

Indeed, at maximal level the uniformisation theorem can be staded for the integral models on both sides and not just on the generic fiber. Specializing to the special fiber, we have an isomorphism of $$overline{mathbb F}_p$$-schemes
$$I^{phi}(mathbb Q)backslash left({mathcal M}_{mathrm{red}}times G(mathbb A_f^p)/K^pright) xrightarrow{sim} widetilde{S}_{K^p}(phi)otimes overline{mathbb F_p}$$
With such an identity, would the spectral sequence constructed by Fargues still work for the special fibers and “classical” étale cohomology, or is there some obstacle that I am not aware of ?

## modular arithmetic – Find a solution to a congruance within a specified range

My problem is to find all the integer solutions of the following conguence:

$$P=0mod4$$

where $$p=q^2∗r^2∗y^4∗z^2∗(2∗w^4+2∗r^2∗w^4∗y^4∗z^2+r^2∗w^8∗y^4∗z^2+2) + q^2+ 2∗r^6∗w^4∗y^m∗z^6∗(w+w^2+1)∗(-w+w^2+1)∗ (-w^2+w^4+1)+ 2∗r^4∗y^8∗z^4∗(w^8+r^2∗y^4∗z^2+1)+ w∗z^2∗(2∗w^2+3∗w^3+2)+z^2+2∗a+2$$ where $$m=12$$ and all the variables are between $$0$$ and $$3$$. One way to do this is to calculate the values of $$P$$ for all the cases of its variables in the mentioned range.

## algorithm – C++ evaluating an arithmetic expression in RPN format using ADT stack

The question:

Write a program that uses an ADT Stack to evaluate arithmetic expressions in RPN format. The contents of the stack should be displayed on the screen during evaluation. The allowed arithmetic operators are +, -, x, and /.

What I have done so far:

``````#include <iostream>
#include <string.h>

using namespace std;

struct Stack
{
int top;
unsigned cap;
int* arr;
};

struct Stack* createStackFun(unsigned capacity)
{
struct Stack* s = (struct Stack*) malloc(sizeof(struct Stack));
if (!s) return NULL;
s->top = -1;
s->cap = capacity;
s->arr = (int*)malloc(s->cap * sizeof(int));
if (!s->arr) return NULL;
return s;
}

int isEmpty(struct Stack* stack)
{
return stack->top == -1;
}

char peek(struct Stack* stack)
{
return stack->arr(stack->top);
}

char pop(struct Stack* stack)
{
if (!isEmpty(stack))
return stack->arr(stack->top--);
return '\$';
}

void push(struct Stack* stack, char op)
{
stack->arr(++stack->top) = op;
}

int postfixEvaluation(char* exp)
{
// Create a stack of capacity equal to expression size
struct Stack* stack = createStackFun(strlen(exp));
int i;
// See if stack was created successfully
if (!stack) return -1;
// Scan all characters one by one
for (i = 0; exp(i); ++i)
{
// If the scanned character is an operand (number here), push it to the stack.
if (isdigit(exp(i)))
push(stack, exp(i) - '0');
// If the scanned character is an operator, pop two elements from stack apply the operator
else
{
int val1 = pop(stack);
int val2 = pop(stack);
switch (exp(i))
{
case '+':
push(stack, val2 + val1);
break;
case '-':
push(stack, val2 - val1);
break;
case '*':
push(stack, val2 * val1);
break;
case '/':
push(stack, val2 / val1);
break;
}
}
}
return pop(stack);
}

int main()
{
char expression() = "74*+8-";
cout << "Postfix Evaluation: " << postfixEvaluation(expression);
return 0;
}
``````

The problem:

I am not sure if this is correct and I don’t know if there is a way to shorten the code or make it better.

## Reference request for "Divisibility of certain arithmetic functions" by Serre

The paper mentioned in the title can be found here. My problem is that it is in french and my French is only as good as Google Translate. Is there any english translations out there or is there any expository material discussing the results of that paper. The paper is classic and the result is well known in number theory.

Any help is appreciated.

Thank you

## modular arithmetic – Is quadratic nonresiduosity in \$textbf{NP}\$?

The paper “The Knowledge Complexity of Interactive Proof Systems” uses the language of quadratic nonresidues defined via the following excerpt from page 293 as an example of constructing an interactive proof system.

Example 1: Let $$Z_m^*$$ denote the set of integers
bctween $$1$$ and $$m$$ that are relatively prime with $$m$$.
An element $$a in Z_m^*$$ is a quadratic residue mod $$n$$ (sic) if
$$a = x^2 mod{m}$$ for some $$x in Z_m^*$$, else it is a quadratic
nonresidue. Now let $$L = {(m, x) | x in mathbb{Z}_m^* text{is a quadratic nonresidue}}$$. Notice that $$L in textbf{NP}$$: a prover needs only to compute the factorization of $$m$$ and send it to the verifier without any further interaction.

Given that $$n$$ is not defined in the context of the example, I assume this to be a typo and that the authors meant $$m$$. My question is about the last sentence. The authors provide no further detail afterwards about what the verifier would do with this factorization to verify quadratic nonresiduosity. In pursuit of more details, I cracked open Arora-Barak where the following treatment of the above is given in section 8.1 example 8.9.

Here is another example for an interactive proof for a language not known to be in
$$textbf{NP}$$. We say that a number $$a$$ is a quadratic residue mod $$p$$ if there is another number $$b$$
such that $$a cong b^2 mod{p}$$. Such a $$b$$ is called the square root of $$a mod{p}$$. …
the language QNR of pairs $$(a, p)$$ such that $$p$$ is a prime and $$a$$ is
not a quadratic residue modulo $$p$$ has no natural short membership proof and is not
known to be in $$textbf{NP}$$. But it does have a simple interactive proof if the verifier is
probabilistic.

Now if the language QNR described in Arora-Barak is not in $$textbf{NP}$$, how could its “superset” the language $$L$$ described in the paper be in $$textbf{NP}$$? If the paper is correct then we could easily construct a verifier which would prove that QNR is in $$textbf{NP}$$: for any $$(a, p)$$ the certificate would consist of the certificate of the membership of $$(p, a)$$ in $$L$$ in addition to a certificate for the primality of $$p$$.

## ARITHMETIC OPERATION ON TWO TABLES IN MYSQL

I keep getting this error

ERROR 1242 (21000): Subquery returns more than 1 row

After I run the mysql command below

create table CoreIndices14 select Year, ((select SumOfPrecipitation from CoreIndices13)/(select NumberOfDays from CoreIndices12)) as SimpleDailyIntensity from CoreIndices13 group by Year;

I need help. Thanks

## fixed point – Computer arithmetic algorithm: what might I be doing wrong?

So I’m working with the following differences equation:

$$y_n=alpha y_{n-1}+(1-alpha)x_n$$

I know this works with 16-fixed point arithmetic, and given some samples I’m trying to figure out how the operation is working. The data given to me is: ´

$$-13559=23528times(-23528)+(1-23528)times 12539$$

So my attempt was to do the multiplications, then shift one bit to the left (to eliminate the repeated sign bit) and then shift 16 bits to the right so that result is kept in Q15.

I obtain:
$$-13559=-16893-9002$$

Now the result is divided by 2 to put the result in Q14 (I know this is not needed here but since this needs to be general for any pair of numbers we need to guarantee there is no overflow).
So now I get:
$$-13559=-12947$$

Which is way off.
Any idea about what I might be doing wrong? I can provide more pairs of samples if needed.

Thank you!

EDIT:
I was pointed out that my samples might be wrong but I don’t think they are I provide here the respective values:

$$alpha=23528$$

Sequence of values

yn=-32767

xn=0 -> yn=-23528

xn=12539 -> yn=-13359

xn=23170 -> yn=-3060

xn=30273 -> yn=6338

xn=32767 -> yn=13789

## c++ – Count the number of arithmetic progressions within a sequence

I have some problems with code for my classes. Even though it works correctly, I run out of time for half of the examples. Here’s the task (I really did my best trying to translate it):

You have a permutation of numbers 1,2,…,n for some n. All consecutive numbers of permutations together create sequence a₁, a₂, a₊. Your task is to count how many arithmetic substrings of length 3 are present.

Input: In first line there is a number n (1 <= n <= 200 000). In the second line there is n numbers a₁, a₂, a₊ representing our permutation.

Output: The program needs to print out amount of arithmetic substrings of length 3 for permutations from entry. You can assume that the result won’t be bigger than 1 000 000.

NOTE: arithmetic substrings most likely stand for arithmetic progression or something like that

``````#include <iostream>
using namespace std;

int main()
{
int input_length;
cin >> input_length;
int correct_sequences = 0;

bool* whether_itroduced = new bool(input_length + 1){0}; // true - if number was already introduced and false otherwise.

for (int i = 0; i < input_length; i++)
{
int a;
cin >> a;
whether_itroduced(a) = true;
int range = min(input_length - a, a - 1); // max or min number that may be in the subsequence e.g. if introduced number a = 3, and all numbers are six, max range is 2 (3 - 2 = 1 and 3 + 2 = 5, so the longest possible subsequence is 1, 3, 5)

for (int r = range * -1; r <= range; r++) // r - there is a formula used to count arithmetic sequences -> an-1 = a1-r, an = a1, an+1 = a1+r, I have no idea how to explain it
{
if (r == 0) continue; // r cannot be 0

if (whether_itroduced(a - r) && !whether_itroduced(a + r))
correct_sequences++;

}
}
cout << correct_sequences;
}
``````

example input: `5 1 5 4 2 3`

correct output: `2` // {1,2,3} and {5,4,3}

example input: `5 1 2 3 4 5`

correct output: `4` // {1,2,3} {2,3,4} {3,4,5} {1,3,5}

example input: `10 1 5 9 7 4 3 6 10 2 8`

correct output: `4` // {4,3,2} {1,5,9} {5,4,3} {4,6,8}

I need to somehow come up with another algorithm that is less than quadratic in time. I can’t really see all of the inputs and correct outputs, but I know that the biggest ‘n’ number is about 32000, so it’s most likely that I run out of time because of the algorithm. Do you have any ideas about how can I improve it and make it work faster? Thanks for help!