What follows is not an answer but a conjecture and some additional
material. We start by working with permutations. I assumed that the
bit pattern / black-white pattern at position $q$ reflects the
less-than greater-than relation at position $q$ in the permutation
(whether the pair at $q$ and $q+1$ is an ascent or a descent, with
circular wrap-around).
I wrote a Perl program to investigate these necklaces (Perl
aficionados are invited to verify and improve this work, e.g. the bit
strings can be produced with pack/unpack). The program
iterates over all bit patterns and attempts to find a circular
permutation that fits the pattern using a backtracking algorithm,
which I hope I've implemented correctly.
The program produced the following table:
$ time ./blg2.pl 12 2>/dev/null
3: 4 2/2
4: 6 4/2
5: 8 6/2
6: 14 12/2
7: 20 18/2
8: 36 34/2
9: 60 58/2
10: 108 106/2
11: 188 186/2
12: 352 350/2
real 7m9.188s
user 7m7.926s
sys 0m0.045s
This table shows the total number of circular colorations obtained and
indicates furthermore that for all $n$ all possible bit patterns were
realized except two. The totals give the sequence
$$4,6,8,14,20,36,60,108,188,352,\ldots $$
which is OEIS A00031 which is simply the
substituted cycle index of the cyclic group
$$\left.Z(C_n)(A+B)\right|_{A=1,B=1},$$
and can be taken as evidence that the program is working since it is
the correct answer (total number of circular patterns with two
colors.)
Observe that the exact values which are
$$2,4,6,12,18,34,58,106,186,350,\ldots $$
also have an OEIS entry namely
OEIS A052823
which reflects the underlying necklace combinatorics but not the
permutation aspect.
The program can also output permutations that fit a given
pattern. Here are the examples for $n=3,4,5$ and $n=6$:
$ time ./blg2.pl 5
100 3-1-2
110 3-2-1
111 FAIL
000 FAIL
3: 4 2/2
1010 3-1-4-2
1000 4-1-2-3
1110 4-3-2-1
1100 4-2-1-3
1111 FAIL
0000 FAIL
4: 6 4/2
11100 5-3-2-1-4
11110 5-4-3-2-1
10100 4-1-5-2-3
11010 4-2-1-5-3
11000 5-2-1-3-4
10000 5-1-2-3-4
00000 FAIL
11111 FAIL
5: 8 6/2
100000 6-1-2-3-4-5
111000 6-3-2-1-4-5
101000 5-1-6-2-3-4
110100 5-2-1-6-3-4
100100 4-1-5-6-2-3
111110 6-5-4-3-2-1
110000 6-2-1-3-4-5
110110 4-2-1-6-5-3
111100 6-4-3-2-1-5
101010 3-1-5-4-6-2
111010 5-3-2-1-6-4
101100 4-1-6-5-2-3
111111 FAIL
000000 FAIL
6: 14 12/2
Studying the examples we immediately have a conjecture, namely that
all black-white patterns can be realized except the monochrome ones
(this is obvious as the circularity makes it impossible to have just
one run in a circular permutation since not all $n$ elements can be to
the left of a larger/smaller element). The conjectured formula is
thus
$$-2 + \left.Z(C_n)(A+B)\right|_{A=1,B=1}.$$
This is
$$-2 +
\left.\frac{1}{n} \sum_{d|n} \varphi(d) (A^d+B^d)^{n/d}\right|
_{A=1, B=1}.$$
This gives the following
CONJECTURE:
$$\large{\color{#0A0}{
-2 + \frac{1}{n} \sum_{d|n} \varphi(d) 2^{n/d}}}.$$
Concluding remark. With the amount of data and context now
available it should not be difficult to produce a combinatorial proof,
which I suspect will turn out to be simple.
This is the Perl code that was used to compute the above data.
#! /usr/bin/perl -w
#
sub search {
my($n, $bits, $q, $avail, $key, $seen, $sofar) = @_;
if($q==$n){
if(($bits->[$n-1] == 0 &&
$sofar->[$n-1] < $sofar->[0]) ||
($bits->[$n-1] == 1 &&
$sofar->[$n-1] > $sofar->[0])){
$seen->{$key} = join('-', @$sofar);
}
return;
}
my $pos = 0;
while(!exists($seen->{$key}) && $pos<$n-$q){
my $nxttry = $avail->[$pos];
if($q==0 ||
(($bits->[$q-1] == 0 &&
$sofar->[$q-1] < $nxttry) ||
($bits->[$q-1] == 1 &&
$sofar->[$q-1] > $nxttry))){
push @$sofar, $nxttry;
splice @$avail, $pos, 1;
search($n, $bits, $q+1,
$avail, $key, $seen, $sofar);
splice @$avail, $pos, 0, $nxttry;
pop @$sofar;
}
$pos++;
}
}
MAIN: {
my $mx = shift || 6;
for(my $n=3; $n<=$mx; $n++){
my $seen = {}; my $failed = {};
for(my $ind=0; $ind<2**$n; $ind++){
my $bits = [];
for(my ($pos, $indx)=(0, $ind);
$pos<$n; $pos++){
push @$bits, ($indx %2);
$indx = ($indx-$bits->[-1])/2;
}
my $rot;
for($rot=0; $rot<$n; $rot++){
my @rotbits =
(@$bits[$rot..($n-1)],
@$bits[0..($rot-1)]);
my $rotkey = join('', @rotbits);
last if
exists($seen->{$rotkey}) ||
exists($failed->{$rotkey});
}
if($rot==$n){
my $key = join('', @$bits);
search($n, $bits, 0, [1..$n], $key, $seen, []);
$failed->{$key} = 'FAIL'
if !exists($seen->{$key});
}
}
my $total = scalar(keys %$seen) + scalar(keys %$failed);
foreach my $pat (keys %$seen){
print STDERR "$pat " . $seen->{$pat} . "\n";
}
foreach my $pat (keys %$failed){
print STDERR "$pat " . $failed->{$pat} . "\n";
}
print "$n: $total " . scalar(keys(%$seen)) . "/" .
scalar(keys(%$failed)) . "\n";
}
}
There is a radically simplified version of the above program which is
not as fast, however. Instead of iterating over bit patterns and
backtracking to find a matching permutation we iterate over all
permutations and collect the bit patterns / black-white patterns that
appear. The slow-down in the speed when solving the case of $n=10$ is
on the order of a factor of $60$. This code uses the factorial number
system to iterate over permutations and never allocates more than one
permutation at a time.
#! /usr/bin/perl -w
#
sub fact {
my ($n) = @_;
return 1 if ($n == 0 || $n == 1);
return $n*fact($n-1);
}
MAIN: {
my $mx = shift || 6;
for(my $n=3; $n<=$mx; $n++){
my $seen = {};
for(my $ind=0; $ind<fact($n); $ind++){
my @perm = (1..$n);
for(my ($pos, $indx) = ($n-1, $ind);
$pos > 0; $pos--){
my $targ = $indx % ($pos+1);
$indx = ($indx-$targ)/($pos+1);
my $tmp = $perm[$pos];
$perm[$pos] = $perm[$targ];
$perm[$targ] = $tmp;
}
my @bits = ();
for(my $pos=0; $pos<$n-1; $pos++){
my $bit =
($perm[$pos] < $perm[$pos+1] ? 1 : 0);
push @bits, $bit;
}
push @bits, ($perm[$n-1] < $perm[0] ? 1 : 0);
my $rot;
for($rot=0; $rot<$n; $rot++){
my @rotbits =
(@bits[$rot..($n-1)],
@bits[0..($rot-1)]);
my $rotkey = join('', @rotbits);
last if exists($seen->{$rotkey});
}
if($rot==$n){
my $key = join('', @bits);
$seen->{$key} = join('-', @perm);
}
}
foreach my $pat (keys %$seen){
print STDERR "$pat " . $seen->{$pat} . "\n";
}
print "$n: " . scalar(keys(%$seen)) . "\n";
}
}