## Sunday, December 30, 2018

### Christmas lights ring oscillator

We set up a string of Christmas lights wrapped around a pine tree outside and plug it into an outlet with a dusk to dawn sensor so it will only turn on at dusk. After a windy day, some of the lights fell from the tree so we adjusted it in the evening. After adjustment, my son noticed that the lights turn on and off at a regular interval, which was strange since these lights are not flashing lights, but are supposed to be on all the time. It turns out one of the light bulb is too close to the light sensor on the outlet, thus tricking it to turn off since the outlet assumed it was dawn. Since it is now dark without the lights, the sensor assumes it is dusk and turns the light back on and so on and so on. Since there is a delay in the sensor, this resulted in the lights being turned on and off periodically. In essence, we have constructed a ring oscillator. A ring oscillator consists of a loop of an odd number of NOT logic gates. The number of stages and the delay in each stage of the logic gates determine the frequency of the oscillator. In our case, we have a single NOT gate represented by the dawn-to-dusk light sensor/outlet combination.

## Sunday, May 20, 2018

While browsing the internet, the following brainteaser popped up on the screen: find $x$ such that

$$\sqrt{x+15} + \sqrt{x} = 15$$

A straight forward approach is to square both sides, move the single term with radicals to one side and square again, and reducing terms to obtain a linear equation in $x$ whose solution gives the answer.

Here is another (somewhat simpler) way to solve this problem. First note that the left hand side is a increasing function of $x$ and at $x=0$ is equal to $\sqrt{15} < 15$, so there is a single real solution to the equation above.
If we set $x = y^2$ and $x+15 = (y+z)^2$, we get $15 = 2yz + z^2 = z(2y+z)$. The left hand side of the original equation then becomes:

$y+z +y = 2y+z = 15$. Combine this with the above it follows that $z = 1$ and $y = 7$. Thus the answer is $x = 49$.

In general, this method shows that the equation

$$\sqrt{x+a} + \sqrt{x} = b$$ where $b \geq 0$ and $b^2 \geq a$ has as the only real solution:

$$x = \left(\frac{b^2-a}{2b}\right)^2$$

For the case $a = b \geq 0$, this reduces to

$$x = \left(\frac{a-1}{2}\right)^2$$

which is an integer if $a$ is odd.

## Monday, April 16, 2018

### What is a slide rule for?

I was listening to Sam Cooke's classic song "Wonderful World" and thought of the line: "Don't know what the slide rule is for". When the song was released in 1960, the line was describing how disinterested the protagonist was about math and algebra, as the slide rule was a common tool for doing calculations. Today, that line would probably describe most young adults or younger, as the slide rule has not been used for calculations for many years with the rise of the calculator. When I was in high school, we used electronic calculators in our tests and exams, but out of curiosity my brother and I bought a slide rule anyway (they were still being sold in bookstores at the time, but disappeared soon after from the shelves). I was fascinated by how you can multiply two numbers merely by aligning the start of one ruler with the first number and reading off the result off the second number.  This is due a property of logarithm: log(ab) = log(a) + log(b). Thus multiplication is reduced to addition. By printing the numbers in logarithmic scale and lining up segment end-to-end (corresponding to addition), we achieve the operation of multiplication using a slide rule. Similarly, division can be done with a slide rule as it corresponds to subtraction. And it can do a lot more, such as trigonometry and taking square and cube roots. Accuracy was a problem, and they were soon supplanted by calculators which can compute to many digits of precision. As the song is continuously being covered by many artists, I wonder if the current audience would find the lyrics strange?

## Wednesday, March 14, 2018

### Primes of the form H(n,-k)-1

OEIS sequence A299145 lists the primes of the form $Q(n,k) = \sum_{i=2}^n i^k$ for $n \geq 2$ and $k> 0$. It is clear that except for the case $k =1$ and $n=2$ resulting in the prime $2$, we must have $n\geq 3$.
The sum $Q(n,k)$ is equal to $H(n,-k) - 1$ where $H(n,m) = \sum_{i=1}^n \frac{1}{i^m}$ is the generalized harmonic number of order $n$ of $m$. It is well known that $H(n,-k)$ is a polynomial of $n$ of degree $k+1$. In particular, Faulhaber's formula shows that
$$H(n,-k) = \frac{1}{2} n^k + \frac{1}{k+1}\sum_{j=0}^{\lfloor k/2 \rfloor} \left(\begin{array}{c} k+1\\2j\end{array}\right) B_{2j} n^{k+1-2j}$$
where $B_i$ is the $i$-th Bernoulli number.

$H(n,k)$ and thus $Q(n,k)$ can be written as a degree $k+1$ polynomial of $n$ with rational coefficients. The smallest denominator of this polynomial is found in OEIS A064538. In 2017, Kellner and Sondow showed that this is equal to $(k+1)\prod_{p\in S}$ where $S$ is the set of primes $p \leq \frac{k+2}{2+(k \mod 2)}$ such that the sum of the base $p$ digits of $k+1$ is $p$ or larger.

Since $H(1,-k) = 1$, this implies that $Q(1,k) = 0$ and thus $n-1$ is a factor of $Q(n,k)$. Since $n\geq 3$, if $n-1$ does not get cancelled out by a factor of the denominator, we would have a nontrivial factor of $Q(n,k)$ and thus $Q(n,k)$ is not prime. This implies that $Q(n,k)$ is prime only if $n-1$ is a divisor of a(k) in sequence A064538. Thus for each $k$ there is only a finite number of values of $n$ to check. This provides an efficient algorithm to find terms of this sequence by looking only for primes in the numbers $Q(n,k)$ where $n-1$ is a divisor of A064538(k). There are 45 such numbers with $1000$ or less digits.

References
Bernd C. Kellner, Jonathan Sondow, Power-Sum Denominators, Amer. Math. Monthly 124 (2017), 695-709.

## Tuesday, February 20, 2018

### Chaos in music

In an earlier post, I talked about fractals mentioned in the lyrics of a song. Today, I heard the song "Jurassic Park" by Al Yankovic, which mentions chaos theory, a related branch of mathematics that studies the unpredictable and complex behavior of dynamical systems, often manifested as sensitive dependence on initial conditions. On the other hand, musical compositions themselves can exhibit fractal and chaotic behavior [1,2].

References:

[1] K J Hsü and A Hsü, "Self-similarity of the "1/f noise" called music," PNAS, vol. 88, no. 8, pp. 3507-3509, 1991.
[2] J. Beran, "Music - Chaos, Fractals, and Information," CHANCE, vol. 17, no. 4, pp. 7-16, 2004.