# Length of the day

This note is supplementary to a previous one entitled "Sunrise Direction". The same model of Earth with respect to the Sun is used to predict the length of day, on any given day in the year, and anywhere on Earth.

We have three coordinate reference frames to relate, the first one (Frame 1) is the reference frame that has its center at the center of Earth, with the z-axis set perpendicular to the orbital plane (the plane in which the Earth orbits the Sun). Also, the x-axis is selected to point towards the center of the Sun.

The second reference frame (Frame 2) is attached to Earth, centered at the Earth center, with its z-axis along the axis of Earth rotation. The x-axis orientation, results naturally when we look at this frame as being the result of two consecutive geometric rotations, the first is about the z-axis (of the orbital plane). And the second is about the y-axis of the frame resulting from the first rotation.

Finally, the third frame (Frame 3), is the frame attached to a moving point on the surface of Earth, with its three axes pointing towards the standard directions of local East, local North, and local Vertical. Thus, let $r_1 = [x_1, y_1, z_1 ]^T$ be the coordinate vector in the orbital plane, and $r' = [x', y', z' ]^T$ be the corresponding coordinate vector in the frame resulting from the first rotation, and let $r_2 = [x_2, y_2, z_2 ]^T$ be the corresponding coordinate vector in Frame 2. We can relate these three vectors as follows

$r_1 = R' r'$

where $R'$ is the rotation matrix about the z-axis by an angle $\phi$, and is given by

$R' = \begin{bmatrix} \cos \phi && -\sin \phi && 0 \\ \sin \phi && \cos \phi && 0 \\ 0 && 0 && 1 \end{bmatrix}$

$r' = R_y r_2$

where $R_y$ is the rotation matrix about the y-axis by an angle $\theta$, and is given by

$R_y = \begin{bmatrix} \cos \theta && 0 && \sin \theta \\ 0 && 1 && 0 \\ -\sin \theta && 0 && \cos \theta \end{bmatrix}$

Hence,

$r_1 = R' R_y r_2 = R_1 r_2$

where

$R_1 = R' R_y = \begin{bmatrix} \cos \phi \cos \theta && -\sin \phi && \cos \phi \sin \theta \\ \sin \phi \cos \theta && \cos \phi && -\sin \phi \sin \theta \\ -\sin \theta && 0 && \cos \theta \end{bmatrix}$

Next, we consider Frame 3. We note that the unit vectors pointing East and North and Vertically Up, at a given point that has a latitude of $(90^{\circ} - \theta_L )$ is given by

$v_{East} = [ - \sin \phi_t , \cos \phi_t , 0 ]^T$

And

$v_{North} = [ - \cos \theta_L \cos \phi_t , - \cos \theta_L \sin \phi_t, \sin \theta_L ]^T$

And

$v_{Vertical} = [ \sin \theta_L \cos \phi_t, \sin \theta_L \sin \phi_t, \cos \theta_L]^T$

Where $\phi_t$ is the rotation angle counterclockwise from the x-axis of the Earth reference frame.
Together, these three vectors form an orthornormal basis for the reference frame we name Frame 3, and can written with respect to frame 2 as

$R_2 = [ v_{East}, v_{North}, v_{Vertical} ]$

i.e.

$R_2 = \begin{bmatrix} -\sin \phi_t && -\cos \theta_L \cos \phi_t && \sin \theta_L \cos \phi_t \\ \cos \phi_t && - \cos \theta_L \sin \phi_t && \sin \theta_L \sin \phi_t \\ 0 && \sin \theta_L && \cos \theta_L \end{bmatrix}$

Now, in the orbital reference frame (Frame 1), the direction to the Sun is pointing in the positive x-direction,

$u_1 = [1, 0, 0]^T$

It follows that the direction of the sun , when expressed with respect to Frame 3, is related to $u_1$ , by

$u_1 = R_1 R_2 u3$ From which

$u_3 = R_2^T R_1^T u_1$

Being a rotation matrix, the inverse of $R_i$ is its transpose. Performing the indicated multiplication, results in $u_3$

