Saturday, December 26, 2020

Harmonic mean of integers

The harmonic mean of a set of $n$ numbers $x_i$ is defined as $\frac{n}{\sum_{i=1}^n x_i^{-1}}$. While investigating the number of subsets of $\{1,...,n\}$ such that the harmonic mean is an integer (OEIS sequence A339453), I formulated and proved the following result, which states that for $n >1$ positive integers whose maximum is a prime power that is attained by a single element, their harmonic mean is not an integer:

Theorem: Let $x_i$ be a finite set of positive integers such that $x_j = \max_i x_i = p^k$ for some prime $p$ and positive integer $k$ and all other numbers $x_i$ are strictly less than $p^k$, then the harmonic mean of $\{x_i\}$ is not an integer.

Proof: Let $M$ be the least common multiple of $\{x_i\}$. Assume that $x_i$ are sorted in nondecreasing order. Thus $x_n = p^k$ and $x_i < p^k$ for all $i<n$ . Then $M = Wp^k$ where $p$ does not divide $W$. Let $Q_i = M/x_i$ and $Q = \sum_i Q_i$. This implies that $Q_n = W$ and $p$ divides $Q_i$ for $i <n$.

The harmonic mean $H$ can then be written as $nM/Q$. Since $p$ does not divide $W$, this implies that $p$ does not divide $Q$. Suppose $H$ is an integer. Then this implies that $Q$ divides $nM/p^k = nW$.

As $x_i < x_n$ for $i < n$, this implies that $Q_i > W$ for $i < n$, i.e. $Q > nW$, and this contradicts the fact that $Q$ divides $nW$ and thus $H$ is not an integer.

Monday, December 14, 2020

Visualizing chaotic attractors via 3D-printed models

 It has been 30 years since I first studied chaotic circuits and dynamical systems. At that time, we visualize the beautiful 3-D (and higher dimensional) chaotic attractors using a Silicon Graphics workstation. I was delighted to read in the December 2020 issue of the Notices of the AMS the article "Modeling Dynamical Systems for 3D Printing" by Stephen K. Lucas, Evelyn Sander and Laura Taalman. The ubiquity of inexpensive 3D printers makes it much easier to create 3D models of chaotic attractors. The authors provided excellent Mathematica and Matlab programs that make it easy to create STL files that can be sent to 3D printers to print these models. With python being able to be run on platforms ranging from PC to smartphones to Raspberry Pi's, I thought it would be nice to have a Python version of these programs. I ported the Matlab program to Python and utilized Python's object oriented features to make it easy to use them for other chaotic dynamical systems. 

The Python port is available here: https://github.com/postvakje/3d-printing-of-chaotic-attractor

The file dynamical_systems.py can be edited to add additional dynamical systems by providing the parameters, initial and ending simulation time, initial conditions and system equations. 

The data files that are output can be used with an script on OpenSCAD to create STL files.