Chaitanya's Random Pages

December 31, 2021

Calculating the locations of stars in the sky

Filed under: geography,mathematics,science — ckrao @ 10:09 am

We present here a calculation of the location of a star as a function of its declination, the observer’s latitude and time after it is at its highest position in the sky. We use the fact that stars trace out circular paths about a fixed point in the sky.

The image below shows a celestial sphere centred on an observer at the location O. Assume the observer is in the northern hemisphere and the point A represents the north celestial pole about which the stars appear to rotate anti-clockwise as the earth rotates on its axis (in the southern hemisphere stars rotate clockwise about the south celestial pole). The red ellipse illustrates the circular path of a star over a 24-hour period – point B is its highest location while point C is where it will be after a quarter of a day. Also shown in the diagram are axes OA (pointing east), OY (pointing north), OZ (pointing directly overhead) and corresponding unit basis vectors \mathbf{i}, \mathbf{j} and \mathbf{k}.

A celestial sphere centred on an observer at the location O

Our aim is to find the location of the star (in 3-dimensional coordinates) on the red circle given:

  • t – the time (as a proportion of a day) after the star has reached its highest point
  • \delta – the angle of declination of the star (-90° to 90°) – the angle between the star and the celestial equator (which is the earth’s equator projected skyward)
  • \phi – the latitude of the observer (-90° to 90°)

The point A is fixed as the earth rotates and in the north direction with an angle of elevation equal to the location’s latitude. Hence we may write

\displaystyle \vec{OA} = 0\ \mathbf{i} + \cos \phi\  \mathbf{j} + \sin \phi\  \mathbf{k}.\quad\quad ...(1)

Next consider the angle between OA and OB. If \delta = 90^{\circ}, we would have a northern pole star and \angle AOB = 0^{\circ}. If \delta = 0^{\circ} we would have a star on the celestial equator and \angle AOB = 90^{\circ}. More generally,

\displaystyle \angle AOB = 90^{\circ}-\delta. \quad\quad ...(2)

The point B has an angle of elevation of \phi + 90^{\circ}-\delta, hence we have

\displaystyle \begin{aligned}\vec{OB} &= 0\ \mathbf{i} + \cos (\phi + 90^{\circ}-\delta )  \mathbf{j} + \sin (\phi + 90^{\circ}-\delta ) \mathbf{k}\\ &= \sin (\delta - \phi ) \mathbf{j} + \cos (\delta - \phi ) \mathbf{k}. \quad \quad ...(3)\end{aligned}

The circular path of the star can be regarded as a point traced around by a line having fixed angle (90^{\circ}-\delta) from the fixed line OA. This circle has its centre at the point A^{'} which is the projection of OB onto the segment OA. Note that A^{'} does not lie on the sphere but A, B and C do. We have

