### Archive

Archive for the ‘Mathematica’ Category

## Fun with Fractions

This post is inspired by tweet from @CutTheKnotMath and his post.

He posed this puzzle for the New Year:

Consider the list: $a_i, 1\le i \le n$

Consider the product: $\prod_{i=1}^n (a_i+1) -1$

For $n\ge 2$, replacing randomly chosen $a_i, a_j$ with $a_i+a_j+ a_i a_j$ in the expression does not change its value as $(a_i+1)(a_j+1)=(a_i+a_j+a_i a_j)+1$. So  repeating till there is one number allows you solve the problem, i.e. process ends a unique number. For the particular sequence this is particularly pleasing: $\prod ^n_{i=1}(1+1/i)-1=\prod^n_{i=1}\frac{i+1}{i} -1= n+1-1=n$.

Simulating a small example with Mathematica:

Categories: Mathematica, Mathematics

## Harmony on a Donut

“Harmony” was my sloppy look at the Kuramoto model. Looking at 2 oscillators:
$\dot{\theta_1}=\omega_1+ k\sin (\theta_2-\theta_1)\\\\ \dot{\theta_2}=\omega_2+ k\sin (\theta_1-\theta_2)$

The following starts “knotted” 2:3 with $k=0$, i.e. no coupling and then increasing the coupling…another visualization of harmony.

Visualizing as motion on a circle:

## Multiplication

This is my homage to Mathologer’s wonderful video. The following is multiplication (2x to 100 x) modulo 200 represented on circle:

## Hewing Prime Ladder from Zeta

This post is based on this question on Mathematica Stackexchange.

## Riding the Wild Zeta Line

The following gif shows the Riemann Zeta function map of Re[z]=1/2 with -30<Im[z]<30:

Categories: Mathematica, Mathematics

The brachistochrone problem is classical example used to illustrate the use of calculus of variations. In some ways it illustrates the trade-off between shortest distance (straight line) and greatest speed for a time minimization problem. The solution curve is a cycloid. In addition to the time minimization, no matter where start on the curve you will reach the end point in the same time.

Categories: Mathematica, Mathematics

## Breaking Sticks

This post is based on a probability puzzle. What is the probability that breaking a straight stick at 2 random points will result in 3 segments that can form a triangle.

Consider the resulting segment lengths: $x_i$, $i \in \{1,2,3\}$. Let the stick length =1.

Now,

$\sum_{j=1}^3 x_j=1$

To form a triangle

$x_i+x_j>x_{6-i-j}, i\neq j$ for all ${i,j}\in \{1,2,3\}$

These constraints reduce to: $x_1+x_2>1/2 , x_1<1/2,x_2<1/2$

You can visualize this as follows. As there are only 2 degrees of freedom, consider only space of $x_1,x_2$. The space of allowable $x_1, x_2$ is the region of the unit square: $x_1+x_2<1$ . Within this space the values of $x_1,x_2$ that form a triangle with lengths $(x_1,x_2,1-x_1-x_2)$ is the region satisfying the constraint above.

The probability is then: (1/8)/(1/2)=1/4.

Just for fun:

The light blue triangle is the region of $x_1,x_2$ that can form triangle and the pink triangle encloses the allowable stick segments.

The triangles on the right have been rescaled to be circumscribed by the unit circle. The relative lengths pertain not the absolute lengths.