The

roots of unity are the solutions of the equation

. The

solutions lie equally spaced around the unit circle.
A solution

is called primitive if

for some

, which occurs when

is coprime to

[1]. The primitive

roots of unity are given by

for

, so there are

, where

is the Euler totient function [2].
The Möbius function

is defined to be

if

is the product of

distinct primes, and zero otherwise, with

[3].
Ramanujan's sum

for

gives

for all positive integers

[4].
The Farey sequence of order

is the set of irreducible fractions between 0 and 1 with denominators less than or equal to

, arranged in increasing order [5].
For the purpose of this Demonstration, we omit the fraction 0/1 and truncate the sequence to include only the fractions less than

. The sequence is

. The truncated Farey sequence is plotted as the black "barcode" and is scaled to the real interval

where the fractions

are those Farey fractions with denominator

and the remaining bars are the Farey fractions with denominators less than

.
Euler's formula

(for

as before) plots the primitive

roots of unity on the unit circle in the complex plane. Upon summing, their symmetries allow cancellation of the imaginary parts and duplication of the real parts to give the shortened summation

, where

stands

here and in the following.
In the result, this sum is shown as

, where
δ denotes the fraction

.
Plotting the points

illustrates how this sum is a measure of their asymmetry about the point zero, seemingly miraculously always equal to

or

for any natural number

.
The Demonstration then plots the points

with a visual link to each point

and computes the comparable sum

.
Computations for

up to

show that the sign of

matches the Möbius function for squarefree

and the sign of

(where

is the floor function) matches the Möbius function for non-squarefree

and is positive for squarefree

.
The product of the sign functions gives an algorithm that returns the Möbius function value;

for

.
Writing

gives the Möbius function in terms of the totient function and the partial sum of the coprime numbers (to

) that it counts;

for

.
Ranging through selected denominators

shows the fractions

that form the truncated Farey sequence

.
Let

be the Farey sequence of order

; a classical sum [6] of the primitive roots of unity gives

, which reduces to

.
The analogous sum

correlates to the classic discrepancy sum

that measures distribution in the Farey sequence

.
The sum

measures asymmetry in the distribution of the Farey sequence

about

.
From the well-known uniform distribution modulo one of the Farey sequence, it follows that

tends to zero as

tends to infinity.