cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A368774 a(n) is the number of distinct real roots of the polynomial whose coefficients are the digits of the binary expansion of n.

Original entry on oeis.org

0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 2, 0, 1, 0, 2, 0, 2, 0, 2, 1, 1, 0, 2, 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 2, 0, 1, 0, 2, 0, 2, 0, 2, 2, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2, 0, 2, 1, 1
Offset: 1

Views

Author

Denis Ivanov, Jan 05 2024

Keywords

Comments

In the full-form binary representation of n = c_m*2^m + c_{m-1}*2^(m-1) + ... + c_0*2^0 we replace 2 with x and count the distinct real roots of the polynomial f_n(x) = c_m*x^m + c_{m-1}*x^(m-1) + ... + c_0.
Multiple roots count only once.
The first occurrences a(n) = 3, 4, 5, 6 are at n = 150, 1686, 854646 and 437545878, respectively.
a(n) >= 1 if n is even or has an even number of binary digits. - Robert Israel, Jan 08 2024

Examples

			n = 1 = 1*2^0 -> f_n(x) = 1*x^0 = 1 -> no roots, a(1) = 0.
n = 6 = 1*2^2 + 1*2^1 + 0*2^0 -> f_n(x) = x^2 + x = x*(x + 1) -> roots {0,-1}, a(6) = 2.
n = 150 = 1*2^7 + 0*2^6 + 0*2^5 + 1*2^4 + 0*2^3 + 1*2^2 + 1*2^1 + 0*2^0 -> f_n(x) = x^7 + x^4 + x^2 + x -> roots {-1, -0.755..., 0}, a(150) = 3.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,p,i,z;
      L:= convert(n,base,2);
      p:= add(L[i]*z^(i-1),i=1..nops(L));
      sturm(sturmseq(p,z),z,-infinity,infinity);
    end proc:
    map(f, [$1..100]); # Robert Israel, Jan 08 2024
  • Mathematica
    a[n_]:=Length@{ToRules@Reduce[FromDigits[IntegerDigits[n, 2], x] == 0, x, Reals]};
  • PARI
    a(n) = #Set(polrootsreal(Pol(binary(n)))); \\ Michel Marcus, Jan 05 2024
    
  • Python
    from sympy.abc import x
    from sympy import sturm, oo, sign, nan, LT
    def A368774(n):
        if n == 1: return 0
        l = len(s:=bin(n)[2:])
        q = sturm(sum(int(s[i])*x**(l-i-1) for i in range(l)))
        a = [1 if (k:=LT(p).subs(x,-oo))==nan else sign(k) for p in q[:-1]]+[sign(q[-1])]
        b = [1 if (k:=LT(p).subs(x,oo))==nan else sign(k) for p in q[:-1]]+[sign(q[-1])]
        return sum(1 for i in range(len(a)-1) if a[i]!=a[i+1])-sum(1 for i in range(len(b)-1) if b[i]!=b[i+1]) # Chai Wah Wu, Feb 15 2024
    
  • Sage
    def a(n):
        R. = PolynomialRing(ZZ); poly = R(list(bin(n)[:1:-1]))
        return poly.number_of_real_roots()  # Robin Visser, Aug 03 2024

A368824 a(n) is the smallest degree of (0,1)-polynomial with exactly n real distinct roots.

Original entry on oeis.org

1, 2, 7, 10, 19, 28
Offset: 1

Views

Author

Denis Ivanov, Jan 07 2024

Keywords

Comments

(0,1) (or Newman) polynomials have coefficients from {0,1}.

Crossrefs

Programs

  • Mathematica
    (* Suitable only for 1 <= n <= 4;
    for larger n, special Julia and Python packages are needed *)
    Table[Exponent[Monitor[Catch[Do[
       poly = FromDigits[IntegerDigits[k, 2], x];
       res = Length@{ToRules@Reduce[poly == 0, x, Reals]};
       If[res == n, Throw@{res, Expand@poly}]
       , {k, 2000}]], k][[2]], x], {n, 1, 4}]
  • Python
    from itertools import count
    from sympy.abc import x
    from sympy import sturm, oo, sign, nan, LT
    def A368824(n):
        for m in count(2):
            l = len(s:=bin(m)[2:])
            q = sturm(sum(int(s[i])*x**(l-i-1) for i in range(l)))
            a = [1 if (k:=LT(p).subs(x,-oo))==nan else sign(k) for p in q[:-1]]+[sign(q[-1])]
            b = [1 if (k:=LT(p).subs(x,oo))==nan else sign(k) for p in q[:-1]]+[sign(q[-1])]
            if n==sum(1 for i in range(len(a)-1) if a[i]!=a[i+1])-sum(1 for i in range(len(b)-1) if b[i]!=b[i+1]):
                return l-1 # Chai Wah Wu, Feb 15 2024

Formula

a(n) ~ C*n^2 (see Odlyzko and Poonen) with numerical estimate 0.7 < C < 0.9.
Showing 1-2 of 2 results.