$u_3 = \begin{bmatrix} - \sin \phi_t && \cos \phi_t && 0 \\ - \cos \theta_L \cos \phi_t && -\cos \theta_L \sin \phi_t && \sin \theta_L \\ \sin \theta_L \cos \phi_t && \sin \theta_L \sin \phi_t && \cos \theta_L \end{bmatrix} \begin{bmatrix} \cos \phi \cos \theta \\ -\sin \phi \\ \cos \phi \sin \theta \end{bmatrix}$

$u_3 = \begin{bmatrix} - \cos \phi \cos \theta \sin \phi_t - \sin \phi \cos \phi_t \\ - \cos \phi \cos \theta \cos \theta_L \cos \phi_t + \sin \phi \cos \theta_L \sin \phi_t + \cos \phi \sin \theta \sin \theta_L \\ \cos \phi \cos \theta \sin \theta_L \cos \phi_t - \sin \phi \sin \theta_L \sin \phi_t + \cos \phi \sin \theta \cos \theta_L \end{bmatrix}$

Now, at sunrise , the z-component of this vector is zero, because the Sun will be coming from the horizon. So we need to solve for $\phi_t$ that will result in zero z-component of $u_3$. To that end, let

$a = \cos \phi \cos \theta \sin \theta_L$

$b = -\sin \phi \sin \theta_L$

$c = \cos \phi \sin \theta \cos \theta_L$

then

$u_{3z} = a \cos \phi_t + b \sin \phi_t + c = 0$

Define $\psi$ to be the angle with $\cos \psi = a / \sqrt{a^2+b^2}$ and $\sin \psi = b / \sqrt{a^2 + b^2}$, then

$\sqrt{a^2+b^2} \cos (\phi_t - \psi) + c = 0$

This raised-cosine crosses from negative to positive at

$\phi_t = \psi - \cos^{-1} (- c / \sqrt{a^2+b^2} )$

This corresponds to sunrise, and it crosses from positive to negative at

$\phi_t = \psi + \cos^{-1} (- c / \sqrt{a^2+b^2} )$

And this corresponds to sunset.

Therefore, the angle swing between sunrise and sunset is given by

$\Delta \phi_t = 2 \cos^{-1} (- c / \sqrt{a^2+b^2} )$

Since $\phi_t$ changes linearly with time, and since it covers $2 \pi$ in $T=23.934471$ hours (this is called a stellar day), it follows that the length of the day is given by

$Day Length = T ( \Delta \phi_t / (2 \pi ) )$

Using the expressions for $a, b, c$ , and simplifying, results in

$Day Length = (T / \pi ) \cos^{-1} ( \frac{- \cot \theta_L \sin \theta \cos \phi} {\sqrt{\sin^2 \phi + \cos^2 \phi \cos^2 \theta } } )$

As an example, to compute the day length, in Ottawa, on December 13th, compute angle $\phi$ from the number of days that have passed since June 21st, and this number is 175 days. Hence

$\phi = -(175/365.25) * 360^{\circ} = - 172.48^{\circ}$

And since Ottawa has a latitude of $45.42^{\circ}$ North of the Equator, then

$\theta_L = 90^{\circ} - 45.42^{\circ} = 44.58^{\circ}$

$\theta = 23.44^{\circ}$

Substituting these values in the above equation, and performing the numeric calculations, results in

$Day Length = (T / \pi ) \cos^{-1} (0.435486) = 8.53447 Hours$

That is, 8 Hours, and 32 Minutes.

The actual Sunrise in Ottawa was at 7:34 am and Sunset is at 4:20 pm, making the day length = 16:20 - 7:34 = 15:80 - 7:34 = 8:46 , i.e. 8 Hours and 46 minutes.

The difference (about 14 minutes, i.e. $2.7 \%$ error) is due to factors we've ignored like refractions of the sun rays in the atmosphere, and also that our calculation assumes a fixed angle $\phi$.

Note by Hosam Hajjir
6 years, 7 months ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

• bulleted
• list

1. numbered
2. list

1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

> This is a quote
This is a quote
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$...$$ or $...$ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$