\displaystyle \vec{OA^{'}} = \cos (90^{\circ}-\delta) \vec{OA} = \sin \delta  \quad\quad ...(4)


\displaystyle |\vec{A^{'}B}| = \cos \delta.\quad\quad ...(5)

We parameterise any point on this circular path by expressing it in terms of the basis vectors \vec{A^{'}B} and \vec{A^{'}C}. For any point P on the path we can write

\displaystyle \vec{A^{'}P} = \cos  2\pi t\ \vec{A^{'}B} + \sin  2 \pi t\ \vec{A^{'}C}, \quad t \in [0, 1].\quad\quad ...(6)

For example,

  • if t = 0, \vec{A^{'}P} = \vec{A^{'}B}
  • if t = 0.25, \vec{A^{'}P} = \vec{A^{'}C}
  • if t = 0.5, \vec{A^{'}P} = -\vec{A^{'}B}
  • if t = 0.75, \vec{A^{'}P} = -\vec{A^{'}C}

Since A^{'}C has the same length as |\vec{A^{'}B}| and is pointing directly west (i.e. perpendicular to both \vec{OA} and \vec{OB}), we have from (5):

\vec{A^{'}C} = -\cos \delta\ \mathbf{i}.\quad\quad ...(7)

We now have all the ingredients we need to find \vec{OP}:

\displaystyle\begin{aligned}\vec{OP} &= \vec{OA^{'}} + \vec{A^{'}P}\\&= \vec{OA^{'}} + \cos  2\pi t\ \vec{A^{'}B} + \sin  2 \pi t\ \vec{A^{'}C}\quad \text{(by (6))}\\&=\vec{OA^{'}} + \cos  2\pi t\ (\vec{A^{'}O} + \vec{OB}) + \sin  2 \pi t\ \vec{A^{'}C}\\&= \vec{OA^{'}} - \cos  2\pi t\ \vec{OA^{'}} + \cos  2\pi t\ \vec{OB} + \sin  2 \pi t\ \vec{A^{'}C}\\&= (1- \cos  2\pi t) \vec{OA^{'}} + \cos  2\pi t\ \vec{OB} + \sin  2 \pi t\ \vec{A^{'}C}\\&=\left(1 - \cos  2\pi t \right)\sin \delta\ \vec{OA} + \cos  2\pi t\ \vec{OB} + \sin  2 \pi t\ \vec{A^{'}C}\quad\text{(by (4))}\\&=\left(1 - \cos  2\pi t \right)\sin \delta \left(\cos \phi\  \mathbf{j} + \sin \phi\  \mathbf{k}\right) + \cos  2\pi t \left(\sin (\delta - \phi) \mathbf{j} + \cos (\delta - \phi) \mathbf{k} \right)\\&\quad\quad +  \sin  2 \pi t \left(-\cos \delta\ \mathbf{i} \right)\quad\text{(by (1), (3) and (7))}\\&=-\sin 2\pi t \cos \delta\ \mathbf{i} + \left(\sin \delta \cos \phi + \cos 2\pi t \left( \sin (\delta - \phi ) - \sin \delta \cos \phi \right) \right) \mathbf{j}\\&\quad\quad + \left( \sin \delta \sin \phi + \cos 2 \pi t \left( \cos (\delta - \phi ) - \sin \delta \sin \phi \right) \right) \mathbf{k}\\&=-\sin 2\pi t \cos \delta\ \mathbf{i} + \left( \sin \delta \cos \phi - \cos 2\pi t \cos \delta \sin \phi \right) \mathbf{j}\\&\quad\quad + \left(\sin \delta \sin \phi + \cos 2 \pi t \cos \delta \cos \phi  \right) \mathbf{k}\quad\text{(using trigonometric identities).}\quad\quad ...(8)\end{aligned}

In this formula, the angle of elevation \theta is found by setting \sin \theta equal to the \mathbf{k}-component, or

\displaystyle \theta = \arcsin \left(\sin \delta \sin \phi + \cos 2 \pi t \cos \delta \cos \phi \right).\quad \quad ...(9)

Let us test out formula (8) in some special cases:

  • If \delta = 90^{\circ} we recover the formula \vec{OP} = \cos \phi\ \mathbf{j} + \sin \phi\ \mathbf{k} = \vec{OA}, the fixed location of the pole star.
  • If \delta = 0^{\circ} we recover the formula \vec{OP} = -\sin 2 \pi t\ \mathbf{i} - \cos 2\pi t \left(\sin \phi\ \mathbf{j} - \cos \phi\ \mathbf{k} \right). This traces a circle with diameter joining -\sin \phi \ \mathbf{j} + \cos \phi\ \mathbf{k} and \sin \phi \ \mathbf{j} - \cos \phi\ \mathbf{k} (two antipodal points), hence it is a great circle on the celestial sphere.
  • If \phi = 0^{\circ} (observer on the equator) we obtain \vec{OP} = -\sin 2\pi t \cos \delta\ \mathbf{i} + \sin \delta   \mathbf{j} +  \cos 2 \pi t \cos \delta\ \mathbf{k}, hence the \mathbf{j}-component remains fixed and a circular path is traced.
  • If \phi = 90^{\circ} (observer at the north pole) we obtain \vec{OP} = -\sin 2\pi t \cos \delta\ \mathbf{i} - \cos 2\pi t \cos \delta\ \mathbf{j} + \sin \delta\ \mathbf{k}, hence the star traces out a circle with constant angle of elevation.

We can also determine the times at which a star rises or sets by setting the \mathbf{k}-component of position in (8) to 0:

\displaystyle \begin{aligned} \sin \delta \sin \phi + \cos 2 \pi t \cos \delta \cos \phi &= 0\\ \Rightarrow \quad \cos 2 \pi t &= -\frac{\sin \delta \sin \phi }{\cos \delta \cos \phi }\\&= -\tan \delta \tan \phi.\quad \quad ...(9)\end{aligned}

This is the so-called sunrise equation and was derived differently in an earlier blog post in [1].

Next let us look at the case when the star is our sun. The declination changes during the year between -23.4° and +23.4° (earth’s axial tilt) between the winter and summer soltice (for the northern hemisphere) as the earth revolves around the sun. Assume that the centre of the sun is at the origin and that earth’s orbit is the x-y plane having the form r = R(\cos 2 \pi s\ \mathbf{i} + \sin 2\pi s\ \mathbf{j}) (assuming a circular orbit with radius R starting at R\ \mathbf{i} at s=0). The parameter s here represents the fraction of year after the winter solstice. Earth’s axis of rotation points in the direction a = \sin 22.4^{\circ}\ \mathbf{i} + \cos 22.4^{\circ}\ \mathbf{k}, being tilted away from the sun in the north when s = 0.

From the earth’s point of view the sun is in the direction -\hat{r} = -(\cos 2 \pi s\ \mathbf{i} + \sin 2\pi s\ \mathbf{j}). Then the angle (90 - \delta) between the sun’s position and the earth’s axis satisfies

\displaystyle \begin{aligned}\sin \delta = \cos (90 - \delta) &= -\hat{r} . a\\&= -(\cos 2 \pi s\ \mathbf{i} + \sin 2\pi s\ \mathbf{j}).(\sin 22.4^{\circ}\ \mathbf{i} + \cos 22.4^{\circ}\ \mathbf{k})\\&=  -\sin 22.4^{\circ}\cos 2 \pi s\\ \Rightarrow \delta &= \arcsin (-\sin 22.4^{\circ}\cos 2 \pi s)\\ &\approx \arcsin(-0.398 \cos 2 \pi s).\quad\quad ...(10) \end{aligned}

For example if s = 0, we have \delta = -22.4^{\circ}. If s = 0.25, 0.75, we have the equinoxes and \delta = 0^{\circ}. Finally if s = 0.5 then \delta = 22.4^{\circ}.

Substituting (10) into (8) gives the location of the sun given the time of year and time relative to when it’s at its highest point in the sky (solar noon). Note that the equation is not perfect since it does not take into account atmospheric refraction or the fact that the earth’s orbit is not perfectly circular and therefore the earth is not uniform in speed. For more exercises on the length of days based on latitude and the sun’s angle of declination refer to [2].

Finally, we can determine the bearing of a star when it rises or sets in the following manner. The position P of the sun is in the x-y plane and so has the form

\displaystyle \vec{OP} = x\ \mathbf{i} + y\ \mathbf{j}.\quad\quad ...(11)

Secondly \angle POA = 90^{\circ} - \delta and hence

\displaystyle \begin{aligned}\sin \delta &= \cos (90^{\circ} - \delta)\\ &= \vec{OP}.\vec{OA}\quad \text{(the dot product of two unit vectors is cosine of the angle between them)}\\ &= (x\ \mathbf{i} + y\ \mathbf{j}).(\cos \phi\  \mathbf{j} + \sin \phi\  \mathbf{k})\quad\quad\text{(from (1) and (11))}\\&=y \cos \phi.\quad\quad ...(12)\end{aligned}

Hence y = \sin \delta/\cos \phi. For example taking the sun on the summer solstice at Melbourne, Australia we have \delta = -22.4^{\circ}, \phi = -38^{\circ} and so y = \sin (-22.4^{\circ})/\cos(-38^{\circ})  \approx -0.484. This corresponds to a bearing of \arcsin(0.484) + 90^{\circ} \approx 119^{\circ}, around 20 degrees south of east. The answer given in is 121^{\circ}, slightly more perhaps because it takes into account refraction and the fact that the sun is not pointlike.


[1] The Shortest Day of the Year, Chaitanya’s Random Pages –

[2] Alan Champneys, The Length of Days

September 24, 2021

International men’s cricket match streaks

Filed under: Uncategorized — ckrao @ 8:58 am
Tags: ,

I have created a few interactive charts with Tableau on winning/losing/drawing international men’s cricket streaks using data from’s Statsguru. You can click on any of the links or graphs to interact with it in a new page.

1. Most consecutive tests played with N matches of a given result (won/lost/drawn)

2. Fewest consecutive tests played with N matches of a given result (won/lost/drawn)

3. Most consecutive one-day internationals played with N matches of a given result (won/lost/drawn)

4. Fewest consecutive one-day internationals played with N matches of a given result (won/lost/drawn)

5. Most consecutive T20 internationals played with N matches of a given result (won/lost/drawn)

6. Fewest consecutive T20 internationals played with N matches of a given result (won/lost/drawn)

Here are a few observations.


  • Largely due to timeless tests in Australia up to World War II, Australia had 0 drawn tests at home Australia for 87 consecutive tests until 1946. For similar reasons England had 0 drawn tests away from home for 66 consecutive tests up to 1914 when they drew in South Africa.
  • The top streaks without a loss for any team anywhere are 27, 26 and 25 by West Indies (1982-84), England (1968-71) and Australia (1946-51) respectively.
  • England amazingly lost only 1 test away from home in 40 matches between 1963 and 1972.
  • At home Pakistan lost only 1 test out of 40 from 1969 to 1986 while India only lost once in a span of 35 tests between 2012 and 2019.
  • West Indies lost only 2 out of 53 tests between 1980 and 1986 and just 10 out of 100 from 1976 to 1988.
  • Australia won 12 consecutive tests at home between 1999 and 2001 and 49 out of 61 home tests between 1998 and 2008. India is not far behind with 40 out of 53 home test wins from 2010 to 2021.
  • In any ground Australia won 76 out of 100 tests between 1999 and 2008.
  • South Africa has played 32 consecutive matches (anywhere) without a draw from 2017, an active streak. The next best is 26 by Zimbabwe from 2005 to 2017.
  • New Zealand has an impressive active streak of 17 matches without a loss dating back to 2017 with 8 of their 13 wins by an innings.

One-day Internationals:

  • Australia lost just 2 matches out of 32 anywhere between 2002 and 2003.
  • India lost only 1 match out of 16 away from home between 2016 and 2018.
  • West Indies lost only 7 matches out of 50 in away or neutral grounds between 1981 and 1985.
  • Four teams have won 16 consecutive ODIs at home – Australia (2014-16), South Africa (2016-17), Sri Lanka (1996-98) and West Indies (1986-90). The best is 18 by Australia and Sri Lanka.
  • Australia (1999-2004), Sri Lanka (1994-2004) and South Africa (1994-2001) all won 53/65 matches at home.

T20 Internationals:

  • Afghanistan and Romania share the record of consecutive wins (12).
  • Zimbabwe had 16 consecutive losses (2010-13).
  • Afghanistan (2016-19) and Pakistan (2017-18) have both won 23 out of 26 consecutive games.
  • Afghanistan won 40 out of 50 matches (2014-19).

December 30, 2020

An identity involving the product of reciprocals

Filed under: mathematics — ckrao @ 10:18 am

In this post I would like to prove the following identity, motivated by this tweet.

\displaystyle n! \prod_{k=0}^n \frac{1}{x+k} = \frac{1}{x\binom{x+n}{n}} = \sum_{k=0}^n \frac{(-1)^k \binom{n}{k}}{x+k}

The first of these equalities is straightforward by the definition of binomial coefficients. To prove the second, we make use of partial fractions. We write the expansion

\displaystyle \prod_{k=0}^n \frac{1}{x+k} = \sum_{k=0}^n \frac{A_k}{x+k},

where the coefficients A_k are to be determined. Multiplying both sides by (x+k') for some k' \in \{0, 1, \ldots, n\},

\displaystyle \begin{aligned} (x+k') \prod_{k=0}^n \frac{1}{x+k} &= \sum_{k=0}^n \frac{A_k(x+k')}{x+k}\\\hbox{i.e.}\quad \prod_{\substack{k=0\\k \neq k'}}^n \frac{1}{x+k} &= A_{k'} + \sum_{\substack{k=0\\k \neq k'}}^n \frac{A_k(x+k')}{x+k}.\end{aligned}

Then setting x = -k in both sides gives

\displaystyle \begin{aligned} \prod_{\substack{k=0\\k \neq k'}}^n \frac{1}{k-k'} &= A_{k'} + \sum_{\substack{k=0\\k \neq k'}}^n \frac{A_k(0)}{x+k}\\&= A_{k'}\\\hbox{i.e.}\quad A_{k'} &= \frac{1}{-k'} \cdot \frac{1}{-k'+1}\cdot \ldots \cdot \frac{1}{-1} \cdot \frac{1}{1}\cdot \frac{1}{2}\cdot \ldots \cdot \frac{1}{n-k'}\\&= \frac{(-1)^{k'}}{k'! (n-k')!}\\&= \frac{(-1)^{k'}}{n!} \binom{n}{k'},\end{aligned}

leading to the desired result.

As a few examples of this identity we have:

\displaystyle \begin{aligned}n=1&:& \frac{1}{x(x+1)} &= \frac{1}{x} - \frac{1}{x+1}\\n = 2&:& \frac{1}{x(x+1)(x+2)} &= \frac{1}{2} \left[  \frac{1}{x} - \frac{2}{x+1} + \frac{1}{x+2} \right]\\n=3&:& \frac{1}{x(x+1)(x+2)(x+3)} &= \frac{1}{6} \left[ \frac{1}{x} - \frac{3}{x+1} + \frac{3}{x+2} - \frac{1}{x+3}\right] \end{aligned}

I had previously posted an identity with similar, but trickier derivation here.

July 12, 2020

Charting Test and ODI cricket performances over consecutive innings

Filed under: cricket,sport — ckrao @ 2:23 am

Adding to my earlier blog post about the highest proportion of test scores above m after n innings, I have created some new interactive charts for best streaks early and mid-career in both bowling and batting in tests and ODIs. The data is mostly from

1. Test batting

2. Test bowling

3. ODI batting

4. ODI bowling

Below are shown a few sample charts. Clicking on the chart will take you to a new page where you can interact further.

Test batting:

Two players had a batting average over 100 after 10 test innings
A player’s stats can be viewed by opposition.

Test bowling:

Jason Holder has had an all-time great low bowling average over 20 consecutive innings, Steve Waugh also features here.
Early players dominate the list of fastest to 5 6-wicket hauls in tests.

ODI batting:

Kohli averaged almost 70 per innings over 50 consecutive innings, Warner also has also done very well from 2016-2019.
Shahid Afridi’s maintained this high a batting strike rate over 50 innings between 2004 and 2007.

ODI bowling:

Rashid Khan took 11 more wickets than the next best over 30 consecutive innings.
Over 100 ODI innings, Muralitharan averaged more than 2 better than the next best.

July 8, 2020

The largest parallelogram in a triangle

Filed under: mathematics — ckrao @ 11:59 pm

In this post we find the largest parallelogram, rhombus, rectangle and square that can be contained in a given triangle. We will see that in the first three cases we can achieve half the area of the triangle but no more, while it is generally less than this for a square.

Inscribing a parallelogram, rhombus, rectangle and square of maximum area in a triangle

1. The largest parallelogram inside a triangle

It can be readily seen that one can obtain a parallelogram having half the area of a triangle by connecting a vertex with the three midpoints of the sides. (This has half the base length of the triangle and half its height.)

Is it possible to obtain a larger parallelogram? As outlined in [1], if two or fewer vertices of the parallelogram are on sides of the triangle, a smaller similar triangle can be created by drawing a line parallel to the triangle’s side through a vertex of the parallelogram that is interior triangle. (This is done three times in the figure below.) This reduces the problem to the next case.

A smaller similar triangle containing the parallelogram can be created by lines through its vertices parallel to the sides of the triangle

We are left to consider the case where three or more vertices of the parallelogram on the triangle. We can draw a line from a vertex to the opposite side parallel to a pair of sides (in the figure below AH is drawn parallel to DG), thus dissecting the triangle into two. Each of the smaller triangles then has an inscribed parallelogram where two of the vertices are on a side of each triangle. Then by drawing lines parallel to sides if required, we create two sub-problems each having four vertices of the parallelogram on the sides of the triangle.

Dissecting a triangle so that each smaller triangle has a parallelogram with two vertices on a side. The right parallelogram is contained in a larger one HIEJ formed by lines parallel to the sides.

Finally, if all four vertices of the parallelogram are on sides of the triangle, by the pigeonhole principle, two of them are on a side (say BC as shown in the figure below). In this figure, if we let AD/AB = k and the height of ABC from BC be h_a, then by the similarity of triangles ADE and ABC, DE = k.BC and \triangle ADE has height kh_a. Then the area of the parallelogram DEFG is DE \times (1-k)h_a = k(1-k) DE.h_a which is 2k(1-k) times the area of \triangle ABC. This quantity has maximum value 1/2 when k=1/2 so we conclude that the parallelogram does not exceed half the triangle’s area.

A parallelogram with all four vertices on sides of a triangle must have two of them on one side.

2. The largest rhombus in a triangle

Constraining sides of the parallelogram to be equal (forming a rhombus), we claim that the largest rhombus that can be inscribed in a triangle is also half its area. This can be formed with two of the vertices on the second longest side of the triangle. Suppose a \geq b \geq c are the sides of the triangle with b=AC the second longest side length. Then let the segment MN joining the midpoints of AB and BC form one side of the rhombus of length b/2. It remains to be shown that there exist parallel segments of this same length from M, N to AC. The longest possible such segment has length NC = a/2 and the shortest has length h_b/2, half the length of the altitude of \triangle ABC from B. We wish to show that h_b/2 \leq b/2 \leq a/2. This follows from

\displaystyle h_b = c \sin A \leq c \leq b \leq a.

Inscribing a rhombus of maximal area in a triangle

The area of this rhombus is clearly half the area of the triangle as it has half the length of its base and half the height.

3. The largest rectangle in a triangle

Here if BC is the longest side of the triangle we form the rectangle from midpoints D, E of AB and AC respectively, dropping perpendiculars onto BC forming rectangle DEFG:

The largest rectangle inscribed in a triangle, where D and E are midpoints

The area of this rectangle is half the area of the triangle as it has half the length of its base and half the height.

Interestingly the reflections of the vertices of the triangle in the sides of the rectangle coincide, showing a paper folding interpretation of this result [2].

Reflecting A, B and C in DE, DG and EF respectively yields the same image, yielding a paper folding interpretation

Since rhombuses and rectangles are special cases of parallelograms and we found that inscribed parallelograms in a triangle occupy no more than half its area, the rhombus and rectangle constructions here are optimal.

4. The largest square in a triangle

Here we shall see that the best we can do may not be half the area of the triangle. As before, if two or fewer vertices of the square are not on the sides of the triangle it is possible to scale up the square (or scale down the triangle) so that three of the square’s vertices are on the sides. We claim that the largest square must have two of its vertices on a side of the triangle. Suppose this is not the case and we have the figure below.

Squares with a vertex on each side of \triangle ABC pivot about the point P

Consider squares LMNO inscribed in \triangle ABC so that one vertex L is on AB, M is on BC and O is on CA. We claim that the largest such square is either DEFG (two vertices on BC) or HIJK (two vertices on AC). Suppose on the contrary that neither of these squares is the largest. Then we make use of the fact that all 90-45-45 triangles LMO inscribed in \triangle ABC have a common pivot point P. This is the point at the intersection of the circumcircles of triangles OAL, LBM and MCO. To show these circles intersect at a single point, we can prove that if the circumcircles of triangles OAL and LBM intersect at P then the points O,P,M,C are cyclic by the following equality:

\displaystyle \begin{aligned} \angle MPO &= 360^{\circ} - \angle LPM - \angle OPL\\ &= (180^{\circ} - \angle LPM) + (180^{\circ} - \angle OPL)\\ &= \angle B + \angle A \\ &= 180^{\circ} - \angle C,\end{aligned}

where the second last equality makes use of quadrilaterals BMPL, ALPO being cyclic.

Additionally we have

\displaystyle \begin{aligned}\angle BPC &= \angle BPM + \angle MPC\\ &= \angle BLM + \angle MOC\\ &= (\angle LAM + \angle AML) + (\angle MAO + \angle OMA)\\&=(\angle LAM + \angle MAO ) + (\angle AML + \angle OMA )\\&= \angle BAC + \angle OML\\&=\angle A + 45^{\circ}, \end{aligned}

with similar relations for \angle APB and \angle CPA. Hence P is the unique point satisfying

\displaystyle \begin{aligned}\angle APB &= \angle ACB + 90^{\circ}\\\angle BPC &= \angle BAC + 45^{\circ}\\\angle CPA &= \angle CBA +45^{\circ}.\end{aligned}

(Each equation defines a circular arc, they intersect at a single point. Note that P may be outside triangle ABC.) This point is the centre of spiral similarity of 90-45-45 triangles LMO with L, M, O respectively on the sides AB, BC, CA of the triangle. Consider the locus of the points of the square as L, M, O vary on straight line segments pivoting about P. It follows that the fourth point of the square N also traces a line segment, between the points F and J so as to be contained within the triangle.

As the side length of the square is proportional to the distance of a vertex to its pivot point, the largest square will be where NP is maximised. We have seen that the point N varies along a line segment, so NP will be maximised at one of the extreme points – either when N=F or N=J. We therefore conclude that the largest square inside a triangle will have two points on a side.

If the triangle is acute-angled, by calculating double the area of the triangle in two ways, the side length x of a square on the side of length a with altitude h_a is derived as

\displaystyle \begin{aligned}ah_a &= 2x^2 + (a-x)x + x(h_a-x)\\&=2x^2 + ax - x^2 + xh_a - x^2\\&= ax + xh_a\\Rightarrow \quad x &=  \frac{ah_a}{a + h_a}.\end{aligned}

If the triangle is obtuse-angled, the square erected on a side may not touch both of the other two sides. In the figure below the side length of square BDEF is the same as if A were moved to G, where \triangle GBC is right-angled. In this case the square’s side length is BC.BG/(BC + BG).

The square erected on side AC when \angle ABC is obtuse

The largest square erected on a side may be constructed using the following beautiful construction [2]: simply erect a square CBDE external to the side BC and find the intersection points F = AD \cap BC, G = AE \cap BC.

These points define the base of the square to be inscribed since by similar triangles

\displaystyle \frac{IF}{BD} = \frac{AF}{AD} = \frac{FG}{DE} = h_a/(a + h_a)

so that

\displaystyle IF = FG = \frac{ah_a}{a + h_a}.

One can use this interactive demo to view the largest square in any given triangle. One needs to find the largest of the three possibilities of the largest square erected on each side. In the acute-angled-triangle case, the largest square is on the side that minimises the sum of that side length and its corresponding perpendicular height – as their product is fixed as twice the triangle’s area, this will occur when the side and height have minimal difference. For a right-angled triangle with legs a, b and hypotenuse c, we wish to compare the quantities (a+b) and (c+h), the two possible sums of the base and height of the triangle. We always have a + b - c = 2(s-c) = 2r < h because the diameter of the incircle of the triangle is shorter than the altitude from the hypotenuse (i.e. the incircle is inside the triangle). We conclude that the largest square in a right-angled triangle is constructed on its two legs rather than its hypotenuse.


[1] I. Niven, Maxima and Minima without Calculus, The Mathematical Association of America, 1981.

[2] M. Gardner, Some Surprising Theorems About Rectangles in Triangles, Math Horizons, Vol. 5, No. 1 (September 1997), pp. 18-22.

[3] Jaime Rangel-Mondragon “Largest Square inside a Triangle” Wolfram Demonstrations Project Published: March 7 2011

April 16, 2020

Highest proportion of test scores above m after n innings

Filed under: cricket,sport — ckrao @ 6:02 am

I created an interactive workbook with Tableau to determine the test batsmen who have had the highest proportion of innings scoring at least m runs after having played n test innings. Below are some screenshots for particular choices of m runs. The data is available from [1]. As expected Bradman comes up on top in many scenarios but it is interesting to see other names that appear up there.


(Click on the above image to go to the Tableau page if you wish to change the parameters. You can also select the “Innings by innings” tab to look up a player’s list of innings.)

Below we some examples for different m (full-career stats among players who have played at least 20 innings).

m=1: A total of 22 players have had an entire career of 20+ innings getting off the mark each time, with RA Duff (Australia, 1902-1905) the only to play 40 innings (note that JW Burke played 44 innings without a duck, but made 0 not out in one innings).

Angelo Mathews (SL) has managed just 2 ducks in his 154 innings to date.

1 or more

m=10: Hobbs, Hutton, Kanhai and Sobers stand out here, having played over 100 innings and reaching double figures at least 80% of the time (Hobbs over 86%). Labuschagne, Hetmyer, Handscomb and Head are recent players to feature highly here.
10 or more

m=25: Bradman starts to distance himself from the rest. Hammond, Smith, Sobers and de Villiers also impress here.
25 or more

m=50: Smith has matched Barrington’s career figures of 50+ starts. Sutcliffe had 33 50+ scores in his first 64 innings, the same as Bradman.
50 or more

m=75: Barrington’s numbers are amazing here and Katich is ahead of Kohli, Tendulkar and Lara.
75 or more

m=100: Smith and Kohli are currently higher than Sangakkara, the highest among recent retirees.
100 or more

m=125: Only Bradman (6) had more 140+ scores than Labuschagne after playing 23 test innings, equal with Graeme Smith (who had 4 150+ scores in his first 17 innings!).
125 or more

m=150: Bradman is so far ahead of the rest here. Lara and Sangakkara are just one behind Tendulkar with the most 150+ scores despite almost 100 fewer innings.
150 or more

m=175: Again Lara and Sangakkara have the same number of 175+ scores (15).
175 or more

m=200: Kohli is similar to Hammond’s career figures at this stage, with 6 of his 7 double centuries coming within 33 innings between July 2016 and December 2017.
200 or more

Please leave any other interesting observations in the comments.



December 7, 2019

Coordinates of special points of the 3-4-5 triangle

Filed under: mathematics — ckrao @ 3:40 am

One thing I observed is that the 3-4-5 triangle is rather attractive in solving problems using coordinates. If the vertices are placed at (0,3), (0,0) and (4,0) the following are the coordinates of points and equations of some lines of interest.

Line AC: x/4 + y/3 = 1

Incentre: (1, 1)

Centroid: (4/3, 1)

Circumcentre: (2, 1.5)

Orthocentre: (0, 0)

Nine-point centre: (1, 3/4) (midpoint of the midpoints of AB and BC)

Angle bisectors: y = x, y=-2x +3, y=4/3-x/3

Ex-centres (intersection of internal and external bisectors): (3,- 3), (6, 6), (-2, 2)


Lines joining the excentres (in red above): y=-x, y=x/2 +3, y = 3(x-4)

Altitude to the hypotenuse: y = 4x/3

Euler line: y=3x/4

Foot of altitude to the hypotenuse: (36/25, 48/25) (where x/4 + y/3 = 1 intersects y=4x/3)

Symmedian point (midpoint of the altitude to the hypotenuse [1]): (18/25, 24/25)

Contact points of incircle and triangle: (1,0), (0,1), (8/5, 9/5)

Gergonne point (intersection of Cevians that pass through the contact points of the incircle and triangle = the intersection of y=3-3x and y=1-x/4): (8/11, 9/11)

Nagel point (intersection of Cevians that pass through the contact points of the ex-circles and triangle = the intersection of y=3-x and y=2-x/2: (2,1)


[1] Weisstein, Eric W. “Symmedian Point.” From MathWorld–A Wolfram Web Resource.

January 26, 2019

49+ °C temperatures in Australia

Filed under: climate and weather — ckrao @ 12:32 pm

Below is a list of recorded instances of maximum temperatures of 49 degrees Celsius or more in Australia, based on [1] and [2] from Australia’s Bureau of Meteorology. Out of the 48 52 occasions, 22 26 have occurred in this decade including 8 (so far) during this summer alone! I believe all the stations have been recording temperatures for at least 20 years except Port Augusta and Keith West (which both started in 2001). Edited: 20 Dec 2019

Temperature (°C) Date Station Name State
50.7 2-Jan-60 Oodnadatta Airport SA
50.5 19-Feb-98 Mardie WA
50.3 3-Jan-60 Oodnadatta Airport SA
49.9 19-Dec-19 Nullarbor SA
49.8 19-Dec-19 Eucla WA
49.8 21-Feb-98 Emu Creek Station WA
49.8 13-Jan-79 Forrest Aero WA
49.8 3-Jan-79 Mundrabilla Station WA
49.7 10-Jan-39 Menindee Post Office NSW
49.6 12-Jan-13 Moomba Airport SA
49.5 19-Dec-19 Forrest WA
49.5 24-Jan-19 Port Augusta Aero SA
49.5 24-Dec-72 Birdsville Police Station QLD
49.4 21-Dec-11 Roebourne WA
49.4 16-Feb-98 Emu Creek Station WA
49.4 7-Jan-71 Madura Station WA
49.4 2-Jan-60 Marree Comparison SA
49.4 2-Jan-60 Whyalla (Norrie) SA
49.3 27-Dec-18 Marble Bar WA
49.3 2-Jan-14 Moomba Airport SA
49.3 9-Jan-39 Kyancutta SA
49.2 20-Dec-19 Keith West SA
49.2 24-Jan-19 Kyancutta SA
49.2 21-Feb-15 Roebourne Aero WA
49.2 10-Jan-14 Emu Creek Station WA
49.2 22-Dec-11 Onslow Airport WA
49.2 1-Jan-10 Onslow WA
49.2 11-Jan-08 Onslow WA
49.2 9-Feb-77 Mardie WA
49.2 1-Jan-60 Oodnadatta Airport SA
49.2 3-Jan-22 Marble Bar Comparison WA
49.2 11-Jan-05 Marble Bar Comparison WA
49.1 24-Jan-19 Tarcoola Aero SA
49.1 23-Jan-19 Red Rocks Point WA
49.1 13-Jan-19 Marble Bar WA
49.1 27-Dec-18 Onslow Airport WA
49.1 3-Jan-14 Walgett Airport AWS NSW
49.1 2-Jan-10 Emu Creek Station WA
49.1 18-Feb-98 Roebourne WA
49.1 23-Dec-72 Moomba SA
49 15-Jan-19 Tarcoola Aero SA
49 23-Jan-15 Marble Bar WA
49 13-Jan-13 Birdsville Airport QLD
49 9-Jan-13 Leonora WA
49 21-Dec-11 Roebourne Aero WA
49 1-Jan-10 Mardie WA
49 10-Jan-09 Emu Creek Station WA
49 11-Jan-08 Port Hedland Airport WA
49 11-Jan-08 Roebourne WA
49 12-Jan-88 Marla Police Station SA
49 6-Dec-81 Birdsville Police Station QLD
49 22-Dec-72 Marree SA




December 30, 2018

A collection of energy formulas

Filed under: science — ckrao @ 10:58 am

Energy is a quantity that is conserved as a consequence of the time-translation invariance of the laws of physics. Below are some formulas calculating energy of different forms.

Kinetic energy is that associated with motion and is defined as K = \frac{1}{2} mv^2 = \frac{p^2}{2m} for a particle with mass m, velocity v and momentum p. If the mass is a fluid in motion (e.g. wind) with density \rho and volume A v t through cross-sectional area A, then K = \frac{1}{2} At\rho v^3.

Work is the result of a force F applied over a displacement \mathbf{s} and is given by the line integral

\displaystyle W = \int_C \mathbf{F} . \mathrm{d}\mathbf{s} = \int_{t_1}^{t_2} \mathbf{F} . \frac{\mathrm{d}\mathbf{s}}{\mathrm{d}t} \ \mathrm{d}t= \int_{t_1}^{t_2} \mathbf{F}.\mathbf{v}\ \mathrm{d}t .

This has the simple form W = Fs \cos \theta when force is constant and displacement is linear where \theta is the angle between the force and displacement vectors.

Using Newton’s 2nd law and the relation \frac{\mathrm{d}}{\mathrm{d}t} (\mathbf{v}^2) = 2\mathbf{v}.\frac{\mathrm{d}\mathbf{v}}{\mathrm{d}t} this can be written as

\displaystyle W = m\int_{t_1}^{t_2} \frac{d\mathbf{v}}{dt} . \mathbf{v} \mathrm{d}t = \frac{1}{2}m\int_{t_1}^{t_2} \frac{\mathrm{d}}{\mathrm{d}t} (\mathbf{v}^2) \mathrm{d}t = \frac{1}{2}m\int_{v_1^2}^{v_2^2} \mathrm{d}(\mathbf{v}^2) = \frac{1}{2}mv_2^2 - \frac{1}{2}mv_1^2.

This is the work-energy theorem which says that work is the change in kinetic energy by a net force. It can also be written as W = \int_{v_1}^{v_2} m \mathbf{v}.\mathrm{d}\mathbf{v} = \int_{p_1}^{p_2} \mathbf{v}.d\mathbf{p} where \mathbf{p} = m\mathbf{v} is momentum.

The above has the rotational analogue K = \frac{1}{2} I \omega^2 where I is moment of inertia and \omega is angular velocity and the equation for work becomes

\displaystyle W = \int_{t_1}^{t_2} \mathbf{T} . \mathbf{\omega}\ \mathrm{d}t,

where \mathbf{T} is a torque vector.

This has the simple form W = Fr \omega = \tau \omega in the special case of a constant magnitude tangential force where \tau = Fr is the torque resulting from force F applied at distance r from the centre of rotation.

Note that the time derivative of work is defined as power, so work can also be expressed as the time integral of power:

W = \int P(t)\  \mathrm{d}t = \int_{t_1}^{t_2} \mathbf{F}.\mathbf{v}\ \mathrm{d}t.

If the work done by a force field \mathbf{F} depends only on a particle’s end points and not on its trajectory (i.e. conservative forces), one may define a potential function of position, known as potential energy U satisfying \mathbf{F} = -\nabla U. By convention positive work is a reduction in potential, hence the minus sign. It then follows that in such force fields the sum of kinetic and potential energy is conserved.

Some types of potential energy:

  • due to a gravitational field: \mathbf{F} = -(GMm/r^2) \hat{r}, U = -GMm/r, where M, m are the masses of two bodies, r the distance between their centre of masses and G is Newton’s gravitation constant.
  • due to earth’s gravity at the surface: \mathbf{F} = -mg, U = mgh where g \approx 9.8 ms^{-2} and h is the object’s height above ground (small compared with the size of the earth).
  • due to a spring obeying Hooke’s law: \mathbf{F} = -kx, U = kx^2/2 where k is the spring constant and x the displacement from an equilibrium position.
  • due to an electrostatic field: \mathbf{F} = q\mathbf{E} = (k_e qQ/r^2) \hat{r}, U = k_e qQ/r where k_e is Coulomb’s constant 1/(4\pi \epsilon_0) and q, Q are charges. This can be written as U = qV where V is a potential function measured in volts.
  • for a system of point charges: \displaystyle U =k_e \sum_{1 \leq i < j \leq n} \frac{q_i q_j}{r_{ij}}.
  • for a system of conductors: U = \frac{1}{2} \sum_{i=1}^n Q_i V_i where the charge on conductor i is Q_i and its potential is V_i.
  • for a charged dielectric: the above may be generalised to the volume integral U = \frac{1}{2} \int_V \rho \Phi \ \mathrm{d}v where \rho is charge density and \Phi is the potential corresponding to the electric field.
  • for an electric dipole in an electric field: U = -\mathbf{p}.\mathbf{E} where \mathbf{p} is directed from the negative to positive charge and has magnitude equal to the product of the positive charge and charge separation distance.
  • for a current loop in a magnetic field: U = -\mathbf{\mu}.\mathbf{B} where \mathbf{\mu} is directed normal to the loop and has magnitude equal to the product of the current through the loop and its area.

In electric circuits the voltage drop across an inductance L is v = L di/dt and the current though a capacitance C is i = C dv/dt. These inserted into the relationship E = \int i(t)v(t) \ \mathrm{d}t lead to the formulas E = \frac{1}{2}L(\Delta I)^2 and E = \frac{1}{2}C(\Delta V)^2 for the energy stored in an inductor and capacitor respectively.

Also in electromagnetism the energy flux (flow per unit area per unit time) is the Poynting vector \mathbf{S} = \mathbf{E} \times \mathbf{H}, the cross product of the electric and magnetising field vectors. The electromagnetic energy in a volume V is given by ([1])

\displaystyle \frac{1}{2}\int_V \mathbf{B}.\mathbf{H} + \mathbf{E}.\mathbf{D}  \ \mathrm{d}v,

where \mathbf{D} is the electric displacement field and \mathbf{B} is the magnetic field. This is more commonly written as \displaystyle \frac{1}{2} \int_V \epsilon_0 |E|^2 + |B^2|/\mu_0 \ \mathrm{d}v when the relationships \mathbf{D} = \epsilon_0\mathbf{E}, \mathbf{B} = \mu_0 \mathbf{H} hold.

In special relativity energy is the time component of the momentum 4-vector. That is, energy and momentum are mixed in a similar way to how space and time are mixed at high velocities. Computing the norm of the momentum four-vector gives the energy-momentum relation

E^2 = (pc)^2 + (m_0c^2)^2.

This leads to E = pc for massless particles (such as photons) and more generally E = \gamma m_0 c^2 , the mass-energy equivalence relation (here \gamma = (1 - (v/c)^2)^{-1/2} and m_0 is rest mass).

In quantum mechanics the energy of a photon is also written as E = hf = hc/\lambda (Planck-Einstein relation) where h is Planck’s constant and f, \lambda are frequency and wavelength respectively. Energies of quantum systems are based on the eigenstates of the Hamiltonian operator, an example of which is \displaystyle {\hat {H}}=-{\frac {\hbar ^{2}}{2m}}\nabla^2+V(x).

Force is also equal to pressure times area, so another formula for work (e.g. done by an expanding gas) is the volume integral W = \int p \mathrm{d}V. In thermodynamics heat is energy transferred through the random motion of particles. The fundamental equation of thermodynamics quantifies the internal energy U which disregards kinetic or potential energy of a system as a whole (only considering microscopic kinetic and potential energy):

\displaystyle U = \int  \left(T \text{d}S - p \mathrm{d}V + \sum_i \mu_i \mathrm{d}N_i \right)

where T is temperature, S is entropy, N_i is the number of particles and \mu_i the chemical potential of species i. Similar formulas exist for other thermodynamic potentials such as Gibbs energy, enthalpy and Helmholtz energy.

The mean translational kinetic energy of a bulk substance is related to its temperature by \bar{E} = \frac{3}{2}k_B T where k_B is Boltzmann’s constant.

In thermal transfer the change in internal energy is given by \Delta U = m C \Delta T where m is mass and C is the heat capacity which may apply to constant volume or constant pressure.

The power per unit area emitted by a body is given by the Stefan-Boltzmann law P = A \epsilon \sigma T^4 where \epsilon is the emissivity (=1 for black body radiation) and \sigma is the Stefan–Boltzmann constant. This equation may be used to determine the energy emitted by stars using their emission spectrum.

The latent heat (thermal energy change during a phase transition) of mass m of a substance with specific latent heat constant L is given by Q = mL.

Finally, the energy of a single wavelength of a mechanical wave is \displaystyle \frac{1}{2} m\omega^2 A^2 where m the mass of a wavelength, A the amplitude and \omega the angular frequency [2]. This can be applied to finding the energy density of ocean waves for example [3].


[1] Poynting Vector. Retrieved 22:24, December 28, 2018, from

[2] Power of a Wave. Retrieved 21:23, December 30, 2018, from

[3] Wikipedia contributors, “Wave power,” Wikipedia, The Free Encyclopedia, (accessed December 30, 2018).

[4] Wikipedia contributors, “Work (physics),” Wikipedia, The Free Encyclopedia, (accessed December 30, 2018).

[5] Wikipedia contributors, “Potential energy,” Wikipedia, The Free Encyclopedia, (accessed December 30, 2018).

[6] Wikipedia contributors, “Electric potential energy,” Wikipedia, The Free Encyclopedia, (accessed December 30, 2018).

[7] Wikipedia contributors, “Thermodynamic equations,” Wikipedia, The Free Encyclopedia, (accessed December 30, 2018).

[8] H. Ohanian, Physics, 2nd edition, Norton & Company, 1989.

June 12, 2018

Rafael Nadal in best of five set matches on clay

Filed under: sport — ckrao @ 1:28 pm

Following Rafael Nadal‘s 11th French Open win, it’s worth looking at just how amazing his best-of-five set record on clay is. He now has a 111-2 win-loss record, with his only two losses against Söderling and Djokovic.

Win-loss breakdown by tournament (Masters tournament finals changed to best of 3 sets from 2007):

  • French Open: 86-2
  • Davis Cup: 18-0
  • Barcelona Open: 2-0
  • Monte Carlo Masters: 2-0
  • Rome Masters: 2-0
  • Stuttgart: 1-0

Win-loss breakdown by number of sets (overall he has won 331 and lost 36 completed sets so even winning a set against him is a big deal!):

  • 5 sets: 4-0 (Coria, Federer, Isner, Djokovic – 5th set scores 7-6 (6), 7-6 (5), 6-4, 9-7 respectively)
  • 4 sets: 22-1 (loss to Söderling)
  • 3 sets: 83-1

Most common opponents (2 or more matches):

  • Djokovic: 7-1 (lost 7 sets)
  • Federer: 7-0 (lost 7 sets)
  • Ferrer: 4-0 (lost 1 set)
  • Almagro: 4-0
  • Hewitt: 4-0 (lost 1 set)
  • Söderling: 3-1 (lost 3 sets)
  • Thiem: 3-0
  • del Potro: 3-0 (lost 1 set)
  • Gasquet: 3-0
  • Seppi: 2-0 (lost 1 set)
  • Murray: 2-0
  • Roddick: 2-0 (lost 1 set)
  • Coria: 2-0 (lost 3 sets)
  • Ljubicic: 2-0
  • Monaco: 2-0
  • Bolelli: 2-0
  • Wawrinka: 2-0 (same score of 6-2 6-3 6-1 both times)
  • Bellucci: 2-0

Breakdown by set score (almost the same likelihood of winning a set 6-2, 6-3 or 6-4):

  • 6-0: 26
  • 6-1: 61
  • 6-2: 68
  • 6-3: 66
  • 6-4: 67
  • 7-5: 18
  • 7-6: 24
  • 9-7: 1
  • 6-7: 9
  • 5-7: 6
  • 4-6: 8
  • 3-6: 6
  • 2-6: 3 (Federer in 2006 Rome, Söderling in 2009 French Open, Djokovic in 2012 French Open)
  • 1-6: 3 (Federer in 2006 French Open, del Potro in 2011 Davis Cup, Djokovic in 2015 French Open)
  • 0-6: 1 (Coria in 2005 Monte Carlo Masters)

(only one incomplete set 2-0 after which Pablo Carreno Busta retired)


(1) Tennis Abstract: Rafael Nadal ATP Match Results, Splits, and Analysis

(2) Ultimate Tennis Statistics – Rafael Nadal

Next Page »

Blog at

%d bloggers like this: