Let $f$ be an arithmetical function. Suppose that $f(n)>0$ if $n$ is in an integer set $A$ and that $f(n)<0$ for another integer set $B.$ Is there a result from number theory or an elementary result that allows us to determine the first sign changes of the sequence $(f(n))$ and to compute its number of sign changes in terms of element of the sets $A$ or $B$? Thanks in advance.

$\begingroup$ Arithmetical function must mean something stronger than just function on the integers, right? Does it mean multiplicative on relatively prime integers? $\endgroup$– LSpiceOct 15, 2020 at 21:33

1$\begingroup$ @LSpice yes in the example that I have it is like that. $\endgroup$– Khadija MbarkiOct 15, 2020 at 21:41
1 Answer
I must agree with Lspice that usually, one requires further “structure” for $f$—like multiplicativity—or for $A$ and $B$—like prime numbers/integers in certain residue classes to be able to adequately answer you question. This allows for the right numbertheoretic and analytical\algebraic tools to be exploited and brought to bear on the problem. Now, if your sets $A$ and $B$ are finite sets, then unless their maximum elements are beyond that which can be handled by modern computers, then the best way is to check by a computer program. The interesting case is then when the sets are infinite and are not susceptible to elementary combinatorial manipulations in abstracting an answer to your questions. In that case, knowing the “precise” answer to your questions may become infeasible and an “approximate” or asymptotic solution may be required; the following approach may be useful and explains why an underlying arithmetical structure for $f$ or the sets is so important; it is however, regrettably, not “elementary” as I am thinking you might want it to be, but the generic nature of your question demands that an elementary procedure is at best infeasible.
Since you said it is an “arithmetical” function, I presume the domain is the natural numbers and that it is of some numbertheoretic flavor; (note that any function on the real numbers restricts to a function on the natural numbers, but rarely does one consider these restrictions as arithmetical functions if they’re not apparently connected to the numbers in a nontrivial/interesting way.
Now, let $\sigma(0):=0$ and define the sign
$$\sigma\colon\mathbb{N}\to\{1,0,1\}\,,~\,~\,~\,~n\mapsto\left\lbrace\begin{array}{ll}\frac{f(n)}{f(n)}&\mbox{if $n\in A\cup B$}\\0&\mbox{if otherwise}\end{array}\right.$$
For the precise number of sign changes between the sets up to a bound $N\ge 1$, you want to obtain the following quantity
$$\sum_{1\le n\le N}\frac{1}{2}\sigma(n)\sigma(n1)\,.$$
But obtaining this sum may be impractical in most cases, as it deals directly with knowing the sign changes a priori, so one may want to obtain a weighted quantity
$$\eta(N):=\sum_{n\le N}\chi(n)\,,~\,~\,~\,~\chi(n):=\omega(n)\sigma(n)\,,$$
where $\omega $ is a relevant suitable positive weight function depending on $f$ and the sets. For instance, suppose $\omega(n)=1$ for all $n$, then what does $\eta$ tell us? First if $\eta(N)=0$, then we know that there exactly the same number of elements—and, by at most an extra count, the same number of sign changes—between $A$ and $B$ up to $N$. Second if $\eta$ changes sign often, then there are intermittent sign changes between $A$ and $B$; monotonicity in a certain range then indicates no sign changes, and a break in monotonicity indicates a change in sign.
It follows from the above that knowing $\eta$ will be helpful in answering your questions; however, more often than not, it may be difficult to evaluate it directly, and this is where we need some structure as intimated in my opening paragraph above. If, on the one hand, $f$ is determined by the additive structure of the natural numbers, then a natural analytic object to consider is the power/Fourier series $$E(z,\chi):=\sum_{n\ge 1}\chi(n)z^{n1}\,.$$ Presumably, the “additive” structure will make $E$ a much “nicer” and “malleable” function; we can formally obtain $\eta$ from $E$ via the identity $$\eta(N)=\frac{1}{2\pi i}\oint_CE(z,\chi)\frac{z^{N}1}{z^{1}1}\frac{dz}{z}\,~\,~\,~\,~\,~\,~ (Eq~1)\,,$$ where the contour integral is over some appropriate closed curve. If, on the other hand, $f$ is determined by the multiplicative structure of the natural numbers, then a natural analytic object to consider is the Dirichlet series $$L(s,\chi):=\sum_{n\ge 1}\chi(n)n^{s}\,.$$ Here too, presumably, the “multiplicative” structure will make $L$ into a nicer and malleable function, from which we can formally determine $\eta$ as follows: $$\eta(N)= \frac{1}{2\pi i}\oint_{ci\infty}^{c+i\infty}L(s,\chi)N^s\frac{ds}{s}\,~\,~\,~\,~\,~\,~ (Eq ~2)\,$$ where $c$ is some appropriate constant. Equations (1) and (2) most often could be evaluated using complex analytic methods up to a controlled error term, which allows one to have an asymptotic nature of how $\eta$ really behaves as $N$ increases without bound.
(Remarks): I have glossed over technical details just to explain the ideas involved; for instance Eq(2) may not give the exact equality when $N$ is an integer.

1$\begingroup$ Since your $\chi$ ignores what happens outside of $A \cup B$, how can it tell us anything about the number (as opposed to just the parity) of sign changes? $\endgroup$– LSpiceOct 16, 2020 at 2:20

2$\begingroup$ @Lspice: it cannot really tell us that; in any case, this answer is just to indicate a basic but useful approach to answering such questions—which is too broad to have a specific useful solution—in the absence of further properties on $f$, $A$ and $B$. Furthermore, my concluding remarks are, in a way, to cater for this—perhaps one may need to add weights, depending on the function and sets, or perhaps consider a different set other than $A\cup B$ in defining a more relevant character $\chi$.. $\endgroup$– Jack L.Oct 16, 2020 at 2:27

1$\begingroup$ Thanks. So, just to check that I'm understanding, the sentence "First if $\eta(N) = 0$, then we know that there exactly the same number of elements—and therefore same number of sign changes—between $A$ and $B$ up to $N$." is not literally correct, right? $\endgroup$– LSpiceOct 16, 2020 at 3:03

1$\begingroup$ I had actually meant that literally but now realize that the difference in sign changes could be off by an extra count of $\pm 1$ when $\eta(N)=0$; to make my answer more accurate and relevant to the OP’s question, I have provided the precise count of the sign changes, and altered my definition of $\chi$ —by an arbitrary weight function — as a suitable option to obtaining the precise count. $\endgroup$– Jack L.Oct 16, 2020 at 8:40

1$\begingroup$ @JackL. Thanks for your answer. Actually $f$ is a multiplicative function and I will check your answer which I suppose is suitable to my case. Many thanks. $\endgroup$ Oct 16, 2020 at 18:54