Smooth polynomials with several prescribed coefficients
Extracted source text · arXiv 2307.10280
\documentclass[12pt]{amsart}
\usepackage[utf8]{inputenc}
%\usepackage{amsmath,amsfonts,amssymb,a4wide,color,
% amsthm,graphicx}
\usepackage{amsmath,amssymb,amsbsy,amsfonts,amsthm,latexsym,mathabx,amsopn,amstext,amsxtra,euscript,amscd,stmaryrd,mathrsfs,cite,array,mathtools,enumerate
}
\usepackage{enumitem}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
citecolor=magenta,
pdftitle={Smooth polynomials},
pdfpagemode=FullScreen,
}
%\usepackage{url}
%\usepackage{refcheck}
\usepackage{a4wide}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{cor}[theorem]{Corollary}
\newtheorem{prop}[theorem]{Proposition}
\newtheorem{definition}{Definition}
\newtheorem{question}[theorem]{Open Question}
\newtheorem{example}[theorem]{Example}
\newtheorem{conjecture}{Conjecture}
\newtheorem{problem}{Problem}
\newcommand{\F}{\mathbb{F}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\Fq}{\mathbb{F}_q}
\newcommand{\e}{\mathbf{e}}
\newcommand{\mand}{ \quad \text{and} \quad}
\newcommand{\Ker}{\mathop{\mathrm{Ker}}}
\renewcommand{\d}{\mathrm{d}}
\renewcommand{\d}{\mathrm{d}}
\newcommand{\re}[1]{\mathrm{Re}#1}
\usepackage{todonotes}
\newcommand{\commL}[2][]{\todo[#1,color=blue!60]{L: #2}}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Alphabet calligraphie %
%%%%%%%%%%%%%%%%%%%%%%%%%
\def\cA{{\mathcal A}}
\def\cB{{\mathcal B}}
\def\cC{{\mathcal C}}
\def\cD{{\mathcal D}}
\def\cE{{\mathcal E}}
\def\cF{{\mathcal F}}
\def\cG{{\mathcal G}}
\def\cH{{\mathcal H}}
\def\cI{{\mathcal I}}
\def\cJ{{\mathcal J}}
\def\cK{{\mathcal K}}
\def\cL{{\mathcal L}}
\def\cM{{\mathcal M}}
\def\cN{{\mathcal N}}
\def\cO{{\mathcal O}}
\def\cP{{\mathcal P}}
\def\cQ{{\mathcal Q}}
\def\cR{{\mathcal R}}
\def\cS{{\mathcal S}}
\def\cT{{\mathcal T}}
\def\cU{{\mathcal U}}
\def\cV{{\mathcal V}}
\def\cW{{\mathcal W}}
\def\cX{{\mathcal X}}
\def\cY{{\mathcal Y}}
\def\cZ{{\mathcal Z}}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Alphabet bold %
%%%%%%%%%%%%%%%%%%%%%%%%%
\def\bT{{\mathbf T}}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Alphabet frak %
%%%%%%%%%%%%%%%%%%%%%%%%%
\def\fM{{\mathfrak M}}
\def\fm{{\mathfrak m}}
\def\fG{{\mathfrak G}}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Re, Im %
%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\mathrm{Im}}
\newcommand{\D}{\operatorname{\mathrm{D}}}
\title{Smooth polynomials with several prescribed coefficients}
\author[L.~M{\'e}rai]{L{\'a}szl{\'o} M{\'e}rai}
\address{Johann Radon Institute for Computational and Applied Mathematics, Austrian Academy of Sciences, Altenberger Stra\ss e 69, A-4040 Linz, Austria and Department of Computer Algebra, Eötvös Loránd University, Pázmány P. sétány 1/c, H-1117, Budapest, Hungary}
\email{merai@inf.elte.hu}
\allowdisplaybreaks
\keywords{polynomial, finite field, exponential sums}
\subjclass[2010]{11T06,11T55,11T23,11L07}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
Let $\Fq[t]$ be the polynomial ring over the finite field $\Fq$ of $q$ elements. A polynomial in $\Fq[t]$ is called $m$-smooth (or $m$-friable) if all its irreducible factors are of degree at most $m$. In this paper, we investigate the distribution of $m$-smooth (or $m$-friable) polynomials with prescribed coefficients. Our technique is based on character sum estimates on smooth (friable) polynomials, Bourgains's argument (2015) applied for polynomials by Ha (2016) and on double character sums on smooth (friable) polynomials.
\end{abstract}
\section{Introduction}
%\subsection{Integers and polynomials with prescribed digital properties}
%In the last decades, many efforts have been made to study different problems in structures of positive characteristic --like in finite fields or function fields over finite fields-- which problems originally focused the arithmetic nature of integers. See e.g. the survey papers of Green \cite{Gre05}, Rudnick \cite{Ru14}, Wolf \cite{Wolf15} and the references therein.
In recent years, many spectacular results have been obtained on important problems combining some arithmetic properties of the integers and some conditions on their digits in a given basis, see for example \cite{cite:Bourgain,Dr14,DrMaRi19,MaRi10,May19,Swa20}.
In particular, Bourgain \cite{cite:Bourgain} investigated the distribution of primes with prescribed bits. Later, Swaenepoel \cite{Swa20} extended Bourgain's result for arbitrary base. Namely, for a given positive integer $k$, consider its $g$-ary expansion
$$
k=\sum_{j\geq 0}k_ig^i, \quad k_i\in\{0,1,\dots, g-1\}.
$$
For a given index-set $\cI\subset \{0,1,\dots, n-1\}$ with $\#\cI \leq \delta(g) \cdot n $ and $0\in \cI$, it follows from \cite{cite:Bourgain,Swa20}, that the number of prime numbers with prescribed digits $\alpha_i\in \{0,1,\dots, g-1\}$ ($i\in \cI$) with $\alpha_0\neq 0$ satisfies
$$
\#\left\{ p<g^n, p_i=\alpha_i, i\in \cI , \text{$p$ prime} \right\}\sim \frac{\pi(g^n)}{g^{\#\cI}},
$$
where $\pi(x)$ is the prime counting function.
Ha \cite{Ha:Irreducible_polynomials} investigated the same problem over function fields. Namely, let $\Fq$ be the finite field of $q$ elements, and consider the polynomial ring $\Fq[t]$ over $\Fq$. Let $\cP(n)$ be the set of \emph{monic irreducible} polynomials of degree $n$. It is well-known, that the number $\pi_q(n)=\#\cP(n)$ of such irreducibly polynomials satisfies
\begin{equation}\label{eq:irred}
\frac{q^n}{n}-2\frac{q^{n/2}}{n} \leq \pi_q(n)\leq \frac{q^n}{n},
\end{equation}
see e.g. \cite[Lemma~4]{pollack13}. Improving earlier result on coefficients of irreducible polynomials \cite{cite:Ham,pollack13,cite:Wan}, Ha showed that the number of irreducible polynomials with preassigned coefficients is proportional to $\pi_q(n)$. In particular, let $\cM(n)$ be the set of \emph{monic} polynomials of degree $n$ and for an index-set $\cI\subset \{0,1\dots, n-1\}$ and $\alpha_i\in\Fq$ ($i\in \cI$) let $\cJ$ be the set of monic polynomials of degree $n$ with $i$th coefficient $\alpha_i$
\begin{equation}\label{eq:setJ}
\cJ=\left\{ t^n +\sum_{i=0}^{n-1} c_it^i\in\cM(n): c_i=\alpha_i , i\in \cI \right\}.
\end{equation}
Write
$$
\delta =\frac{\#\cI}{n},
$$
then for $\delta \leq 1/4$ we have
\begin{equation*}%\label{Ha:result}
\#(\cP(n)\cap \cJ ) =\frac{\mathfrak{G} q^{n-\#\cI}}{n}\left(1 + O\left(\frac{1- \log_q \delta}{q^{1/\delta - 4/(\delta +1)}} \right) \right) + O(q^{3n/4}),
\end{equation*}
where
$$
\mathfrak{G}=\left\{
\begin{array}{cl}
1 & \text{if $0\not\in \cI$}, \\
1+\frac{1}{q-1} & \text{if $0\in \cI$ and $\alpha_0\neq 0$},\\
0 & \text{if $0\in \cI$ and $\alpha_0= 0$}.
\end{array}
\right.
$$
In particular, we have the expected frequency of irreducible polynomials with prescribed coefficients, $ \#(\cP(n)\cap \cJ ) \sim \frac{\mathfrak{G} q^{n-\#\cI}}{n}$, if $q\rightarrow \infty$ or $\delta = \#\cI/n\rightarrow 0$.
\smallskip
In this paper, we investigate the distribution of \emph{smooth} (or \emph{friable}) polynomials with preassigned coefficients. For a given integer $m$, a polynomial is called $m$-smooth (or $m$-friable) if all its irreducible divisors are of degree at most $m$. Write
$$
\cS(n,m)=\{f\in \cM(n): f \text{ is $m$-smooth}\}\mand \Psi(n,m)=\#\cS(n,m).
$$
If we let
$$
u=\frac{n}{m},
$$
it is known, that the proportion of $m$-smooth polynomials of degree $n$ tends to Dickman's $\rho$ function defined via the delayed differential equation
$$
\tau\rho'(\tau)+ \rho(\tau -1)=0
$$
for $\tau \geq 1$ with initial condition $\rho(\tau)=1$ for $\tau\in[0,1]$.
It is decreasing, and de Bruijn proved \cite{deBruijn} that it satisfies
$$
\rho(u)=\exp\left( -u \log\left( u \log u\right) +u+ O\left(\frac{u \log \log u}{\log u}\right) \right)
$$
uniformly for $u\geq 3$.
Then Manstavi\u{c}ius \cite{Man} proved that
\begin{equation}\label{eq:Psi}
\Psi(n,m)=q^n \rho\left(u\right)\left(1+O\left(\frac{u\log(u+1) }{m}\right)\right)
\end{equation}
holds in range $n\geq m \geq \sqrt{n\log n}$
(see also \cite{Car,GarPa,PaGoFl98}). Recently, Gorodetsky \cite{Gor22+} gave better approximation of $\Psi(n,m)$ with main term $q^n\rho(u-n/(2m^2))$ and improved error term.
The main result of this paper investigates the proportion of $m$-smooth polynomials with prescribed coefficients.
\begin{theorem}\label{thm:1}
Let $0<\varepsilon<1/4$.
Let $\cI\subset\{0,1,\dots, n-1\}$ and $\alpha_i\in\Fq$ ($i\in \cI$) such that
$0\in \cI$ and $\alpha_0\neq 0$.
%Assume,
%\begin{equation}\label{eq:condition1}
%3m+8\leq 2n \mand m\geq 40.
%\end{equation}
%\commL{Where do we use it?}
Write $\delta =\#\cI/n$ and assume that
\begin{equation*}%\label{eq:thm1:delta}
\delta < 1/10, \quad \text{that is,} \quad \#\cI < n/10.
%\delta < 1/(16u), \quad \text{that is,} \quad \#\cI < m/16.
\end{equation*}
Then we have
\begin{equation}\label{eq:thm1}
\begin{split}
\#(\cS(n,m)\cap \cJ) &=
\frac{\Psi(n,m)}{q^{\# I}}
\left(1 + O\left( \left(u\log u\right)^{1/8}\frac{\delta^{-1} \log \delta}{q^{C /\delta}}+
\frac{1}{q} \frac{u^{1/2}(\log u)^{5/2}}{m} \right)\right) \\
&\qquad
+
O\left( \frac{q^{n}}{q^{\#I}} q^{
-\frac{(1-\varepsilon)n+2m}{8}+2
}+
m^2 n^{1/2}q^{(7n+m+4)/8}
\right)
,
\end{split}
\end{equation}
holds for some positive $C>0$ in range $n\geq m \geq \sqrt{n\log n}$, where the implied constant may depend on $\varepsilon$.
\end{theorem}
In particular, the number of $m$-smooth polynomials with prescribed coefficients has the expected frequency if $q\rightarrow \infty$ or $\delta \rightarrow 0$.
\begin{cor}\label{cor:1}
Assume, that
\begin{itemize}
\item for fixed $n$, $u$ and $\delta$, we have $q\rightarrow \infty$; or
\item for fixed $q$, we have $n\rightarrow \infty$ and $\delta
%< c(q)(\log u)^{-1}
=o(n)$. %for some constant $c(q)$ depending only on $q$.
\end{itemize}
Then
\begin{equation}\label{eq:expected}
\#(\cS(n,m)\cap \cJ) \sim q^{-\# I}\Psi(n,m) .
\end{equation}
\end{cor}
If $\alpha_0=0$, then $\#(\cS(n,m)\cap \cJ)$ deviates from the expected frequency. For example, if $I=\{0,1,\dots, r-1\}$ with $\alpha_i=0$ for $i\in \cI$, then
$$
\cS(n,m)\cap \cJ = \{t^nf: f\in\cS(n-r,m) \}
$$
and thus by \eqref{eq:Psi},
\begin{equation}\label{eq:zero_coeff}
\#(\cS(n,m)\cap \cJ)= \Psi(n-r,m)\sim \rho\left(\frac{n-r}{m}\right)q^{n-r}
\end{equation}
in contrast to \eqref{eq:thm1}.
In order to handle the general case write
$$
I=\{i_0<\dots< i_\nu<\dots\}
$$
with $\alpha_{i_0}=\dots =\alpha_{i_{\nu-1}}=0\neq \alpha_{i_{\nu}}$ and define
$$
\Lambda_0(n,m,I,\nu)=\frac{-1}{m}\sum_{\substack{0\leq j<\nu\\ i_j<m/8}} q^{j-i_j}\rho'\left(\frac{n-i_j}{m}\right)%-\frac{1}{m}\frac{q^{u-i_u}}{q-1}\rho'\left(\frac{n-i_u}{m}\right).
$$
and
$$
\Lambda_1(n,m,I,\nu)=
\left\{
\begin{array}{cl}
-\frac{1}{m}\frac{q^{\nu-i_\nu}}{q-1}\rho'\left(\frac{n-i_\nu}{m}\right) & \text{if $i_\nu<m/8$}, \\
0 & \text{otherwise} .
\end{array}
\right.
$$
Then we have
\begin{theorem}\label{thm:2}
Let $\cI\subset\{0,1,\dots, n-1\}$ and choose $\alpha_i\in\Fq$ for each $i\in \cI$. %Assume, that
%\begin{equation}\label{eq:condition2}
%3m+8\leq 2n \mand m\geq 40.
%\end{equation}
%\commL{Where do we use it?}
Write $\delta =\#\cI/n$ and assume that
$$
\delta < 1/10, \quad \text{that is,} \quad \#\cI < n/10,
% \delta < 1/(16u), \quad \text{that is,} \quad \#\cI < m/16,
$$
then we have
\begin{align*}
\#(\cS(n,m)\cap \cJ) &=
\frac{\Psi(n,m)}{q^{\# I}}
\left(1 + O\left( \left(u\log u\right)^{1/8}\frac{\delta^{-1} \log \delta}{q^{C /\delta}}+
\frac{1}{ q^{i_0+1}} \frac{u^{1/2}(\log u)^{5/2}}{m} \right)\right) \\
&\qquad
+\frac{q^{n}}{q^{\#\cI}}\left(\Lambda_0(n,m,I,u) +\Lambda_1(n,m,I,u)
+O\left( q^{
-\frac{(1-\varepsilon)n+2m}{8}+2
}e^{\varepsilon(n-m)}
\right)
\right)\\
&\qquad +
O\left(
m^2 n^{1/2}q^{(7n+m+4)/8}
\right)
,
\end{align*}
holds for some positive $C>0$ in range $n\geq m \geq \sqrt{n\log n}$.
\end{theorem}
By Theorem~\ref{thm:2}, the distribution of $m$-smooth polynomials only depends on the position of the prescribed zero coefficients.
We remark, if $0\in \cI$, then we can apply either Theorem~\ref{thm:1} if $\alpha_0\neq 0$ or \eqref{eq:zero_coeff} if $\alpha_0=0$.
In the case $0\not \in \cI$, Theorem~\ref{thm:2} yields the expected frequency if $q\rightarrow \infty$ or $\delta$ is small enough in terms of $u$.
\begin{cor}\label{cor:2}
Assume, that $0\not \in \cI $ and
\begin{itemize}
\item if $q\rightarrow \infty$ for fixed $n$ and $u$; or
\item if $n\rightarrow \infty$ with $\delta = o\left((u\log u)^{9/8}\right)$ and fixed $q$.
\end{itemize}
Then \eqref{eq:expected} holds.
\end{cor}
%We also remark that one can relax the conditions \eqref{eq:condition1}, \eqref{eq:condition2} by having more technical error terms.
\smallskip
Theorems \ref{thm:1} and \ref{thm:2} give asymptotics to the number smooth polynomials with several prescribed coefficients.
Recently, Kuttner and Wang \cite{KuttnerWang}, using different techniques, have considered the \emph{exact} number of smooth polynomials of degree $n$ with given trace, that is, when $\cI=\{n-1\}$.
In a different perspective, Gorodetsky \cite{cite:Gorodetsky:irred} also investigated the number of smooth polynomials with three prescribed coefficients in characteristic 2 and 5 and reveal, after normalization, a cyclic property of their number in terms of $n$.
Hauck and Shparlinski \cite{HaukSparlinski} has also considered similar problems over $\ZZ$ by proving the existence of smooth \emph{integers} (that is, integers without large prime factor) with few nonzero binary digits.
\bigskip
The proof of Theorem~\ref{thm:2} uses the circles method. The major arc analysis is based on character sum estimates on smooth polynomials,
%proved by the analytic approach of Panario, Gourdon and Flajolet \cite{PaGoFl98}
see Section~\ref{sec:char_sum}, and
Bourgain's argument~\cite{cite:Bourgain}, applied for polynomials over finite fields by Ha \cite{Ha:Irreducible_polynomials}, see Section~\ref{sec:SJ}.
The minor arc analysis is based on double exponential sums and the good
factorisation properties of smooth polynomials, see Section~\ref{sec:minor}.
\section{Outline of the proof}
For $f\in \Fq[t]$, write
\begin{equation}\label{eq:norm}
|f|=q^{\deg f}
\end{equation}
with the convention $|0|=0$. One can extend the absolute value $|\cdot|$ to $\F_q(t)$ in the natural way by $|f/g|=q^{\deg f-\deg g}$.
Let $\K_{\infty}$ be the set of formal power series
$$
\K_{\infty}=\left\{\xi=\sum_{i\leq k}x_it^i, k\in \ZZ, x_i\in\Fq \right\},
$$
which is the completion of $\Fq(t)$ at the prime associated to the $(1/t)$-adic valuation.
We extend the norm \eqref{eq:norm} to $\K_{\infty}$ by
$$
|\xi|=q^k,
$$
where $k$ is the larges index so that $x_k\neq 0$.
Also, for $\xi\in \K_{\infty}$ we define
$$
\| \xi\|=\min_{f\in \Fq[t] }|\xi-f|.
$$
Write
$$
\e(\xi)=\exp\left(\frac{2\pi i }{p} \mathrm{tr}_{\Fq}(x_{-1}) \right),
$$
where $\mathrm{tr}_{\Fq}$ is the (absolute) trace of $\Fq$ and $p$ is the characteristic of $\Fq$.
We define $\mathbf{T}$ by $\{\xi\in \K_{\infty}: |\xi|<1 \}$, and fix an additive Haar measure, normalized so that $\int_{\mathbf{T}} \mathrm{d}\xi=1$. Then we have for a polynomial $f\in\Fq[t]$,
\begin{equation}\label{eq:ortogonal}
\int_{\mathbf{T}} \e(f\xi) \mathrm{d}\xi=
\left\{
\begin{array}{cl}
1 & \text{if } f=0, \\
0 & \text{if } f\neq 0,
\end{array}
\right.
\end{equation}
see \cite[Theorem~3.5]{Hayes:Goldbach}.
For given integers $m\leq n$, write
$$
S(\xi;n,m)=\sum_{f\in \cS(n,m)}\e(f \xi).
$$
For a nonempty subset $\cI\subset \{0,1,\dots n-1\}$ fix $\alpha_i\in\F_q[t]$ for $i\in \cI$.
Let $\cJ$ defined by \eqref{eq:setJ} and write
$$
S_{\cJ}(\xi)=\sum_{f\in\cJ}\e(f\xi).
$$
By \eqref{eq:ortogonal}, we have
\begin{align}\label{eq:int}
\int_{\mathbf{T}} S(\xi;n,m) \overline{S_{\cJ}(\xi)} \mathrm{d}\xi = \sum_{f\in\cS(n,m)} \sum_{g\in \cJ} \int_{\mathbf{T}} \e((f-g)\xi) \mathrm{d}\xi = \#(\cS(n,m)\cap \cJ).
\end{align}
We investigate this integral by the circle method. To do so, let $\kappa, \ell$ be two positive parameters to be fixed later such that
\begin{equation*}
\ell+\kappa<n
\end{equation*}
and define the major and minor arcs by
\begin{equation}\label{eq:major}
\fM = \bigcup_{|a|<|g|\leq q^{\kappa}}\left\{\xi \in \bT: \left|\xi-\frac{a}{g}\right|<q^{-n+\ell} \right\}
\mand \fm = \bT \setminus \fM.
\end{equation}
We give approximation of $S(\xi;n,m)$ on major arcs in Section~\ref{sec:major} using character sum estimates on smooth polynomials introduced in Section~\ref{sec:char_sum}. %and proved by the analytic approach of Panario, Gourdon and Flajolet \cite{PaGoFl98}.
The minor arc estimates of $S(\xi;n,m)$ are based on double exponential sums and the good
factorisation properties of smooth polynomials, see Section~\ref{sec:minor}.
The analysis of $S_{\cJ}(\xi)$ is based on Bourgain's argument \cite{cite:Bourgain}, applied for polynomials over finite fields by Ha \cite{Ha:Irreducible_polynomials}, see Section~\ref{sec:SJ}.
\section{Preliminaries}
\subsection{Notations}
For given functions $F$ and $G$, the notations $F\ll G$, $G \gg F$ and $F =O(G)$ are all equivalent to the statement that the inequality $|F| \leq c|G|$
holds with some constant $c > 0$. Throughout the paper, any implied
constants in symbols O, $\ll$ and $\gg$ are absolute unless specified otherwise.
For a set $\cA$ we denote the characteristic function of $\cA$ by $\mathbf{1}(\cA)$.
\smallskip
We let $\cM=\bigcup_n \cM(n)$ and $\cP=\bigcup_n \cP(n)$ to be the sets of \emph{all monic} and \emph{all monic irreducible polynomials} respectively.
\subsection{Arithmetically distributed relations}
For a monic polynomial $f=t^n+c_{n-1}t^{n-1}+\dots +c_0$, we call $c_{n-1},\dots, c_{n-\ell}$ the first $\ell$ coefficients of $f$. Define $f^{*}=t^{\deg f}f(1/t)$. For $\ell \geq 0$ and $g\in \Fq[t]$, define the \emph{arithmetically distributed relation}
$\cR_{\ell,g}$ as
$$
f\equiv h \mod \cR_{\ell,g} \quad \text{if} \quad f\equiv h \mod g \mand f^*\equiv h^* \mod t^{\ell+1},
$$
that is, if $f$ and $h$ are congruent modulo $g$ and their first $\ell$ coefficients are the same.
Clearly, an arithmetically distributed relation $\cR_{\ell,g}$ is an equivalence relation.
We also write $\cR_{\ell}=\cR_{\ell,1}$ and $\cR_{g}=\cR_{0,g}$.
Observe, that $\cR_\ell$ on fixed degree polynomials captures the polynomials on intervals, that is, for polynomials $f,h\in\cM(n)$,
$$
f \equiv h \mod \cR_\ell \quad \text{if and only if} \quad |f-h|<q^{n-\ell}.
$$
The polynomial $f$ is invertible modulo $\cR_{\ell,g}$ if $\gcd(f,g)=1$. These invertible polynomials form a group, denoted by $G_{\ell, g}=\left(\cM/\cR_{\ell,g}\right)^\times$. Write $G_{\ell}=\left(\cM/\cR_{\ell}\right)^\times$ and $G_{g}=\left(\cM/\cR_{g}\right)^\times$. Then we have
\begin{equation}\label{eq:CRT}
G_{\ell, g} \cong G_{\ell} \times G_{g},
\end{equation}
see \cite[Theorem~8.6]{Hayes:Distribution} and \cite[Lemma~1.1]{Hsu:Distribution}. We also have $\# G_{\ell}=q^\ell$ and
$$
\#G_{g}=\#(\Fq[t]/(g))^{\times}=\Phi(g).
$$
We have the following lower bound on $\Phi(g)$, see \cite[Lemma~2.3]{Ha:Irreducible_polynomials},
\begin{equation}\label{eq:phi}
\Phi(H) \gg
\frac{|g|}{\log_q (\deg g) +1 } \quad \text{for } g\neq 0.
\end{equation}
Let $\chi$ be a character modulo an arithmetically distributed relation $\cR_{\ell,g}$, and let $L(s,\chi)$ be the associated $L$-function,
$$
L(s,\chi)=\sum_{f\in\cM}\frac{\chi(f)}{|f|^s}=\prod_{\substack{\omega \nmid g\\\omega \in\cP}}\left(1-\frac{\chi(\omega)}{|\omega|^s}\right)^{-1} , \quad \re (s) >1.
$$
The following result, see \cite[Theorem~1.3]{Hsu:Distribution}, follows from the Riemann hypothesis for the $L$-functions of algebraic curves over finite fields proved by Weil \cite{weil}.
\begin{lemma}\label{lemma:Weil}
If $\chi$ is a non-trivial multiplicative character modulo $\cR_{\ell,g}$, then there exists a polynomial $P_\chi$ of degree at most $ \ell -1+\deg g$ and of form
$$
P_\chi(z)=\prod_i\left(1-\alpha_i z\right)
$$
with $L(s,\chi)=P_\chi(q^{-s})$ and $|\alpha_i|=\sqrt{q}$ with at most one exceptional $\alpha_i$ with $|\alpha_i|=1$.
\end{lemma}
Using Lemma~\ref{lemma:Weil}, on can derive the following character sum estimates along irreducible polynomials, see \cite{Hsu:Distribution} for more details.
\begin{lemma}\label{lemma:char_sum_irred}
Let $\chi$ be a non-trivial character modulo $\cR_{\ell,g}$. Then
$$
\left|\sum_{\omega\in\cP(n)}\chi(\omega)\right|\leq \frac{1}{n}(\ell-1+\deg g)q^{n/2}.
$$
\end{lemma}
%\begin{lemma}\label{lemma:char_sum_irred}
% Let $\chi$ be a non-trivial character modulo $\cR_{\ell,g}$. Then
% $$
%\left|\sum_{\omega\in\cP(n)}\chi(\omega)\right|\leq \frac{1}{n}(\ell-1+\deg g)q^{n/2}. \quad \text{\color{red} \bf To be checked}
% $$
%\end{lemma}
\subsection{Exponential sums}
We have, see \cite[Theorem~3.7]{Hayes:Goldbach}.
\begin{lemma}\label{lemma:ort1}
Suppose $|\xi|<1$. Then
$$
\sum_{f\in \cM(n)}\e(f\xi)=
\left\{
\begin{array}{lc}
q^n \e(t^{n}\xi) & \text{if } |\xi|<q^{n},\\
0 & \text{otherwise}.
\end{array}
\right.
$$
\end{lemma}
We have, see \cite[Equation~(4.6)]{Hayes:Goldbach}.
\begin{lemma}\label{lemma:ort2}
If $a,b$ are invertible modulo $\cR_{\ell, g}$, then
$$
\frac{1}{q^{\ell}\Phi(g)}
\sum_{\chi \bmod \cR_{\ell, g}}\bar{\chi}(a)\chi(b)=
\left\{
\begin{array}{ll}
1 & \text{if } a\equiv b \mod \cR_{\ell,g},\\
0 & \text{otherwise}.
\end{array}
\right.
$$
\end{lemma}
For the following result see \cite[Theorem~6.1]{Hayes:Goldbach}.
\begin{lemma}\label{lemma:Ram}
For polynomials $f,g$, we have
$$
\sideset{}{^*}\sum_{a \bmod g}\e(af/g)=\sum_{d \mid \gcd(f,g)}|d|\mu(g/d).
$$
\end{lemma}
We can prove the following results on polynomial Gauss sums.
% \begin{lemma}\label{lemma:Gauss}
% For polynomials $f,g$, we have
% $$
% \sum_{\chi \bmod \cR_{\ell, g}}
% \left|\
% \sideset{}{^*}\sum_{a \bmod \cR_{\ell,g}}\chi(a)\e(a/g)
% \right|^2=q^{2\ell} \Phi(g)^2
% $$
% \end{lemma}
% \begin{proof}
% We have by Lemma \ref{lemma:ort2}, that
% \begin{align*}
% &\sum_{\chi \bmod \cR_{\ell, g}}
% \left|\
% \sideset{}{^*}\sum_{a \bmod \cR_{\ell,g}}\chi(a)\e(a/g)
% \right|^2\\
% &=
% \sum_{\chi \bmod \cR_{\ell, g}}
% \left(\ \sideset{}{^*}\sum_{a \bmod \cR_{\ell,g}}\chi(a)\e(a/g) \right)\left( \ \sideset{}{^*}\sum_{b \bmod \cR_{\ell,g}}\bar{\chi}(b)\e(-b/g) \right)\\
% &=\sideset{}{^*}\sum_{a,b \bmod \cR_{\ell, g} } \e((a-b)/g)\sum_{\chi \bmod \cR_{\ell, g}} \chi(a/b)\\
% &=q^\ell \Phi(g) \sideset{}{^*}\sum_{a\equiv b \bmod \cR_{\ell, g}} \e((a-b)/g)= q^{2\ell}\Phi(g)^2.
% \end{align*}
% \end{proof}
\begin{lemma}\label{lemma:Gauss}
For polynomials $b,g$, we have
$$
\sum_{\chi \bmod \cR_{\ell, g}}
\left|\
\sideset{}{^*}\sum_{\substack{a \bmod \cR_{\ell,g}\\ a \equiv b \bmod \cR_\ell }}\chi(a)\e(a/g)
\right|^2=q^{\ell} \Phi(g)^2
$$
\end{lemma}
\begin{proof}
We have by Lemma \ref{lemma:ort2}, that
\begin{align*}
&\sum_{\chi \bmod \cR_{\ell, g}}
\left|\
\sideset{}{^*}\sum_{\substack{a \bmod \cR_{\ell,g}\\ a \equiv b \bmod \cR_\ell }}\chi(a)\e(a/g)
\right|^2\\
&=
\sum_{\chi \bmod \cR_{\ell, g}}
\left(\ \sideset{}{^*}\sum_{\substack{a_1 \bmod \cR_{\ell,g}\\ a_1 \equiv b \bmod \cR_\ell }}\chi(a_1)\e(a_1/g) \right)\left( \ \sideset{}{^*}\sum_{\substack{a_2 \bmod \cR_{\ell,g}\\ a_2 \equiv b \bmod \cR_\ell }}\bar{\chi}(a_2)\e(-a_2/g) \right)\\
&=\sideset{}{^*}\sum_{\substack{a_1,a_2 \bmod \cR_{\ell, g}\\ a_1\equiv a_2\equiv b \mod \cR_\ell }} \e((a_1-a_2)/g)\sum_{\chi \bmod \cR_{\ell, g}} \chi(a_1)\bar{\chi}(a_2)\\
&=q^\ell \Phi(g) \sideset{}{^*}\sum_{
\substack{a_1\equiv a_2 \bmod \cR_{g}\\a_1\equiv a_2\equiv b \bmod \cR_{\ell}}}
\e((a-b)/g)= q^{\ell}\Phi(g)^2.
\end{align*}
\end{proof}
For the following estimate see \cite[Lemma~4]{cite:Merai_Divisors_of_sum}.
\begin{lemma}\label{lemma:minor-1}
Let
\begin{equation*}
\xi= \frac{a}{g}+ \gamma \quad \text{with} \quad |\gamma| \leq \frac{1}{|g|^2} \quad \text{and} \quad (a,g)=1.
\end{equation*}
Then we have
\begin{equation*}
\sum_{f\in\cM(k)}\left|\sum_{h \in \cM(j)} \e(\xi fh) \right|\ll \frac{q^{k+j}}{|g|} + q^k +|g|.
\end{equation*}
\end{lemma}
\subsection{Dickman's $\rho$ function}\label{seq:rho}
We need the following result on Dickman's $\rho$ function which follows directly from \cite[Lemma~III. 5.11]{cite:Tenenbaum} and \cite[Corollary~III. 5.15]{cite:Tenenbaum}.
\begin{lemma}\label{lemma:rho}
Uniformly over $0\leq v\leq u$, we have
$$
\rho(u-v)\ll (u \log u)^{v}\rho(u).
$$
\end{lemma}
For the following result see \cite[Lemma 4.1]{FoTe91}.
\begin{lemma}\label{lemma:rho'}
For any integer $k\geq 0$ we have
$$
(-1)^k\rho^{(k)}(u) > 0 \quad \text{for $ u >1$}
$$
and
$$
\rho^{(k)}(u)\sim (-1)^k \rho(u)(\log u)^k \quad \text{as } u \rightarrow \infty.
$$
\end{lemma}
\subsection{Further preliminaries}
% \begin{claim}
% We have
% $$
% \prod_{\substack{\omega \mid Q\\ \omega \in\cI}}\left(1+\frac{1}{|\omega|}\right)\ll \log_q \deg Q.
% $$
% \end{claim}
% \begin{proof}
% Clearly, it is enough to prove the assertion for square-free polynomials.
% Write
% $$
% \sigma(Q)=\prod_{\substack{\omega \mid Q\\ \omega \in\cI}}\left(1+\frac{1}{|\omega|}\right)
% $$
% and for a positive integer $A$
% $$
% \Omega_A=\prod_{\substack{\deg \omega \leq A\\ \omega \in \cI}}\omega.
% $$
% First we prove the claim for $\Omega_A$. By \eqref{eq:irred}, we have
% $$
% \log \sigma (\Omega_A)= \sum_{\substack{\deg \omega\leq A\\ \omega \in \cI}} \log (1+1/|\omega|)=
% \sum_{k=1}^A \pi_q(k) \cdot \log (1+q^{-k})\leq \sum_{k=1}^A \frac{1}{k}.
% $$
% We have by the Euler–Maclaurin formula that
% $$
% \sum_{k=1}^A\frac{1}{k}\leq \log A + \gamma +\frac{1}{2A},
% $$
% thus
% $$
% \sigma(\Omega_A)\leq e^{\gamma +1} A.
% $$
% On the other hand,
% $$
% \deg \Omega_A =\sum_{k=1}^A k \pi_q(k)\geq \sum_{k\mid A} k \pi_q(k)=q^A-1,
% $$
% thus
% $$
% \sigma(\Omega_A)\leq e^{\gamma +1} A \leq e^{\gamma +1} \log _q \deg \Omega_A.
% $$
% If $P$ is such a polynomial that
% \begin{equation}\label{eq:Omega}
% \Omega_{A-1}\mid P\mid \Omega_{A},
% \end{equation}
% then
% $$
% \sigma(P)\leq \sigma(\Omega_A)\leq e^{\gamma +1} A \leq e^{\gamma +2} (A-1) \leq e^{\gamma +2} \log _q \deg \Omega_{A-1}\leq e^{\gamma +2} \log _q \deg P.
% $$
% Finally, if P does not have the form \eqref{eq:Omega}, let $\hat{P}$ be a square-free polynomial of form \eqref{eq:Omega} obtained from $P$ replacing irreducible factors of $P$ by smaller degree irreducible terms. Then
% $$
% \sigma(P)\leq \sigma(\hat{P})\leq e^{\gamma +2} \log _q \deg \hat{P}\leq e^{\gamma +2} \log _q \deg P.
% $$
% \end{proof}
% \begin{lemma}
% We have
% $$
% \Phi(f)\gg \frac{|f|}{1+\log_q \deg f }.$$
% \end{lemma}
The following lemma of Hayes \cite[Theorem 4.3]{Hayes:Goldbach} is an analogue of a well-known result of Dirichlet
in the theory of Diophantine approximation.
\begin{lemma}\label{lemma:dio}
For any integer $n$ and $\xi\in\mathbf{T}$, there is a pair of coprime polynomials $a,g\in\Fq[t]$ with $g$ monic, $|a|<|g|\leq q^{n/2}$ such that
$$
\left|\xi - \frac{a}{g}\right|<\frac{1}{|g|q^{n/2}}.
$$
\end{lemma}
Let $\tau(f)$ denote the number of divisors of $f$. We have the following bound on $\tau(f)$.
\begin{lemma}\label{lemma:number_of_divisors}
For any $\varepsilon>0$ there is a constant $c(\varepsilon)>0$ such that
$$
\tau(f) \leq c(\varepsilon) |f|^{(2+\varepsilon)/\log \deg f}.
$$
\end{lemma}
The proof of this lemma is analogue to the integer case, however, we include its proof for the sake for completeness.
\begin{proof}
Write
$$
f=g_1^{e_1}\dots g_k^{e_k}
$$
with pairwise distinct irreducible polynomials $g_1,\dots, g_k$.
Then
$$
\tau(f)=\prod_{i=1}^k(e_i+1).
$$
For any $\lambda>0$ we have
$$
\frac{\tau(f)}{\exp(\lambda \deg f)}
=\prod_{i=1}^k\frac{e_i+1}{\exp(\lambda e_i\deg g_i)}
\leq
\prod_{i=1}^k\frac{e_i+1}{1+\lambda e_i\deg g_i }.
$$
For $\deg g_i >1/\lambda$ we have
$$
\frac{e_i+1}{1+\lambda e_i\deg g_i }<1.
$$
Thus
$$
\frac{\tau(f)}{\exp(\lambda \deg f)}\leq
\prod_{\deg g_i \leq 1/\lambda}\frac{e_i+1}{1+\lambda e_i\deg g_i }.
$$
As there are at most $q^{1/\lambda}$ irreducible polynomial of degree at most $1/\lambda$, we get
\begin{equation}\label{eq:tau}
\frac{\tau(f)}{\exp(\lambda \deg f)}\leq \left(\frac{1}{\lambda}\right)^{q^{1/\lambda}}=\exp \left(q^{1/\lambda} \log(1/\lambda) \right).
\end{equation}
Choosing
$$
\lambda = \frac{2\log q}{\log \deg f},
$$
we get that the logarithm of \eqref{eq:tau} is
$$
\log \frac{\tau(f)}{\exp\left(\frac{2\log q\deg f}{\log \deg f} \right)}\leq (\deg f)^{1/2}\log \frac{\log \deg f}{2\log q}\leq \varepsilon \frac{\log q \deg f}{\log \deg f}
$$
if $\deg f$ is large enough in terms of $\varepsilon$.
\end{proof}
% We have the following lower bound on $\Phi(g)$, see e.g. \cite[Lemma~2.3]{Ha:Irreducible_polynomials}.
% \begin{lemma}\label{lemma:totient}
% For any $g\in\Fq[t]$, we have
% $$
% \Phi(g)\gg \frac{|g|}{1+\log_q \deg q}.
% $$
% \end{lemma}
\section{Distribution of smooth polynomials}
\label{sec:char_sum}
The purpose of this section is to prove character sum estimates along smooth polynomial. The proof is based on the method of Bhowmick, L\^{e} and Liu \cite{cite:Bhow_et_al}, see also \cite{cite:Gorod2022}. We consider both cases of $q$ or $n$ are fixed in contrast to \cite{cite:Bhow_et_al,cite:Gorod2022}.
%The purpose of this section is to prove the following result by the analytic approach of Panario, Gourdon and Flajolet \cite{PaGoFl98}.
% Let $g\in\Fq[t]$ be invertible in $\cR_{\ell,h}$. We are interested in the cardinality of the set
% $$
% \cS(n,m;g,\cR)=\{f\in S(n,m): \ f\equiv g \mod \cR\}.
% $$
% We may also need the quantity
% $$
% \Psi(n,m;\cR)=\#\{f\in\cS(n,m): \ f \text{ is invertible} \bmod \cR \}.
% $$
% \begin{lemma}\label{lemma:char_sum}
% Let $\chi$ be a character modulo $\cR_{\ell, g}$ and $n>\ell -1 +\deg g$. If $\chi\neq \chi_0$, then
% $$
% \sum_{f\in S(n,m)}\chi(f)\ll (\ell +\deg g) \left(1+q^{-1/2}\right)^{\ell +\deg g}q^{n-m/2}.
% $$
% \end{lemma}
% \begin{proof}
% Write
% $$
% T(z,\chi;m)=\prod_{\omega \in \cP , \deg \omega \leq m}\left(1-\chi(\omega)z^{\deg \omega}\right)^{-1} \quad z\in\mathbb{C}.
% $$
% For $|z|<1/q$, we have
% $$
% T(z,\chi;m)=\sum_{n=0}^\infty S(\chi;n,m)z^n, \quad S(\chi;n,m)=\sum_{f\in\cS(n,m)}\chi(f)
% $$
% as
% $$
% \left|S(\chi;n,m)\right|\leq q^n.
% $$
% Write
% $$
% P_\chi(z)=\sum_{f\in\cM}\chi(f)z^{\deg f} =\prod_{\omega \in \cP }\left(1-\chi(\omega)z^{\deg \omega}\right)^{-1}, \quad |z|< 1/q.
% $$
% We have by Lemma~\ref{lemma:Weil} that $P_\chi$ is actually a polynomial. Then for $|z|<1/q$, we have
% \begin{align*}
% T(z,\chi;m)&=P_\chi(z) \prod_{\omega \in \cP , \deg \omega > m}\left(1-\chi(\omega)z^{\deg \omega}\right).
% \end{align*}
% Here
% \begin{align*}
% \prod_{\omega \in \cP , \deg \omega > m}\left(1-\chi(\omega)z^{\deg \omega}\right)&=\exp \left( \sum_{k>m} \sum_{\omega \in \cP(k)} \log \left(1-\chi(\omega)z^k\right)\right)\\
% &=\exp \left( -\sum_{k>m} \sum_{\omega \in \cP(k)}
% \sum_{j\geq 1} \frac{\left(\chi(\omega)z^k\right)^j}{j}
% \right)\\
% &=\exp \left( -\sum_{j\geq 1}\frac{1}{j} \sum_{k>m} z^{kj}\sum_{\omega \in \cP(k)} \chi(\omega)^j
% \right).
% \end{align*}
% For $j=1$, we have by Lemma~\ref{lemma:char_sum_irred},
% \begin{align*}
% \left|\sum_{k>m} z^{k}\sum_{\omega \in \cP(k)} \chi(\omega)\right|&\leq
% \sum_{k>m} |z|^{k} (\ell -1 +\deg g)q^{k/2}\leq
% (\ell -1 +\deg g)
% \sum_{k>m} q^{-k/2}\\
% &\ll (\ell +\deg g)q^{-m/2}.
% \end{align*}
% For $j\geq 2$, we have by \eqref{eq:irred}
% \begin{align*}
% \left|\sum_{j\geq 2}\frac{1}{j} \sum_{k>m} z^{kj}\sum_{\omega \in \cI(k)} \chi(\omega)^j\right| \leq \sum_{j\geq 2}\frac{1}{j} \sum_{k>m} \pi_q(k)|z|^{kj}\ll \sum_{j\geq 2}\frac{1}{j} \sum_{k>m} \frac{1}{k} \frac{1}{q^{k(j-1)}} \ll q^{-m}.
% \end{align*}
% We can assume, that $ (\ell +\deg g)q^{-m/2}\ll 1$ since otherwise the result is trivial. Then we get
% \begin{align*}
% \prod_{\omega \in \cI , \deg \omega > m}\left(1-\chi(\omega)z^{\deg \omega}\right)&=
% \exp\left(O\left( (\ell +\deg g)q^{-m/2}\right) \right)\\
% &=
% 1+O\left( (\ell +\deg g)q^{-m/2}\right), \quad |z|<1/q
% \end{align*}
% and so
% \begin{equation}\label{eq:split}
% T(z,\chi;m)=P_\chi(z)\left(1+O\left((\ell +\deg g)q^{-m/2}\right)\right), \quad |z|<1/q.
% \end{equation}
% By the Cauchy's integral formula, we have
% $$
% S(\chi;n,m)=q^n\frac{1}{2\pi i}\int _\cC \frac{T(z/q,\chi;m)}{z^{n+1}} \d z,
% $$
% where the contour $\cC$ is chosen to be $z= e^{1/n + i\theta}$, $-\pi \leq \theta \leq \pi$.
% We have by \eqref{eq:split}
% \begin{align*}
% S(\chi;n,m)&=q^n\frac{1}{2\pi i}\int _\cC \frac{T(z/q,\chi;m)}{z^{n+1}} \d z\\
% &=q^n\frac{1}{2\pi i}\int _\cC \frac{P(z/q,\chi)}{z^{n+1}} \d z
% +O\left(q^n\left( (\ell +\deg g)q^{-m/2}\right)\int _\cC \frac{|P(z/q,\chi)|}{|z|^{n+1}} \d z \right)\\
% &=\sum_{f \in\cM(n)}\chi(f)
% +O\left(q^n\frac{1}{2\pi i}\left((\ell +\deg g)q^{-m/2}\right)\int _\cC \frac{|P(z/q,\chi)|}{|z|^{n+1}} \d z \right).
% \end{align*}
% As $n>\ell -1 + \deg g$, it follows from Lemma~\ref{lemma:Weil}, that
% $$
% \sum_{f\in\cM(n)}\chi(f)=0.
% $$
% We also have for $z\in\cC$ by Lemma~\ref{lemma:Weil} that
% $$
% \frac{|P(z/q,\chi)|}{|z|^{n+1}}=e^{(n+1)/n} \prod_{i=1}^{\ell -1 +\deg g}\left|1-\frac{z}{q}\alpha_i\right|\ll \left(1+q^{-1/2}\right)^{\ell +\deg g}.
% $$
% Whence
% $$
% S(\chi;n,m) \ll (\ell +\deg g) \left(1+q^{-1/2}\right)^{\ell +\deg g}q^{n-m/2}.
% $$
% \end{proof}
\begin{lemma}\label{lemma:char_sum}
Let $\chi\neq\chi_0$ be a character modulo $\cR_{\ell,g}$ and $n>\ell-1+\deg g$.
\begin{enumerate}[label=(\roman*)]
\item \label{item:charsum1} We have
$$
\left| \sum_{f\in S(n,m)}\chi(f)\right|\leq
q^{\frac{n}{2}+\frac{\log \log(\ell+1+\deg g)}{\log(\ell+1+\deg g)}}e^{ 13q \frac{\ell+1+\deg g}{\log^2(\ell+1+\deg g)} }
$$
if $\ell + \deg g$ is large enough in terms of $q$. One can choose
$$
\ell + \deg g > 10^4 \mand \frac{\log (\ell + 1+\deg g)}{\log \log (\ell + 1+\deg g)}>\log q .
$$
\item \label{item:charsum2} Let $0<\varepsilon<1/4$,
then we have
$$
\left|\sum_{f\in S(n,m)}\chi(f)\right|\leq
q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon (\ell+1+\deg g)}
$$
if $q$ is large enough in terms of $\varepsilon$. One can choose $q>(1+1/\varepsilon)^{1/\varepsilon}$.
\end{enumerate}
\end{lemma}
\begin{proof}
Write
$$
T(z,\chi;m)=\prod_{\omega \in \cP , \deg \omega \leq m}\left(1-\chi(\omega)z^{\deg \omega}\right)^{-1}.
$$
For $z\in\mathbb{C}$ with $|z|<1$, we have
$$
T(z,\chi;m)=\sum_{r=0}^\infty S(\chi;r,m)z^r, \quad S(\chi;r,m)=\sum_{f\in\cS(r,m)}\chi(f).
$$
The logarithm of $T(z,\chi;m)$ is given by
\begin{equation}\label{eq:logT}
\log T(z,\chi;m) = \sum_{\omega \in \cP ,\deg \omega \leq m } \chi(\omega) z^{\deg \omega}+ \sum_{k\geq 2 }k^{-1}\sum_{\omega \in \cP ,\deg \omega \leq m } \chi(\omega)^k z^{k\deg \omega}
.
\end{equation}
By Lemma~\ref{lemma:char_sum_irred}, we have
\begin{equation}\label{eq:charsum-nontrivial}
\left|\sum_{\omega\in\cP(r)}\chi(\omega) \right|\leq \frac{\ell -1+ \deg g}{r}q^{r/2}.
\end{equation}
We also have the trivial bound
\begin{equation}\label{eq:charsum-trivial}
\left|\sum_{\omega\in\cP(r)}\chi(\omega) \right|\leq \frac{q^{r}}{r}
\end{equation}
by \eqref{eq:irred}.
Let $R$ be a positive integer to be fixed later.
For for $r\geq R$ we use \eqref{eq:charsum-nontrivial} in \eqref{eq:logT}, while $r< R$ we use the trivial bound \eqref{eq:charsum-trivial}. Namely, \eqref{eq:charsum-nontrivial} yields that for $r\geq R$, we have that the coefficient of $z^r$ in \eqref{eq:logT} is bounded in absolute value by
\begin{equation}\label{eq:large_r}
\frac{\ell -1+ \deg g}{r}q^{r/2} + \sum_{\substack{k\mid r\\k\geq 2}} k^{-1} \#\cP(r/k)\leq \frac{\ell + 1+\deg g}{r}q^{r/2}.
\end{equation}
For $r< R$, the trivial bound \eqref{eq:charsum-trivial} yields, that the coefficient of $z^r$ in \eqref{eq:logT} is bounded in absolute value by
\begin{equation}\label{eq:small_r}
\frac{q^{r}}{r} + \sum_{\substack{k\mid r\\k\geq 2}} k^{-1} \#\cP(r/k)\leq \frac{2}{r}q^{r}.
\end{equation}
Combining \eqref{eq:large_r} and \eqref{eq:small_r}, we get
\begin{equation}\label{eq:log_T}
\log T(z,\chi;m) \leq \sum_{1\leq r < R} \frac{2}{r}(q|z|)^r + \sum_{r\geq R} \frac{\ell+1+\deg g}{r}(q^{1/2}|z|)^r.
\end{equation}
In order to prove \ref{item:charsum1}, put
$$
R=\left\lfloor 2\frac{\log(\ell + 1 +\deg g)}{\log q} \right\rfloor +1.
$$
With this choice, we have
\begin{equation}\label{eq:q-to-R}
q^{(R-1)/2}\leq \ell + 1+\deg g\leq q^{
R/2}.
\end{equation}
Also, let
\begin{equation}\label{eq:delta_def}
0 <\delta<\min\left\{\frac{1}{\log q},\frac{1}{4} \right\}
\end{equation}
to be chosen later. With this choice, put $Z=q^{-1/2-\delta}$ and let $|z|=Z$.
Then for the first term of \eqref{eq:log_T} we have
\begin{align}\label{eq:r_sum1}
\sum_{1\leq r < R} \frac{2}{r}(q|z|)^r
\leq 2 (qZ)^{R-1} \sum_{r\geq 0} (qZ)^{-r}
\leq \frac{2 (\ell+1+\deg g)^2 Z^{R-1}}{1-(qZ)^{-1}}
\leq 13 (\ell+1+\deg g)^2 Z^{R-1}
\end{align}
using $|qZ|\geq q^{1/4}\geq 2^{1/4}$.
Also,
\begin{align}\label{eq:r_sum2}
\sum_{r\geq R} \frac{\ell+1+\deg g}{r}(q^{1/2}Z)^r\leq \frac{\ell+1+\deg g}{R} \cdot\frac{(q^{1/2}Z)^{R}}{1-q^{1/2}Z}.
\end{align}
Then combining \eqref{eq:log_T}, \eqref{eq:r_sum1} and \eqref{eq:r_sum2}, we
have by \eqref{eq:q-to-R} that
\begin{align*}
\log T(z,\chi;m) &\leq 13 (\ell+1+\deg g)^2 q^{-(1/2+\delta)(R-1)} + \frac{\ell+1+\deg g}{R} \cdot\frac{q^{-\delta R}}{1-q^{-\delta}}\\
&\leq (\ell+1+\deg g)^{(1-2\delta)} \left( 13q^{1/2} + \frac{1}{R(1-q^{-\delta})}\right).
\end{align*}
As $\delta<1/\log q$, we have $1-q^{-\delta}\geq \frac{1}{2}\delta \log q$, thus
\begin{align*}
\log T(z,\chi;m)&\leq (\ell+1+\deg g)^{(1-2\delta)} \left( 13q^{1/2} + \frac{1}{R\delta \log q}\right)\\
&\leq (\ell+1+\deg g)^{(1-2\delta)} \left( 13q^{1/2} + \frac{1}{\delta \log ( \ell+1+\deg g )}\right)
.
\end{align*}
Let $C_Z$ denote the circle centered at 0 with radius $Z$. Then, by the Cauchy's integral formula, we have
\begin{align*}
|S(\chi,n,m)|&=\left|\frac{1}{2\pi i} \int_{C_Z} T(z,\chi;m)z^{-n-1}\d z \right|\\
&\leq \max_{C_Z}|T(z,\chi;m)| Z^{-n}\\
&\leq \exp\left((\ell+1+\deg g)^{(1-2\delta)} \left( 13q^{1/2} + \frac{1}{\delta \log ( \ell+1+\deg g )}\right) \right) q^{(1/2+\delta)n}.
\end{align*}
Put
$$
\delta = \frac{\log \log(\ell+1+\deg g )}{\log(\ell+1+\deg g ) }
$$
and observe that it satisfies \eqref{eq:delta_def} by assumption.
If $\ell+1+\deg g >10^4$, then $\delta\leq 1/4$, and also, $\delta \leq \frac{1}{\log q}$. Then
\begin{align*}
&(\ell+1+\deg g)^{(1-2\delta)} \left( 13q^{1/2} + \frac{1}{\delta \log ( \ell+1+\deg g )}\right)\\
=&\frac{\ell+1+\deg g }{\log ^2 (\ell+1+\deg g)}\left( 13q^{1/2} + \frac{1}{\log \log ( \ell+1+\deg g )}\right)\\
\leq &
13q\frac{\ell+1+\deg g }{\log ^2 (\ell+1+\deg g)}
\end{align*}
which proves \ref{item:charsum1}.
In order to prove \ref{item:charsum2}, we choose $R=1$, that is, in \eqref{eq:log_T} the first term vanishes and
\begin{equation*}
\log T(z,\chi;m) \leq \sum_{r\geq 1} \frac{\ell+1+\deg g}{r}(q^{1/2}|z|)^r.
\end{equation*}
Choose $Z=q^{-1/2-\varepsilon}$. For $|z|=Z$, we have
\begin{equation*}
\log T(z,\chi;m) \leq \sum_{r\geq 1} \frac{\ell+1+\deg g}{r}(q^{-\varepsilon})^r
\leq (\ell+1+\deg g) \cdot\frac{q^{-\varepsilon }
}{1-q^{-\varepsilon}}
\leq \varepsilon (\ell+1+\deg g)
\end{equation*}
if $q$ is large enough in terms of $\varepsilon$.
Then, by the Cauchy's integral formula, we have
\begin{align*}
|S(\chi,n,m)|&=\left|\frac{1}{2\pi i} \int_{C_Z} T(z,\chi;m)z^{-n-1}\d z \right|\\
&\leq \max_{C_Z}|T(z,\chi;m)| Z^{-n}\\
&\leq \exp\left(\varepsilon (\ell+1+\deg g) \right) q^{(1/2+\varepsilon)n},
\end{align*}
which proves \ref{item:charsum2}.
\end{proof}
The following result unifies the two bounds of Lemma~\ref{lemma:char_sum}.
\begin{cor}\label{cor:char_sum}
Let $\chi\neq\chi_0$ be a character modulo $\cR_{\ell,g}$ and $n\geq \ell+\deg g$. For all $0<\varepsilon<1/4$, we have
$$
\sum_{f\in S(n,m)}\chi(f)\ll
q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon (\ell+\deg g)},
$$
where the implied constant may depend on $\varepsilon$.
\end{cor}
\begin{proof}
We can assume, that $q^n$ is large enough in terms of $\varepsilon$.
If $q>(1+1/\varepsilon)^{1/\varepsilon}$, then we apply \ref{item:charsum2} of Lemma~\ref{lemma:char_sum} directly. Otherwise,
$$
e^{ 13q \frac{\ell+1+\deg g}{\log^2(\ell+1+\deg g)} } \ll e^{\varepsilon (\ell+\deg g)}
$$
and if $n$ is large enough, then
$$
q^{\frac{\log \log(\ell+1+\deg g)}{\log(\ell+1+\deg g)}} \ll q^{\varepsilon n}.
$$
\end{proof}
As an application, we prove the following result on the distribution of smooth polynomials in intervals.
\begin{lemma}\label{lemma:smooth_in_interval}
Let $0<\varepsilon<1/4$.
For $1\leq \ell\leq n$ we have for $b\in \Fq[t]$ that
$$
\#\{f\in \cS(n,m): f\equiv b \mod \cR_\ell\}=\frac{1}{q^\ell}\Psi(n,m) + O\left(q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon \ell}\right),
$$
where the implied constant may depend on $\varepsilon$.
\end{lemma}
\begin{proof}
We have
\begin{align}
\#\{f\in \cS(n,m): f\equiv b \mod \cR_\ell\}&=
\frac{1}{q^\ell}\sum_{\chi \bmod \cR_\ell}\overline{\chi(b)} \sum_{f\in \cS(n,m)}\chi(f).
\end{align}
The contribution of the principal character $\chi_0$ is
$$
\frac{1}{q^\ell}\overline{\chi_0(b)} \sum_{f\in \cS(n,m)}\chi_0(f) = \frac{1}{q^\ell}\Psi(n,m) .
$$
By Corollary~\ref{cor:char_sum}, the contribution of the non-principal characters is
\begin{align*}
\frac{1}{q^\ell}\sum_{\chi \neq \chi_0}\overline{\chi(b)} \sum_{f\in \cS(n,m)}\chi(f) \ll
q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon \ell}.
\end{align*}
\end{proof}
\section{Analysis of $\cS(\xi;n,m)$}
In this section we investigate $\cS(\xi;n,m)$ on major and minor arcs.
\subsection{Major arc estimates}\label{sec:major}
Let $\Psi_g(n,m)$ denote the number of $m$-smooth polynomials of degree $n$ which are coprime to $g$,
$$
\Psi_g(n,m)=\#\{f\in\cS(n,m): \gcd(f,g)=1\}.
$$
We split the summation over $f$ in $\cS(\xi;n,m)$ into residue classes modulo $\cR_\ell$
$$
\cS(\xi;n,m) = \sum_{b\bmod \cR_\ell}\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}}\e\left(f \xi\right)
$$
and investigate each term on the major arcs.
\begin{lemma}\label{lemma:major2}
Let $0<\varepsilon<1/4$. For $a,b\in \Fq[t]$, $\gcd(a,g)=1$, $\ell + \deg g<n$, we have
\begin{align*}
\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}}\e\left(\frac{af}{g}\right)&=
\sum_{d \mid g} \frac{\mu(g/d)}{q^{\ell}\Phi(g/d)}
\Psi_{g/d}(n-\deg d,m)
+O\left(q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon (\ell + \deg g)}|g|^{1/2}\right),
\end{align*}
where the implied constant may depend on $\varepsilon$.
\end{lemma}
\begin{proof}
We have
$$
\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}}\e\left(\frac{af}{g}\right)=\sum_{d\mid g} \sum_{\substack{f\in \cS(n-\deg d,m)\\ \gcd(f,g/d)=1\\f \equiv b \bmod \cR_\ell}}
\e\left(\frac{af}{g/d}\right).
$$
For a given $d$ we have by Lemma~\ref{lemma:ort2} that
\begin{align*}
\sum_{\substack{f\in \cS(n-\deg d,m)\\ \gcd(f,g/d)=1\\f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{g/d}\right)&
= \frac{1}{q^{\ell}\Phi(g/d)}\sum_{\chi \bmod \cR_{g/d,\ell}} \sum_{\substack{f\in \cS(n-\deg d,m)} } \chi(f)\sideset{}{^*} \sum_{\substack{c\bmod \cR_{g/d,\ell}\\ c \equiv b \bmod \cR_{\ell}}}\bar{\chi}(c) \e\left(\frac{ac}{g/d}\right),
\end{align*}
where in the innermost sum $c\in\cM(n-\deg d)$ runs over all resuced residue calsses modulo $\cR_{g/d,\ell}$ such that $c\equiv b \mod \cR_{\ell}$. As $n-\deg d > \deg (g/d)+\ell$,
by \eqref{eq:CRT}, the polynomial $c$ runs thorough all residue classes modulo $g/d$. Thus by Lemma~\ref{lemma:Ram}, the contributions of the principal characters $\chi_0^{(g/d,\ell)}$ modulo $\cR_{g/d,\ell}$ is
\begin{align*}
&\sum_{d \mid g} \frac{1}{q^{\ell}\Phi(g/d)} \sum_{\substack{f\in \cS(n-\deg d,m)}} \chi_0^{(g/d,\ell)}(f)
\sideset{}{^*} \sum_{c\bmod g/d}\e\left(\frac{ac}{g/d}\right)
=\sum_{d \mid g} \frac{\mu(g/d)}{q^{\ell}\Phi(g/d)}
\Psi_{g/d}(n-\deg d,m)
%\sum_{\substack{f\in \cS(n-\deg d,m) }} \chi_0^{(g/d)}(f)
.
\end{align*}
By \eqref{eq:CRT} and Lemma~\ref{cor:char_sum}, the contribution of the non-principal characters are
\begin{align*}
&\frac{1}{q^{\ell}\Phi(g/d)}\left|\sum_{\substack{\chi^{(g/d, \ell)} \bmod \cR_{g/d,\ell}\\ \chi^{(g/d, \ell)}\neq \chi^{(g/d, \ell)}_0 }} \sum_{\substack{f\in \cS(n-\deg d,m) }} \chi^{(g/d, \ell)}(f)\sideset{}{^*} \sum_{\substack{c\bmod \cR_{g/d,\ell}\\ c\equiv b \bmod \cR_{\ell}}}\bar{\chi}^{(g/d, \ell)}(a) \e\left(\frac{ac}{g/d}\right)\right|\\
&\leq \frac{1}{q^{\ell}\Phi(g/d)}
\sum_{\substack{\chi^{(g/d, \ell)} \bmod \cR_{g/d,\ell}\\ \chi^{(g/d, \ell)}\neq \chi^{(g/d, \ell)}_0 }} \left|\sum_{\substack{f\in \cS(n-\deg d,m)}} \chi^{(g/d, \ell)}(f)\right|\left| \ \sideset{}{^*} \sum_{\substack{c\bmod \cR_{g/d,\ell}\\ c\equiv b \bmod \cR_{\ell}}}\bar{\chi}^{(g/d, \ell)}(a) \e\left(\frac{ac}{g/d}\right)\right|\\
&\ll
q^{\left(\frac{1}{2}+\varepsilon\right)(n-\deg d)}e^{ \varepsilon (\ell + \deg g)} \frac{1}{q^\ell \Phi(g/d)}
\sum_{\substack{\chi^{(g/d, \ell)}\bmod \cR_{g/d,\ell}}} \left| \ \sideset{}{^*} \sum_{\substack{c\bmod \cR_{g/d,\ell}\\ c\equiv b \bmod \cR_{\ell}}}\bar{\chi}^{(g/d, \ell)}(a) \e\left(\frac{ac}{g/d}\right)\right|.
\end{align*}
By the Cauchy-Schwartz inequality and Lemma~\ref{lemma:Gauss} we have
\begin{align*}
&\left( \
\sum_{\substack{\chi^{(g/d, \ell)}\bmod \cR_{g/d,\ell}}} \left| \ \sideset{}{^*} \sum_{\substack{c\bmod \cR_{g/d,\ell}\\ c\equiv b \bmod \cR_{\ell}}}\bar{\chi}^{(g/d, \ell)}(a) \e\left(\frac{ac}{g/d}\right)\right|\right)^2\\
&\leq q^\ell \Phi(g/d) \sum_{\substack{\chi^{(g/d, \ell)}\bmod \cR_{g/d,\ell}}} \left| \ \sideset{}{^*} \sum_{\substack{c\bmod \cR_{g/d,\ell}\\ c\equiv b \bmod \cR_{\ell}}}\bar{\chi}^{(g/d, \ell)}(a) \e\left(\frac{ac}{g/d}\right)\right|^2\\
&\leq q^{2\ell}\Phi(g/d)^3.
\end{align*}
Thus, summing over $d$ we get, that the error term is
$$
\ll
q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon (\ell+\deg g)}\sum_{d\mid g}q^{-\left(\frac{1}{2}+\varepsilon\right)\deg d}\Phi(g/d)^{1/2}\ll q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon (\ell+\deg g)}|g|^{1/2}\sum_{d\mid g}\frac{1}{|d|^{1+\varepsilon}}
$$
As
\begin{equation*}%\label{eq:reciprocal_sum}
\sum_{d\mid g} \frac{1}{|d|^{1+\varepsilon}}= \sum_{i\leq \deg g} \frac{1}{q^{i(1+\varepsilon)}}\sum_{\substack{d\mid g\\ \deg d =i}} 1\leq \sum_{i\leq \deg g} \frac{1}{q^{\varepsilon i}}\leq \sum_{i=1}^{\infty} \frac{1}{q^{\varepsilon i}}\ll 1,
\end{equation*}
the result follows.
% $$
% m \left(1+q^{-1/2}\right)^{m} \sum_{d\mid g} q^{n-\deg d-m/2} \Phi(g/d)^{1/2} \ll m\left(1+q^{-1/2}\right)^m q^{n-m/2+(\deg g) /2}\sum_{d\mid g} \frac{1}{|d|^{3/2}} .
% $$
% As
% \begin{equation*}%\label{eq:reciprocal_sum}
% \sum_{d\mid g} \frac{1}{|d|^{3/2}}= \sum_{i\leq \deg g} \frac{1}{q^{3i/2}}\sum_{\substack{d\mid g\\ \deg d =i}} 1\leq \sum_{i\leq \deg g} \frac{1}{q^{i/2}}\leq \sum_{i=1}^{\infty} \frac{1}{q^{i/2}}\ll 1,
% \end{equation*}
% the result follows.
\end{proof}
The following result estimates the main term of Lemma~\ref{lemma:major2} for polynomials $g$ of form $g=t^k$.
\begin{lemma}\label{lemma:major}
Let $0<\varepsilon<1/4$. For $b\in \Fq[t]$, $\gcd(b,t)=1$, $1\leq k< n-\ell$, we have
\begin{align*}
\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}}\e\left(\frac{bf}{t^k}\right)&=
%
-\frac{1}{m}\frac{q^{n-\ell-k+1}}{q-1}\rho'\left(\frac{n-k+1}{m}\right)
\left(
1 + O\left(
\frac{\log (u+1)}{m}
\right)
\right)\\
&\quad +
O\left(q^{\left(\frac{1}{2}+\varepsilon\right)n+ \frac{k}{2}}e^{\varepsilon k}
\right)
,
\end{align*}
where the implied constant may depend on $\varepsilon$.
\end{lemma}
\begin{proof}
By~Lemma~\ref{lemma:major2}, the main term is
\begin{align*}
&\sum_{i=0}^{k} \frac{ \mu(t^{k-i}) }{q^\ell\Phi(t^{k-i})} \Psi_{t^{k-i}}(n-i,m)\\
&=\frac{1}{q^{\ell}}\Psi(n-k,m) - \frac{1}{q^{\ell}(q-1)}\Psi_t(n-k+1,m)\\
&=\frac{1}{q^{\ell}}\Psi(n-k,m) - \frac{1}{q^{\ell}(q-1)}\left(\Psi(n-k+1,m)-\Psi(n-k,m)\right)\\
&=\frac{1}{q^{\ell-1}(q-1)}\Psi(n-k,m) - \frac{1}{q^{\ell}(q-1)}\Psi(n-k+1,m)\\
&= \frac{q^{n-\ell-k+1}}{q-1}\left(\rho\left(\frac{n-k}{m}\right) -\rho\left(\frac{n-k+1}{m}\right) \right)\left(1 +O\left(\frac{\log (u+1)}{m}\right)\right)
\end{align*}
by \eqref{eq:Psi}.
We have
\begin{align*}
\rho\left(\frac{n-k}{m}\right) -\rho\left(\frac{n-k+1}{m}\right) &=
%
-\frac{1}{m}\rho'\left(\frac{n-k+1}{m}\right) +
\frac{\rho^{(2)}(\xi) }{2!}\frac{1}{m^2}
\end{align*}
for some $\xi \in ((n-k)/m, (n-k+1)/m )$, thus
by Lemmas~\ref{lemma:rho} and \ref{lemma:rho'} we have
\begin{align*}
\rho\left(\frac{n-k}{m}\right) -\rho\left(\frac{n-k+1}{m}\right) &=
%
-\frac{1}{m}\rho'\left(\frac{n-k+1}{m}\right) + O\left(\frac{1}{m^2}\rho^{(2)}\left(\frac{n-k+1}{m}\right) \right)\\
&=
-\frac{1}{m}\rho'\left(\frac{n-k+1}{m}\right)
\left(
1 + O\left(
\frac{\log (u+1)}{m}
\right)
\right).
\end{align*}
Then the result follows from Lemma~\ref{lemma:major2}.
\end{proof}
\subsection{Minor arc estimates}
\label{sec:minor}
\begin{lemma}\label{lemma:minor_counting}
For $\alpha, \beta \in \mathbf{T}$, we have
$$
\#\left\{f\in\cM(n): \|\alpha f -\beta \|< q^{-k} \right\}\leq \max\left\{1, q^{n-k} , q^{n}\|\alpha\|, q^{-k}/\|\alpha\| \right\}.
$$
\end{lemma}
\begin{proof}
Write
$$
\alpha =\sum_{i\leq 0}\alpha_i t^i \mand \beta =\sum_{i\leq 0}\beta_i t^i
$$
%with $\alpha_r \neq 0$.
and let $\|\alpha\|=q^{-r}$.
If $\|\alpha f -\beta\|\leq q^{-k}$, then
\begin{equation}\label{eq:LES}
\sum_{ i=-j+r }^n f_i\alpha_{ -j-i} =\beta_{-j}, \quad \text{for } j=\max\{1,r-n+1\}, \dots, \min\{k,r \}
\end{equation}
As $\alpha_{-r}\neq 0$, the coefficient matrix has full rank, and thus \eqref{eq:LES} has
$$
q^{n-(\min\{k,r\}-\max\{0, r-n\})}
$$ solutions.
\end{proof}
\begin{lemma}\label{lemma:minor_arcs}
Let $\xi=a/g+\gamma$ with $\gcd(a,g)=1$, $\|\gamma\|<1/|g|^2$. Then
we have
$$
S(\xi;n,m)\ll
\left\{
\begin{array}{c}
m^2 n^{1/2}\left(\frac{q^{n}}{|g|^{1/2}}+q^{3n/4+m/4}+|g|^{1/2}q^{(n+1)/2} \right),
\\
m^2 n^{1/2}\left(
|g|^{1/2}q^{3n/4+m/4+1/2}+\|g\gamma\|^{1/2}q^n +\frac{q^{(n+1)/2}}{\|\gamma\|^{1/2}} \right).
\end{array}
\right.
$$
\end{lemma}
\begin{proof}
Let us fix an arbitrary ordering $\preccurlyeq$ of polynomials which is compatible the degree, that is, $g\preccurlyeq f$ whenever $\deg g < \deg f$. For a polynomial $f$ let $\Omega^+(f)$ and $\Omega^-(f)$ be the maximal resp. minimal irreducible divisor of $f$ with respect to the ordering $\preccurlyeq$. By collecting small degree divisors of $f$ into $u$, one can have a unique representation
$f = u\cdot v$ of polynomials $f\in\cS(n,m)$ with polynomials $u,v$ satisfying
$$
\Omega^+(u) \preccurlyeq \Omega^-(v), \quad
\frac{n-m}{2}\leq \deg(u)< \frac{n+m}{2}, \quad \text{and }
\deg u + \deg \Omega^-(v) \geq \frac{n+m}{2}.
$$
For an irreducible polynomial $\omega \in \cP$ write
$$
\cU(j, \omega)=\left\{ u\in \cS(j,m): \, \Omega^+(u)= \omega \right\}
$$
and
$$
\cV(j, \omega)=\left\{ v\in \cS(n-j,m) :\, \Omega^-(v)\geq \omega, \deg \Omega^-(v) \geq \frac{n+m}{2}-j\right\}.
$$
Then, we have
\begin{align*}
S\left(\xi;n,m\right)
&=
\sum_{\frac{n-m}{2}\leq j <\frac{n+m}{2}}
\sum_{r=1}^{m} \sum_{\omega\in \cP(r)} \sum_{u\in\cU(j, \omega) } \sum_{v\in \cV(j, \omega) } \e\left(uv \xi\right).
\end{align*}
Write
$$
S_{j,r} = \sum_{\omega\in \cP(r)} \sum_{u\in\cU(j, \omega) } \sum_{v\in \cV(j, \omega) } \e\left(uv \xi\right).
$$
By the Cauchy inequality, we have
\begin{align*}
|S_{j,r}|^2
&\ll \left(\sum_{\omega\in \cP(r)}\sum_{u\in \cU(j, \omega)}1\right) \sum_{\omega\in \cP(r)} \sum_{u\in \cU(j, \omega)} \left|\sum_{v\in\cV(j, \omega)} \e\left(uv \xi\right)\right|^2 \\
&\ll q^{j} \max_{\omega\in\cP(r)} \sum_{\substack{z \in \cM(j)}} \left|\sum_{v\in\cV(j, \omega)}\e \left( zv \xi\right)\right|^2 \\
& \ll q^{j}\max_{\omega\in\cP(r)}
\sum_{v_1,v_2\in\cV(j, \omega)}\left| \sum_{\substack{z \in \cM(j)}} \e(z(v_1-v_2)\xi)\right|\\
& \ll q^{j}
\sum_{v_1,v_2\in\cP(n-j)}\left| \sum_{\substack{z \in \cM(j)}} \e(z(v_1-v_2)\xi)\right|\\
& \ll q^{j}
\sum_{b\in \Fq^*}
\sum_{v\in\cP(n-j)}
\sum_{i=0}^{n-j-1}
\sum_{h \in \cM(i)}
\left| \sum_{\substack{z \in \cM(j)}} \e\left(bz h \xi\right)\right|
+q^{n+j}.
\end{align*}
To prove the first bound, we apply Lemma~\ref{lemma:minor-1} to get
\begin{align*}
|S_{j,r}|^2
&\ll q^j \sum_{b\in \Fq^*}
\sum_{v\in\cP(n-j)}
\sum_{i=0}^{n-j-1}
\left(\frac{q^{i+j}}{|g|}+q^{i}+|g|\right) + q^{n+j}\\
&\ll n \left(\frac{q^{2n}}{|g|}+q^{2n-j}+|g|q^{n+1} + q^{n+j}\right).
\end{align*}
Whence
$$
S(\xi;n,m)\ll m^2 n^{1/2}\left(\frac{q^{n}}{|g|^{1/2}}+q^{3n/4+m/4}+|g|^{1/2}q^{(n+1)/2} \right).
$$
To prove the second bound, we have by
Lemma~\ref{lemma:ort1},
\begin{equation}\label{eq:minor-1001}
\sum_{h \in \cM(i)} \left| \sum_{\substack{z \in \cM(j)}} \e\left(bz h \xi \right)\right|=
q^{j}\cdot \#\left\{h \in \cM(i): \| h \xi\|< q^{-j} \right\}.
\end{equation}
Write $h$ as $h=eg + f$, $|f|<|g|$. Then
$$
\left\|h \xi \right\| = \left\|e g\gamma + \frac{af}{g} +f\gamma \right\| .
$$
Putting $\beta= af/g +f\gamma $, then
by Lemma~\ref{lemma:minor_counting},
$$
\#\left\{|e|=\frac{q^i}{|g|} : \| e g \gamma +\beta\|< q^{-j} \right\} \ll \max\left\{1, \frac{q^{i-j}}{|g|}, \|g\gamma\|\frac{q^i}{|g|}, \frac{1}{\|g\gamma\|q^j}\right\}
$$
thus by \eqref{eq:minor-1001}
$$
\sum_{h \in \cM(i)} \left| \sum_{\substack{z \in \cM(j)}} \e\left(bz h \xi \right)\right|\ll |g|q^j + q^i+ \|g\gamma\|q^{i+j} +\frac{1}{\|\gamma\|}.
$$
Whence
\begin{align*}
|S_{j,r}|^2
&\ll q^j \sum_{b\in \Fq^*}
\sum_{v\in\cP(n-j)}
\sum_{i=0}^{n-j-1}
\left(|g|q^j + q^i+ \|g\gamma\|q^{i+j} + \frac{1}{\|\gamma\|}\right)+q^{n+j}\\
&\ll n\left(|g|q^{n+j+1}+ q^{2n-j}+ \|g\gamma\|q^{2n} +\frac{q^{n+1}}{\|\gamma\|}\right).
\end{align*}
It yields
$$
S(\xi;n,m)\ll m^2 n^{1/2}\left(
|g|^{1/2}q^{3n/4+m/4+1/2}+\|g\gamma\|^{1/2}q^n +\frac{q^{(n+1)/2}}{\|\gamma\|^{1/2}}
\right)
$$
\end{proof}
\section{Analysis of $S_\cJ$}
\label{sec:SJ}
We have the following results, for their proof see the proof of \cite[Section~2.1]{Ha:Irreducible_polynomials}.
\begin{lemma}\label{lemma:inf_norm}
We have
$$
\int_{\mathbf{T}}|S_{\cJ}(\xi) | \d \xi =1.
$$
\end{lemma}
\begin{lemma}\label{lemma:generating_function}
We have
$$
S_{\cJ}(\xi)=
\left\{
\begin{array}{ll}
q^{n- \#\cI} \e(\xi t^n) \prod_{i\in \cI}\e (a_it^i \xi) & \text{if } \xi_{-i-1} =0 \text{ for all } i\not \in \cI,\\
0 & \text{otherwise.}
\end{array}
\right.
$$
\end{lemma}
The following result is \cite[Lemma~2.7]{Ha:Irreducible_polynomials}
\begin{lemma}\label{lemma:char_fn_vanishes}
Let $a,g \in\F_q[t]$ be two polynomials with $\gcd(a,g)=1$ and write $g=g_0 t^k$, $\gcd(g_0,t)=1$. If $1<|g_0|\leq q^{\lceil n/(\#\cI+1)\rceil}-1$, then
$$
\cS_{\cJ}\left(\frac{a}{g}\right)=0.
$$
\end{lemma}
The following result is the analogue of Bourgain's result \cite[Lemma~3]{cite:Bourgain} proved by Ha \cite[Lemma~2.6]{Ha:Irreducible_polynomials}
\begin{lemma}\label{lemma:Bourgain}
Let $k\leq n/2$. Then we have
$$
\sum_{\substack{|g|<q^k\\\gcd(aT,g)=1}} \left|
S_\cJ\left(\frac{a}{g}\right)\right|\leq \frac{q^n}{q^{\#\cI}} q^{2kC_1 \#\cI/n}
,
$$
where $C_1=\kappa(n, 2k, \#\cI/n)\leq 2$ is given by
$$
\kappa(x,y,\delta) =
\left\{
\begin{array}{cl}
\frac{2}{\delta +1} & \text{if } 1<x/y<2\\
\frac{2v}{(v+1)\delta +v-1} & \text{if } v-1<x/y<v\\
1 & \text{if } y\mid x.
\end{array}
\right.
$$
\end{lemma}
\section{
Proof of Theorem~\ref{thm:2}}
First we investigate the integral \eqref{eq:int} over the major arcs defined by \eqref{eq:major}. We also choose
\begin{equation}\label{eq:kappa-ell}
\kappa = \left\lceil\frac{n-m-2}{4} \right\rceil\mand \ell = \left\lceil \frac{n-m}{4}\right\rceil .
\end{equation}
As the polynomials $f$ in the summations $S(\xi;n,m)$ and $S_\cJ(\xi)$ are monic and of degree~$n$, we have for $\xi\in \fM$ having the form $\xi=a/g+\gamma$, $|\gamma|<q^{-n+\ell}$ that $\e(f\gamma)=\e(b\gamma)$ if $f\equiv b \mod \cR_{\ell}$, $b\in \cM(n)$.
Then
\begin{align*}
&\int_{\fM}S(\xi;n,m)\overline{S_\cJ(\xi)}\d \xi\\
&=
\sum_{\substack{a,g\\ |g|\leq q^{\kappa}}} \int_{|\gamma|<q^{-n+\ell}}S\left(\frac{a}{g}+\gamma;n,m\right)\overline{S_\cJ\left(\frac{a}{g}+\gamma\right)}\d \gamma
\\
&=\sum_{\substack{a,g\\ |g|\leq q^{\kappa}}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\left(\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{g}\right)
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g}\right)
\right)
\int_{|\gamma|<q^{-n+\ell}} \e\left(b\gamma\right)\overline{ \e\left(b\gamma\right)}\d \gamma\\
&=\frac{1}{q^{n-\ell}}\sum_{\substack{a,g\\ |g|\leq q^{\kappa}}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\left(\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{g}\right)
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g}\right)
\right).
\end{align*}
We split the sum above into two parts
\begin{equation}\label{eq:major_int}
\int_{\fM}S(\xi;n,m)\overline{S_\cJ(\xi)}\d \xi = M_1+M_2
\end{equation}
with
$$
M_1= \frac{1}{q^{n-\ell}} \sum_{0\leq k \leq \kappa} \sum_{\substack{|a|<t^k \\ t\nmid a}} \sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\left(\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{t^k}\right)
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{t^k}\right)
\right)
$$
and
$$
M_2=\frac{1}{q^{n-\ell}}\sum_{\substack{a,g\\ g\neq t^k}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\left(\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{g}\right)
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g}\right)
\right).
$$
Concerning $M_1$, for $k=0$ we have by Lemma~\ref{lemma:smooth_in_interval},
\begin{equation}\label{eq:M10}
\begin{split}
& \frac{1}{q^{n-\ell}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\left(\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} 1
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
1
\right) \\
=&
\frac{1}{q^{n-\ell}} \left(\frac{1}{q^\ell}\Psi(n,m)+ O\left(
q^{\left(\frac{1}{2}+\varepsilon\right)n}e^{ \varepsilon \ell}
\right)
\right) \sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
1\\
=&
\frac{\Psi(n,m)}{q^{\#\cI}} +
O\left(
q^{\left(\frac{1}{2}+\varepsilon\right)n - \#\cI+\ell}e^{ \varepsilon \ell }
\right).
\end{split}
\end{equation}
Now consider the terms with $g=t^k$, $k\geq 1$. Let $B=\cI\cap \{n-\ell,\dots, n-1\}$. Clearly, one can represent the residue classes of $\cR_\ell$ by the elements of $\cM(\ell)$. The contribution of those $b$ that $b_{i-(n-\ell)}\neq \alpha_{i}$ for $i\in B$ is zero. Write
$$
\cB=\left\{b\in\cM(\ell): b_{j-(n-\ell)}= \alpha_{j} \text{ for } j\in B\right\} \mand I_\ell=I\cup \{n-\ell,\dots, n-1\}
$$
and for $b\in\cB$ write
$$
\cJ_b =\left\{f\in\cM(n): f\in \cJ \text{ and } f\equiv b \mod \cR_\ell \right\}
$$
and
$$
\beta_i =
\left\{
\begin{array}{cl}
\alpha_i & \text{if $i\in \cI$} , \\
b_{i-(n-\ell)} & \text{if $i \in \{n-\ell,\dots, n-1\}\setminus I$ } .
\end{array}
\right.
$$
Then
$$
\#\cJ_b = q^{n-\#\cI_\ell}=q^{n-\#\cI-\ell +\#B}
$$
and
$$
S_{\cJ_b}(\xi) =\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(f\xi\right).
$$
For $1\leq k\leq \kappa$ we recall that by Lemmas~\ref{lemma:rho}, \ref{lemma:rho'} and \ref{lemma:major}, we have
\begin{align*}
\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{t^k}\right)=
%
-\frac{1}{m}\frac{q^{n-\ell-k+1}}{q-1}\rho'\left(\frac{n-k+1}{m}\right)
+E(n,m,k)
\end{align*}
with error term
$$
E(n,m,k) \ll
q^{n-\ell-k} \rho\left(u\right) \frac{u^{1/2}(\log (u+1))^{5/2}}{m^2}
+
q^{\left(\frac{1}{2}+\varepsilon\right)n+ \frac{k}{2}}e^{\varepsilon k}.
$$
By Lemma~\ref{lemma:generating_function}, $S_{\cJ_b}(a/t^k)=0$ if $a_{i}\neq 0$ for some $k-i-1\not\in \cI_\ell$, $0\leq i <k$. As $\gcd(a,t)=1$, we have $a_0\neq 0$ and thus it is enough to consider $k$ with
$k-1 \in \cI_\ell$. For such a $k$, we have by Lemma~\ref{lemma:generating_function} that
\begin{equation}\label{eq:M_1_fix_k}
\begin{split}
&\frac{1}{q^{n-\ell}}\sum_{b\in \cB}\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{t^k}\right) S_{\cJ_b}(a/t^k)\\
=& \frac{1}{q^{\#\cI_\ell-\ell}}\sum_{b\in \cB} \sum_{ \substack{a_{i}\in \Fq \\ k-i-1\in \cI_\ell\\
0\leq i < k\\ a_0\neq 0}}
\sum_{\substack{f\in S(n,m)\\ f \equiv b \bmod \cR_\ell}}
%S
\e\left(\sum_{\substack{0\leq i<k\\ k-i-1\in \cI_\ell}} \frac{a_{i} t^{i}f}{t^k}\right)
\prod _{ j\in \cI_\ell}\e\left(\beta_j t^j \left(\sum_{\substack{0\leq i<k \\ k-i-1\in \cI_\ell}} a_{i} t^{i-k} \right) \right)\\
=&\frac{1}{q^{\#\cI_\ell-\ell}}
\left(
-\frac{1}{m}\frac{q^{n-\ell-k+1}}{q-1}\rho'\left(\frac{n-k+1}{m}\right)
+E(n,m,k)
\right) \cdot S_I(n,k,\ell)
\end{split}
\end{equation}
with
$$
S_I(n,k,\ell)=\sum_{b\in \cB}
\sum_{ \substack{a_{i}\in \Fq \\ k-i-1\in \cI_\ell\\
0\leq i < k\\ a_0\neq 0}}\prod _{ j\in \cI_\ell}\e\left(\beta _j t^j \left(\sum_{\substack{0\leq i<k \\ k-i-1\in \cI_\ell}} a_{i} t^{i-k} \right) \right).
$$
%Now consider the second term.
Considering $S_I(n,k,\ell)$, as $k-i-1\leq k\leq \kappa <n-\ell$, for the summation over $a_i$ it is enough to consider $i$ with $k-i-1\in \cI$. Moreover, for $j\geq n-\ell$ and $0\leq i<k$, we have $j +i-k\geq n-\ell-k>0$, and thus
$$
\e\left(\beta_j t^j \left(\sum_{\substack{0\leq i<k \\ k-i-1\in \cI_\ell}} a_{i} t^{i-k} \right)\right)=1,
$$
i.e., the terms in $S_I(n,k,\ell)$ do not depend on the choice of $b\in\cB$. Therefore
\begin{align*}
S_I(n,k,\ell)
&=
q^{\ell-\#B}
\sum_{ \substack{a_{i}\in \Fq \\ k-i-1\in \cI\\
0\leq i < k\\ a_0\neq 0}}\prod _{ j\in \cI}\e\left(\alpha _j t^j \left(\sum_{\substack{0\leq i<k \\ k-i-1\in \cI}} a_{i} t^{i-k} \right) \right)
\\
&=q^{\ell-\#B}\prod_{ \substack{j\in \cI\\
0\leq j < k-1}}
\left(\sum_{a_{k-j-1}\in \Fq}
\e\left( \alpha_{j}a_{k-j-1} t^{-1} \right) \right)\left(\sum_{a_{0}\in \Fq^*}
\e\left( \alpha_{k-1}a_{0} t^{-1} \right) \right)
\\
&=\sigma_k q^{\ell-\#B+\#\cI\cap\{0,\dots, k-2\}}\mathbf{1}(\alpha_j = 0, j\in \cI\cap\{0,\dots, k-2\} ),
\end{align*}
where
$$
\sigma_k =
\left\{
\begin{array}{cl}
-1 & \alpha_{k-1}\neq 0 , \\
q-1 & \text{otherwise} .
\end{array}
\right.
$$
Write $I= \{i_0<i_1<\dots< i_\nu<\dots \}$ with $a_{i_0}=a_{i_1}=\dots =a_{i_{\nu-1}}=0\neq a_{i_\nu}$.
Then taking summation over $0\leq k\leq \kappa$ we get by \eqref{eq:M10} and \eqref{eq:M_1_fix_k}, that
\begin{equation}\label{eq:M1}
\begin{split}
M_1 =& \frac{\Psi(n,m)}{q^{\#\cI}} +
O\left(
q^{\left(\frac{1}{2}+\varepsilon\right)n - \#\cI+\ell}e^{ \varepsilon \ell }
\right)
\\
&+ (q-1) \sum_{\substack{0\leq j<\nu \\ i_j<\kappa}} \frac{1}{q^{\#\cI-j-\ell}}
\left(
-\frac{1}{m}\frac{q^{n-i_j-\ell}}{q-1}\rho'\left(\frac{n-i_j}{m}\right)
+E(n,m,i_j+1)
\right)
\\
&-\mathbf{1}(\nu<\kappa)
\frac{1}{q^{\#\cI-\nu-\ell}} \left(
-\frac{1}{m}\frac{q^{n-i_\nu-\ell}}{q-1}\rho'\left(\frac{n-i_\nu-\ell}{m}\right)
+E(n,m,i_\nu+1)
\right)\\
=& \frac{1}{q^{\#\cI}}\Psi(n,m) +
\frac{q^n}{q^{\#\cI}}\left(\Lambda_0(n,m,I,u)+\Lambda_1(n,m,I,u)\right)
\\
&
+O\left(
% %
\nu q^{n-\#\cI-i_0-1} \rho\left(u\right) \frac{u^{1/2}(\log (u+1))^{5/2}}{m^2}
+
% %
q^{\left(\frac{1}{2}+\varepsilon\right)n - \#\cI+\frac{\kappa}{2}+\ell}e^{ \varepsilon (n-m)/2}
\right)
\\
=& \frac{1}{q^{\#\cI}}\Psi(n,m)
+
\frac{q^n}{q^{\#\cI}}\left(\Lambda_0(n,m,I,u)+\Lambda_1(n,m,I,u)\right)
\\
&+O\left(
q^{n-\#\cI-i_0-1}
\rho\left(u\right) \frac{u^{1/2}(\log (u+1))^{5/2}}{m}
+
%
q^{
\left(\frac{7}{8}+\varepsilon\right)n-\frac{3m}{8}+\frac{5}{4}- \#\cI}e^{ \varepsilon (n-m)/2}
\right)
\end{split}
\end{equation}
by \eqref{eq:kappa-ell}.
For $M_2$, write $K=\lceil n/(\#\cI +1)\rceil$. If $g$ has the form $g=g_0t^k$ with $t\nmid g_0$ and $1<|g_0|<q^{K}$, then $S_{\cJ}(a/g)$ vanishes by Lemma~\ref{lemma:char_fn_vanishes}. Then, we can write
$$
M_2= \frac{1}{q^{n-\ell}} \sum_{ r=K}^\kappa \sum_{k=0}^{\kappa-r} M_2(r,k)
$$
with
$$
M_2(r,k)= \sum_{\substack{\substack{g_0\in \cM(r)\\t\nmid g_0}}}\sum_{\substack{|a|<|g_0t^k|\\ \gcd(a,g_0t)=1}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\left(\sum_{\substack{f\in\cS(n,m)\\ f \equiv b \bmod \cR_\ell}} \e\left(\frac{af}{g_0t^k}\right)
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g_0t^k}\right)
\right).
$$
By Lemma~\ref{lemma:major2},
\begin{equation*}%\label{eq:M2_start}
\begin{split}
M_2(r,k)
&= \sum_{\substack{\substack{g_0\in \cM(r)\\t\nmid g_0}}}\sum_{\substack{|a|<|g_0t^k|\\ \gcd(a,g_0t)=1}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}} \left(\sum_{d \mid g_0t^k} \frac{\mu(g_0t^k/d)}{q^\ell\Phi(g_0t^k/d)} \Psi_{g_0t^k/d}(n-\deg d,m)
+R(r,k) \right)\\
& \qquad \cdot
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g_0t^k}\right)
\end{split}
\end{equation*}
with error term
\begin{equation}\label{eq:M2_error}
R(r,k)\ll
q^{\left(\frac{1}{2}+\varepsilon\right)n +\frac{r+k}{2}}e^{\varepsilon (\ell+\kappa) }. %\leq q^{\left(\frac{5}{8}+\varepsilon\right)n -\frac{m}{8} +\frac{1}{2}}e^{\varepsilon (n-m)/2 }
\end{equation}
%by \eqref{eq:kappa-ell}.
By \eqref{eq:phi} and Lemmas~\ref{lemma:rho} and \ref{lemma:number_of_divisors}, we have
\begin{align*}
&\sum_{d \mid g_0t^k} \frac{\mu(g_0t^k/d)}{q^\ell\Phi(g_0t^k/d)} \Psi_{g_0t^k/d}(n-\deg d,m)\\
\leq &\sum_{d \mid g_0t^k} \frac{1}{q^\ell\Phi(g_0t^k/d)} \Psi(n-\deg d,m)\\
\ll &\sum_{d \mid g_0t^k} \frac{q^{n-\deg d}}{q^{\ell}\Phi(g_0t^k/d)} \rho\left(\frac{n-\deg d}{m}\right) \\
\ll& q^{n-\ell} \rho\left(u\right) \sum_{d \mid g_0t^k} \frac{(u \log u )^{\deg d/m}}{|d|\Phi(g_0t^k/d)}
\\
\ll & q^{n-\ell-r-k} \rho\left(u\right)
\left(u\log u\right)^{1/8}(r+k)\left(1+\log_q (r+k) \right)
.
\end{align*}
Whence
\begin{equation}\label{eq:M2-partial}
\begin{split}
M_2(r,k)
&=
\left(
q^{n-\ell-r-k}\rho\left(u\right)
\left(u\log u\right)^{1/8}\kappa \left(1+\log_q \kappa \right)
+R(r,k)
\right)\\
&\qquad \cdot \sum_{\substack{\substack{g_0\in \cM(r)\\t\nmid g_0}}}\sum_{\substack{|a|<|g_0t^k|\\ \gcd(a,g_0t)=1}}\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g_0t^k}\right).
\end{split}
\end{equation}
In order to handle the second term, write
$$
\frac{af}{g_0t^k}=\frac{a_1f}{g_0}+\frac{a_2f}{t^k} \quad \text{with} \quad \gcd(a_1,g_0)=\gcd(a_2,t)=1.
$$
Then we have by Lemmas~\ref{lemma:Ram} and \ref{lemma:Bourgain} that
\begin{align*}
&
\sum_{\substack{g_0\in\cM(r)\\ t\nmid g_0}}
\sum_{\substack{b\bmod \cR_\ell\\ b\in\cM(n)}}\sum_{\substack{|a|<|g_0t^k|\\ \gcd(a,g_0t)=1}}
\sum_{\substack{f\in\cJ\\ f \equiv b \bmod \cR_\ell}}
\e\left(-\frac{af}{g_0t^k}\right)\\
=& \sum_{\substack{g_0\in\cM(r)\\ t\nmid g_0}}
\sum_{\substack{|a|<|g_0t^k|\\ \gcd(a,g_0t)=1}}
\sum_{\substack{f\in\cJ}}
\e\left(-\frac{af}{g_0t^k}\right)\\
=& \sum_{\substack{ g_0\in\cM(r)\\ \gcd(g_0,t)=1}} \sum_{\substack{|a_1|<|g_0|\\ \gcd(a_1,g_0)=1 }} \sum_{\substack{|a_2|<|t^k|\\ \gcd(a_t,t)=1}}
\sum_{\substack{f\in\cJ}} \e\left(-\frac{a_1f}{g_0}-\frac{a_2f}{t^k}\right)\\
=& \sum_{\substack{|c|<|t^k|\\ \gcd(c,t)=1}} \sum_{\substack{|a_2|<|t^k|\\ \gcd(a_t,t)=1}} \e\left(-\frac{a_2c}{t^k}\right)\sum_{\substack{g_0\in\cM(r)\\ \gcd(g_0,t)=1}}\sum_{\substack{|a_1|<|g_0|\\ \gcd(a_1,g_0)=1 }} \sum_{\substack{f\in\cJ\\ f \equiv c \bmod t^k}} \e\left(-\frac{a_1f}{g_0}\right)\\
=&
\sum_{\substack{|c|<|t^k|\\ \gcd(c,t)=1}}
\mu(t^k)
\sum_{\substack{g_0\in\cM(r)\\ \gcd(g_0,t)=1}}\sum_{\substack{|a_1|<|g_0|\\ \gcd(a_1,g_0)=1 }} \sum_{\substack{f\in\cJ\\ f \equiv c \bmod t^k}} \e\left(-\frac{a_1f}{g_0}\right)\\
\ll & |\mu(t^k)| \frac{q^{n}}{q^{\#\cI}}q^{2rC_1(\#\cI+k)/n}
% \frac{q^{n}}{q^{\#\cI}}q^{2rC_1\#\cI/n}+ q\frac{q^{n}}{q^{\#\cI+1}}q^{2rC_1(\#\cI+1)/n}\ll \frac{q^{n}}{q^{\#\cI}}q^{4rC_1\#\cI/n}
.
\end{align*}
where $C_1$ as in Lemma~\ref{lemma:Bourgain}. Thus by \eqref{eq:M2-partial}
\begin{equation}\label{eq:M2-partial2}
\begin{split}
M_2(r,k)
&\ll
\left(
q^{n-\ell-r-k}\rho\left(u\right)
\left(u\log u\right)^{1/8}(r+k) \left(1+\log_q (r+k)\right)
+R(r,k)
\right)\\
& \quad \cdot |\mu(t^k)| \frac{q^{n}}{q^{\#\cI}}q^{2rC_1(\#\cI+k)/n}.
\end{split}
\end{equation}
Write
$$
C_2=1-4C_1 \frac{\#\cI+1}{n}.
$$
As $\#\cI< n/10 $, we have then $C_2\geq 1/5$ and $2C_1(\#I+1)/n\leq 1/2$. As $M_2(r,k)=0$ for $k\geq 2$, we have by \eqref{eq:M2_error} and \eqref{eq:M2-partial2} that
\begin{equation}\label{eq:M2final}
\begin{split}
M_2 &
\ll \frac{q^{n}}{q^{\#\cI}} \left(\rho\left(u\right)
\left(u\log u\right)^{1/8} \sum_{ r\geq K } \frac{r \left(1+\log_q r \right)}{q^{C_2r}} + O\left(
q^{-\frac{(1-4\varepsilon)n+m}{4}+2}e^{\varepsilon(n-m)/4}
\right) \right)\\
&\ll \frac{q^{n}}{q^{\#\cI}} \left(\rho\left(u\right)
\left(u\log u\right)^{1/8} \frac{K \left(1+\log_q K \right)}{q^{C_2K}} + O\left(
q^{-\frac{(1-4\varepsilon)n+m}{4}+2}
e^{\varepsilon(n-m)/4}
\right) \right)
\\
&\ll \frac{q^{n}}{q^{\#\cI}}\left( \rho\left(u\right)
\left(u\log u\right)^{1/8} \frac{K \left(1+\log_q K \right)}{q^{C_2K}} + O\left(
q^{-\frac{(1-4\varepsilon)n+m}{4}+2}e^{\varepsilon(n-m)/4}
\right) \right).
\end{split}
\end{equation}
%assuming \eqref{eq:condition2}.
Then, combining \eqref{eq:major_int}, \eqref{eq:M1} and \eqref{eq:M2final}, we get that the contribution of the major arcs is
\begin{equation}\label{eq:major-final}
\begin{split}
\int_{\fM}S(\xi;n,m)\overline{S_\cJ(\xi)}\d \xi &=
\frac{\Psi(n,m)}{q^{\# I}}
\left(1 + O\left( \left(u\log u\right)^{1/8}\frac{\delta^{-1} \log \delta}{q^{C /\delta}}+
\frac{1}{ q^{i_0+1}} \frac{u^{1/2}(\log u)^{5/2}}{m} \right)\right) \\
&\quad
+\frac{q^{n}}{q^{\#\cI}}\left(\Lambda_0(n,m,I,u) +\Lambda_1(n,m,I,u)
+
O\left( q^{
-\frac{(1-8\varepsilon)n+2m}{8}
+2}e^{\varepsilon\frac{n-m}{2}}
\right)
\right)
.
\end{split}
\end{equation}
%Using $m\leq n$, we get that the error term satisfies
%\begin{equation}\label{eq:error-final}
% q^{
%-\frac{(1-8\varepsilon)n+m}{8}
%+2}e^{\varepsilon\frac{n-m}{2}}
%\ll q^{
%-\frac{(1-16\varepsilon)n+m}{4}
%+2}.
%\end{equation}
Next, we consider the integral along the minor arcs $\fm$
\begin{equation*} \int_{\fm}S(\xi;n,m)\overline{S_\cJ(\xi)}\d \xi.
\end{equation*}
By Lemma~\ref{lemma:dio}, write $\xi\in\mathbf{T}$ as
$$
\xi=\frac{a}{g}+\gamma, \quad \gcd(a,g)=1, |g|<q^{n/2}, |\gamma|\leq \frac{1}{|g|q^{n/2}}.
$$
If $\xi\in \fm$, then either $q^{\kappa}\leq|g|<q^{n/2}$ or $|g|<q^{\kappa}$ and $q^{-n+\ell}\leq |\gamma|\leq 1/(|g|q^{n/2})$. In the formal case, we estimate $S(\xi;n,m)$ by the first bound of Lemma~\ref{lemma:minor_arcs}
\begin{align*}
S(\xi,m,n)&\ll
m^2 n^{1/2}\left(\frac{q^{n}}{|g|^{1/2}}+q^{3n/4+m/4}+|g|^{1/2}q^{(n+1)/2} \right)\\
&\ll
m^2 n^{1/2}\left(q^{n-\kappa/2}+q^{3n/4+m/4} \right).
\end{align*}
In the second case, we use the second bound of Lemma~\ref{lemma:minor_arcs}
\begin{align*}
S(\xi,m,n)&\ll m^2 n^{1/2}\left(
|g|^{1/2}q^{3n/4+m/4+1/2}+\|g\gamma\|^{1/2}q^n +\frac{q^{(n+1)/2}}{\|\gamma\|^{1/2}} \right)\\
&\ll
m^2 n^{1/2}\left(
q^{3n/4+m/4+\kappa/2+1/2} +q^{n-(\ell-1)/2} \right).
\end{align*}
By \eqref{eq:kappa-ell}, we get in both cases
$$
S(\xi,m,n)\ll
m^2 n^{1/2} q^{(7n+m+4)/8} .
$$
Thus by Lemma~\ref{lemma:inf_norm}, we have
\begin{equation}\label{eq:minor-final}
\begin{split}
\int_{\fm}S(\xi;n,m)\overline{S_\cJ(\xi)}\d \xi&
\ll m^2 n^{1/2} q^{(7n+m+4)/8}
\int_{\fm}|S_\cJ(\xi)|\d \xi\\
&\ll m^2 n^{1/2}q^{(7n+m+4)/8}\int_{\mathbf{T}}|S_\cJ(\xi)|\d \xi\\
&\ll m^2 n^{1/2}q^{(7n+m+4)/8}.
\end{split}
\end{equation}
By replacing $\varepsilon$ if needed in \eqref{eq:major-final}, %and \eqref{eq:error-final},
Theorem~\ref{thm:2} follows from \eqref{eq:major-final}%,%\eqref{eq:error-final}
and \eqref{eq:minor-final}.
\section{Proof of Theorem~\ref{thm:1}}
Theorem~\ref{thm:1} follows directly form Theorem~\ref{thm:2}. Indeed, if $0\in \cI$ and $\alpha_0\neq 0$, then $\Lambda_0(n,m,I,u) =0$ and
$$
\Lambda_1(n,m,I,u)=-\frac{1}{m}\frac{1}{q-1}\rho'\left(u\right) \sim \frac{1}{m}\frac{1}{q}\rho\left(u\right)\log u
$$
by Lemmas \ref{lemma:rho} and \ref{lemma:rho'}, which is absorbed by the error term.
\section{Proof of Corollaries \ref{cor:1} and \ref{cor:2}}
Corollary \ref{cor:1} follows directly from Theorem~\ref{thm:1}.
For Corollary \ref{cor:2}, if $q\rightarrow \infty$, then
$$
|\Lambda_0(n,m,I,u)|, |\Lambda_1(n,m,I,u)| \leq c(n,m)\frac{1}{q}
$$
for some constant $c(n,m)$ depends only on $n$ and $m$ (and thus on $u$).
If $n\rightarrow \infty$
%and $\delta < 1/u^{9/8+\varepsilon}$
, then by Lemmas \ref{lemma:rho} and \ref{lemma:rho'},
$$
|\rho'((n-i_j)/m)|\leq c \rho(u) u^{1/8} (\log u)^{9/8}
$$
for some absolute constant $c$, and as $\nu \leq \#\cI = n\delta$,
thus
$$
|\Lambda_0(n,m,I,u)|\leq c(q) \rho(u)\frac{u^{1/8} (\log u)^{9/8}}{m}n \delta = c(q)\rho(u)u^{9/8} (\log u)^{9/8} \delta =o(\rho(u)) .%\leq c_0(q)\frac{1}{u^{\varepsilon/2}},
$$
%where $c_0(q)$ is a constant which may depend on $c$ and $q$.
Similarly,
$$
|\Lambda_1(n,m,I,u)|\leq c_1(q)\frac{1}{m}\rho'\left(\frac{n-i_\nu}{m}\right)\leq c_2(q) \rho(u)\frac{u^{1/8}(\log u)^{9/8}}{m}=o(\rho(u)).
$$
%for some constants $c_1(q), c_2(q)$ which may depend on $q$.
\section*{Acknowledgment}
The author wishes to thank Ofir Gorodetsky and Eugenijus Manstavi\u{c}ius for useful discussions and valuable comments. He also thanks the anonymous referee to bring the attention to \cite{cite:Bhow_et_al} which allowed to improve Lemma~\ref{lemma:char_sum}.
The author was was partially supported by NRDI (National Research Development and Innovation Office, Hungary) grant FK 142960,
\begin{thebibliography}{99}
\bibitem{cite:Bhow_et_al} A.
Bhowmick, T. H. L\^{e}, Y.-R. Liu,
A note on character sums in finite fields. Finite Fields Appl. 46 (2017), 247-254.
\bibitem{cite:Bourgain} J. Bourgain, Prescribing the binary digits of primes, II, Isr. J. Math. 206 (1) (2015) 165--182.
\bibitem{deBruijn} de Bruijn, N. G.
The asymptotic behaviour of a function occurring in the theory of primes,
J. Indian Math. Soc. (N.S.) 15 (1951), 25–32.
\bibitem{Car} M. Car,
Théorèmes de densité dans $\Fq[X]$. Acta Arith. 48 (1987), no.2, 145--165.
\bibitem{Dr14} M. Drmota, Subsequences of automatic sequences and uniform distribution. Uniform distribution and quasi-Monte Carlo methods, 87–104, Radon Ser. Comput. Appl. Math., 15, De Gruyter, Berlin, 2014.
\bibitem{DrMaRi19} M. Drmota, C. Mauduit, and J. Rivat. Normality along squares. J. Eur. Math. Soc. (JEMS) 21 (2019), no. 2, 507–548.
\bibitem{FoTe91} É. Fouvry,G. Tenenbaum, Entiers sans grand facteur premier en progressions arithmetiques. Proc. London Math. Soc. (3) 63 (1991), no. 3, 449–494.
\bibitem{GarPa} T. Garefalakis, D. Panario, Polynomials over finite fields free from large and small degree irreducible factors. Analysis of algorithms. J. Algorithms 44 (2002), no. 1, 98–120.
\bibitem{cite:Gorodetsky:irred}
O. Gorodetsky,
Irreducible polynomials over $\F_{2^r}$ with three prescribed coefficients. Finite Fields Appl.56 (2019), 150–187.
\bibitem{cite:Gorod2022} O. Gorodetsky, Mean values of arithmetic functions in short intervals and in arithmetic progressions in the large-degree limit, Mathematika 66 (2020), no. 2, 373–394.
\bibitem{Gor22+} O. Gorodetsky, Friable permutations and polynomial revisited, preprint, arXiv:2211.11023
\bibitem{Ha:Irreducible_polynomials} J. Ha, Irreducible polynomials with several prescribed coefficients. Finite Fields Appl. 40 (2016), 10--25.
\bibitem{cite:Ham} K. H. Ham, G. L. Mullen,
Distribution of irreducible polynomials of small degrees over finite fields. Math. Comp. 67 (1998), no. 221, 337–341
\bibitem{HaukSparlinski} M. Hauk,
I. E. Sparlinski, Smooth numbers with few nonzero
binary digits. Canad. Math. Bull. 67(2024), no.1, 74–89.
\bibitem{Hayes:Distribution} D.R. Hayes, The distribution of irreducibles in $GF[q,x]$. Trans. Amer. Math. Soc. 117 (1965), 101–127
\bibitem{Hayes:Goldbach} D. R. Hayes, The expression of a polynomial as a sum of three irreducibles. Acta Arith. 11 (1966), 461–488.
\bibitem{Hsu:Distribution} C.-N. Hsu,
The distribution of irreducible polynomials in $\Fq[t]$.
J. Number Theory 61 (1996), no. 1, 85--96.
\bibitem{KuttnerWang} S. Kuttner, Q. Wang, On the enumeration of polynomials with prescribed factorization pattern. Finite Fields Appl. 81 (2022) Paper No. 102030
\bibitem{Man} E. Manstavi\u{c}ius, Remarks on elements of semigroups that are free of large prime factors. (Russian) Liet. Mat. Rink. 32 (1992), no. 4, 512–525; translation in Lithuanian Math. J. 32 (1992), no. 4, 400–409 (1993)
\bibitem{MaRi10} C. Mauduit, J. Rivat, Sur un probléme de Gelfond: la somme des chiffres des nombrespremiers. Ann. of Math. (2) 171 (2010), no. 3, 1591–1646.
\bibitem{May19} J. Maynard,
Primes with restricted digits.
Invent. Math. 217 (2019), no. 1, 127–218.
\bibitem{cite:Merai_Divisors_of_sum} L. Mérai, On divisors of sums of polynomials.
Finite Fields Appl. 83 (2022), Paper No. 102090,
\bibitem{PaGoFl98} D. Panario, X. Gourdon, P. Flajolet,
An analytic approach to smooth polynomials over finite fields. Algorithmic number theory (Portland, OR, 1998), 226–236,
Lecture Notes in Comput. Sci., 1423, Springer, Berlin, 1998.
\bibitem{pollack13} P. Pollack, Irreducible polynomials with several prescribed coefficients, Finite Fields Appl. 22 (2013)
70–78
\bibitem{Swa20} C. Swaenepoel. Prime numbers with a positive proportion of preassigned digits.
Proc. Lond. Math. Soc. (3) 121 (2020), no. 1, 83–151.
\bibitem{cite:Tenenbaum} G. Tenenbaum, Introduction to analytic and probabilistic number theory. Third edition. Translated from the 2008 French edition by Patrick D. F. Ion. Graduate Studies in Mathematics, 163.
\bibitem{cite:Wan} D. Wan,
Generators and irreducible polynomials over finite fields.
Math. Comp. 66 (1997), no. 219, 1195–1212.
\bibitem{weil} A. Weil,
Basic number theory.
Third edition. Die Grundlehren der mathematischen Wissenschaften, Band 144. Springer-Verlag, New York-Berlin, 1974
\end{thebibliography}
\end{document}