The requirement is for a function
$h \colon \mathbb{R} \to \mathbb{R}$ satisfying the following
conditions. The argument of the function represents time, for the
purpose of modelling life on an imaginary planet in a computer game.
Each interval $[i, i + 1),$ where $i$ is an integer, represents one
day, i.e., one rotation of the planet about its North-South axis.
All days have exactly the same length. A year consists of exactly
$n$ days, where $n$ is an integer. Because the planet's rotational
axis is not perpendicular to the plane of its solar orbit, the
length of the period of daylight varies throughout the year. The
value of the function $h$ is to represent an idealised concept of
temperature, which increases smoothly to a maximum value in the
middle of the day (i.e., the period of daylight), then decreases
smoothly to a minimum value in the middle of the night, before
increasing smoothly again towards the dawn of the next day. That
is, the behaviour of $h$ on each interval $[i, i + 1],$ where $i$ is
an integer, is like that of a sine function on $[0, 2\pi],$ except
that the positive values occur on an interval $(i, i + a),$ and
the negative values occur on the interval $(i + a, i + 1),$ where
the number $a \in (0, 1)$ is the fraction of the rotational period
in which there is daylight (at a given point on the planet's surface,
on a given day of the year), and $a$ is not a constant, but has a
different value for each value of $i.$ Physical realism is not
required, either for the variation in temperature during the day and
night, or for the annual variation in the length of the period of
daylight, but the value of $a$ should increase from $\frac12$ at the
planet's "Spring equinox", to a maximum value $a_\text{max},$ say,
at the "Summer solstice", then decrease again to $\frac12$ at the
"Autumn equinox", then further to a minimum of $1 - a_\text{max}$
at the "Winter solstice", then increase to $\frac12$ again at the
next year's "Spring equinox". The function $h$ must have a
continuous derivative.
An older question, Continuous function for day/night with
night being c times longer than day, which like this one
has some latitude (no pun intended!) of interpretation, asks for a
function $f_c \colon [0, 1) \to [0, 1),$ with
$\left[0, \frac1{c + 1}\right)$ representing "day" and
$\left[\frac1{c + 1}, 1\right)$ representing "night", and
$f_c\left(\frac1{c + 1}\right) = \frac12,$ as if $f_c$ represents
some physical quantity that changes by equal amounts in the day and
night, even though night is $c$ times longer than day, $c$ being an
arbitrary strictly positive parameter.
I gave two solutions. The first was a polynomial function, obtained
using Hermite interpolation. (The necessary general formulae were
contained in an older answer of mine, but I gave a self-contained
proof of its validity in an appendix to the more recent answer.)
Being analytic, this function satisfied even the most rigid
interpretation of the requirements of the question, but it also
suffered from another form of rigidity, which not only limited the
range of values of $c,$ but even for moderate values of $c$ made it
uniformly inferior
to the second solution, using cubic spline interpolation. The
latter was not analytic, but it was continuously differentiable, and
it was valid for all values of $c.$
The night-to-day ratio is $c = (1 - a)/a.$ If $f_c$ is either of the
functions above [I've hit the length limit, so I can't repeat the definitions!], then the function
$$
h \colon \mathbb{R} \to \mathbb{R}, \
t \mapsto \sin(2\pi f_{c(\left\lfloor t\right\rfloor)}(t - \left\lfloor t\right\rfloor))
$$
for some suitable function
$$
c \colon \mathbb{Z} \to \mathbb{R}_{>0},
$$
of period $n,$ is continuously differentiable, and satisfies the requirements of the present question.
Here is some Python code that implements those functions:
# ~\Work\Comp\Python\3\Lib\maths\diurnal.py
#
# Sun 26 Jul 2020 (created)
# Sat 1 Aug 2020 (updated)
"""
Day/night cycle: https://math.stackexchange.com/q/3766767.
See also previous question: https://math.stackexchange.com/q/3339606.
Has been run using Python 3.8.1 [MSC v.1916 64 bit (AMD64)] on win32.
"""
__all__ = ['planet', 'hermite', 'spline']
from math import asin, atan, cos, fabs, inf, pi, sin, sqrt
import matplotlib.pyplot as plt
import numpy as np
class planet(object):
# Sun 26 Jul 2020 (created)
# Sat 1 Aug 2020 (updated)
"""
A simplified but not unrealistic model of a quite Earth-like exoplanet.
"""
def __init__(self, n=8, alg='spline', mod='physical', tilt=5/13, cmax=2):
# Sun 26 Jul 2020 (created)
# Sat 1 Aug 2020 (updated)
"""
Create planet, given days/year and axial tilt or max night/day ratio.
The axial tilt is specified by its sine.
"""
self.n = n
self.alg = alg
self.mod = mod
if mod == 'physical':
self.tsin = tilt
expr = self.tsin**2
self.tcos = sqrt(1 - expr)
self.tcot = self.tcos/self.tsin
self.amax = 1/2 + atan(expr/sqrt(1 - 2*expr))/pi
elif mod == 'empirical':
self.cmax = cmax
self.amax = cmax/(cmax + 1)
else:
raise ValueError
self.f = []
for i in range(n):
if self.mod == 'physical':
ai = self.day_frac(i/n)
elif self.mod == 'empirical':
ai = 1/2 + (self.amax - 1/2)*sin(2*pi*i/n)
ci = (1 - ai)/ai
if alg == 'spline':
fi = spline(ci)
elif alg == 'hermite':
fi = hermite(ci)
else:
raise ValueError
self.f.append(fi)
def day_frac(self, x, tolerance=.000001):
# Fri 31 Jul 2020 (created)
# Sat 1 Aug 2020 (updated)
"""
Compute daylight fraction of cycle as a function of time of year.
Assumes the planet was created with the parameter mod='physical'.
"""
sin2pix = sin(2*pi*x)
if fabs(sin2pix) < tolerance: # near an equinox
return 1/2
else:
expr = self.tcot - sqrt(self.tcot**2 - sin2pix**2)
cos2pix = cos(2*pi*x)
t_X = expr/(1 + cos2pix)
t_Y = expr/(1 - cos2pix)
half_XY = (1 - t_X*t_Y)/(sqrt(1 + t_X**2)*sqrt(1 + t_Y**2))
a = asin(half_XY/self.tcos)/pi
if sin2pix > 0: # k < x < k + 1/2 for some integer k
return 1 - a
else: # k - 1/2 < x < k for some integer k
return a
def plot(self, xsz=12.0, ysz=3.0, N=50):
# Sun 26 Jul 2020 (created)
# Sun 26 Jul 2020 (updated)
"""
Plot the annual graph of temperature for this planet.
"""
plt.figure(figsize=(xsz, ysz))
args = np.linspace(0, 1, N, endpoint=False)
xvals = np.empty(self.n*N)
yvals = np.empty(self.n*N)
for i in range(self.n):
fi = self.f[i]
xvals[i*N : (i + 1)*N] = i + args
yvals[i*N : (i + 1)*N] = [sin(2*pi*fi.val(x)) for x in args]
plt.plot(xvals, yvals)
return plt.show()
def compare(self, xsz=8.0, ysz=6.0, N=600):
# Fri 31 Jul 2020 (created)
# Sat 1 Aug 2020 (updated)
"""
Plot the daylight fraction as a function of the time of year.
"""
plt.figure(figsize=(xsz, ysz))
plt.title(r'Annual variation of day length on tropic of Cancer, ' +
r'axial tilt $= {:.1f}^\circ$'.format(asin(self.tsin)*180/pi))
plt.xlabel('Time from Spring equinox')
plt.ylabel('Daylight fraction of cycle')
xvals = np.linspace(0, 1, N)
yvals = [self.day_frac(x) for x in xvals]
plt.plot(xvals, yvals, label='Physical model')
yvals = [1/2 + (self.amax - 1/2)*sin(2*pi*x) for x in xvals]
plt.plot(xvals, yvals, label='Sine function')
plt.legend()
return plt.show()
class hermite(object):
# Sun 26 Jul 2020 (created)
# Sun 26 Jul 2020 (updated)
"""
Hermite interpolation function.
"""
def __init__(self, c=1):
# Sun 26 Jul 2020 (created)
# Sun 26 Jul 2020 (updated)
"""
Create Hermite interpolation function with parameter c.
"""
self.c = c
self.a = 1/(c + 1)
self.p = 1/2 - self.a
self.b = inf if self.p == 0 else 1/2 + 1/(20*self.p)
self.d = 5*self.a*self.b/2 # == inf if c == 1
self.q = self.a*(1 - self.a)
self.coef = 4*self.p**2/self.q**3
def val(self, x):
# Sun 26 Jul 2020 (created)
# Sun 26 Jul 2020 (updated)
"""
Compute Hermite interpolation function at point x.
"""
if self.c == 1:
return x
else:
return x + self.coef*(x*(1 - x))**2*(self.d - x)
def deriv(self, x):
# Sun 26 Jul 2020 (created)
# Tue 28 Jul 2020 (updated)
"""
Compute derivative of Hermite interpolation function at point x.
"""
if self.c == 1:
return 1
else:
return 1 + 5*self.coef*x*(1 - x)*(x - self.a)*(x - self.b)
def plot(self, xsz=12.0, ysz=7.5, N=50):
# Sun 26 Jul 2020 (created)
# Sun 26 Jul 2020 (updated)
"""
Plot Hermite interpolation function.
"""
plt.figure(figsize=(xsz, ysz))
xvals = np.linspace(0, 1, N, endpoint=False)
yvals = np.array([self.val(x) for x in xvals])
plt.plot(xvals, yvals)
return plt.show()
class spline(object):
# Tue 28 Jul 2020 (created)
# Tue 28 Jul 2020 (updated)
"""
Cubic spline interpolation function
"""
def __init__(self, c=1):
# Tue 28 Jul 2020 (created)
# Tue 28 Jul 2020 (updated)
"""
Create cubic spline interpolation function with parameter c.
"""
self.c = c
self.a = 1/(c + 1)
self.p = 1/2 - self.a
self.coef0 = self.p/self.a**3
self.coef1 = self.p/(1 - self.a)**3
def val(self, x):
# Tue 28 Jul 2020 (created)
# Tue 28 Jul 2020 (updated)
"""
Compute cubic spline interpolation function at point x.
"""
if self.c == 1:
return x
elif x <= self.a:
return x + self.coef0*x**2*(3*self.a - 2*x)
else:
return x + self.coef1*(1 - x)**2*(1 - 3*self.a + 2*x)
def deriv(self, x):
# Tue 28 Jul 2020 (created)
# Tue 28 Jul 2020 (updated)
"""
Compute derivative of cubic spline interpolation function at point x.
"""
if self.c == 1:
return 1
elif x <= self.a:
return 1 + 6*self.coef0*x*(self.a - x)
else:
return 1 + 6*self.coef1*(1 - x)*(x - self.a)
def plot(self, xsz=12.0, ysz=7.5, N=50, start=0, stop=1):
# Sun 26 Jul 2020 (created, for class 'hermite')
# Sun 26 Jul 2020 (updated)
# Tue 28 Jul 2020 (copied - too lazy to create abstract base class!)
# Tue 28 Jul 2020 (improved - haven't bothered to improve 'hermite')
"""
Plot cubic spline interpolation function.
"""
plt.figure(figsize=(xsz, ysz))
xvals = np.linspace(start, stop, N, endpoint=False) # A bit naughty!
yvals = np.array([self.val(x) for x in xvals])
plt.plot(xvals, yvals)
return plt.show()
def main():
# Sun 26 Jul 2020 (created)
# Sat 1 Aug 2020 (updated)
"""
Function to exercise the module.
"""
planet(alg='hermite', mod='empirical', cmax=3/2).plot()
planet(alg='spline', mod='empirical', cmax=5/2).plot()
dat = planet(tilt=3/5)
dat.plot()
dat.compare()
if __name__ == '__main__':
main()
# end diurnal.py
Here is a graph of annual temperature variation for a planet with an $8$-day year and a maximum night-to-day ratio of $2$ to $1,$ obtained using Hermite interpolation:

and here is a graph for the same planet using cubic spline interpolation:

It is amusing and instructive to make an animation out of the two images -
it looks for all the world as if the cubic spline function is correcting
the silly mistakes made by the Hermite interpolation function!
Now to inject at least a little bit of physical realism.
Turning the clock of science back a couple of thousand years, let us
consider a perfectly spherical planet orbiting a distant star in a
perfect circle at a constant speed. For the sake of simplicity,
without sacrificing too much realism, let the planet's
axial tilt, the angle between
its polar axis and the normal to the ecliptic (orbital plane), be
$$
\sin^{-1}\left(\frac5{13}\right) \bumpeq 22.6^\circ.
$$
Consider a denizen of the planet who, fortunately for us (if not for
him, her, or it!), lives on a circle of latitude that intersects the
ecliptic. (There is no reason for this. It just makes the equations
more tractable. It's a fictional planet, so we're free to idealise,
so long as we do not abandon physical realism altogether. Since
starting to write this answer, I have learned from Wikipedia that
this circle of latitude is what could be called the planet's
"tropic of Cancer".)
Take that point of intersection, $M,$ as $[1, 0, 0]$ in a system of
spherical polar coordinates [there are several such systems;
it will soon be clear which one I'm using]
$[r, \theta, \phi]$ for the planet,
whose radius is taken as the unit of length, and whose rotation is
ignored, i.e., one should think of the planet as rotating within an
invisible spherical shell, upon which is the "fixed" point $M.$
(One can even think of the star as orbiting the planet, i.e.,
orbiting the "fixed" shell; it makes no difference.) The angle
between the polar axis, $SN,$ and the ecliptic is
$$
\alpha = \cos^{-1}\left(\frac5{13}\right) \bumpeq 67.4^\circ,
$$
so the North pole is
$$
N = [1, 0, \alpha],
$$
and another point on our friend's circle of latitude (as we shall
check later) is
$$
Q = [1, \pi, \pi - 2\alpha] \bumpeq [1, 180^\circ, 45.2^\circ].
$$

In Cartesian coordinates, the North pole $N$ is
$$
\mathbf{n} = (\cos\alpha, 0, \sin\alpha),
$$
and the point $M$ is
$$
\mathbf{m} = (1, 0, 0).
$$
A general point on the planet's surface with Cartesian coordinates
$$
\mathbf{p} = (x, y, z) =
(\cos\phi\cos\theta, \, \cos\phi\sin\theta, \, \sin\phi)
$$
lies on the same circle of latitude as $M$ iff
$$
\mathbf{p}\cdot\mathbf{n} = \mathbf{m}\cdot\mathbf{n},
$$
i.e., iff
\begin{equation}
\label{3766767:eq:1}\tag{$1$}
\boxed{\cos\phi\cos\theta\cos\alpha + \sin\phi\sin\alpha =
\cos\alpha.}
\end{equation}
We easily check that $Q$ lies on the circle:
$$
\cos(\pi - 2\alpha)\cos\pi\cos\alpha +
\sin(\pi - 2\alpha)\sin\alpha =
\cos2\alpha\cos\alpha + \sin2\alpha\sin\alpha = \cos\alpha.
$$
With our convenient choice of $\alpha,$ \eqref{3766767:eq:1} becomes
\begin{equation}
\label{3766767:eq:2}\tag{$2$}
5\cos\phi\cos\theta + 12\sin\phi = 5.
\end{equation}
As the planet orbits the faraway star, the terminator between light
and darkness is (because the star is, for this purpose,
considered to
be effectively at infinity) a great circle, consisting of two great
semicircles [I don't know if that's a term], each of whose equations
in spherical polar coordinates is of the form $\theta =$ constant,
the "constant" value changing with constant angular velocity. Our
first need is to solve \eqref{3766767:eq:2} for $\phi$ in terms of
$\theta$ (to determine the moments of dusk and dawn, so to speak).
We already know that $\phi = 0$ when $\theta = 0$ (at point $M$),
and $\phi = \pi - 2\alpha$ when $\theta = \pi$ (at point $Q$).
We'll have to be careful about the ranges of values of spherical
polar coordinates $[\theta, \phi].$ (I haven't been explicit so
far.) That said, I don't think we need to fuss too much about the
values of $\theta$; just take everything modulo $2\pi,$ giving an
informal preference to the interval $(-\pi, \pi]$ when a definite
real value is required. However, we must insist that
$-\frac\pi2 < \phi < \frac\pi2.$ (This excludes the point $M$ and
its antipodal point, neither of which has a definite value of the
azimuthal angle $\theta.$) Because our circle of latitude (the
"tropic of Cancer") lies entirely above the ecliptic, we should
always find that $0 \leqslant \phi < \frac\pi2.$
The radius of the circle of latitude (in space, ignoring
the sphere on which it lies) is $\sin\alpha.$ It lies in a plane
whose inclination to the ecliptic is $\tfrac\pi2 - \alpha.$ Looking
down on the ecliptic from far above the point $P = (0, 0, 1)$
(itself above the planet's centre $O = (0, 0, 0),$ lying on the
ecliptic), we therefore see the circle of latitude as an ellipse
with semi-major axis $\sin\alpha$ and semi-minor axis
$\sin^2\alpha$:

The solution of \eqref{3766767:eq:2} (see solution of
\eqref{3766767:eq:1} below) is:
$$
\phi = 2\tan^{-1}\left(
\frac{12 - \sqrt{144 - 25\sin^2\theta}}{5 + 5\cos\theta}\right)
\quad (0 \leqslant \theta < \pi).
$$
The limit of this expression as $\theta \to \pi{-}$ is (not obviously!)
$$
2\tan^{-1}\left(\frac5{12}\right) =
\pi - 2\tan^{-1}\left(\frac{12}5\right) = \pi - 2\alpha,
$$
which is as it should be.
Here is a graph from Wolfram Alpha, showing latitude, $\phi,$ as a function of longitude, $\theta,$ on the planet's "tropic of Cancer":

The centre, $C,$ of the circle of latitude has Cartesian coordinates
$$
\mathbf{c} = (\cos^2\alpha, 0, \cos\alpha\sin\alpha) =
\left(\frac{25}{169}, 0, \frac{60}{169}\right).
$$
Two unit vectors orthogonal to each other and to
$\mathbf{n} = (\cos\alpha, 0, \sin\alpha)$ are
$$
\mathbf{u} = (0, 1, 0), \quad
\mathbf{v} = \left(-\sin\alpha, 0, \cos\alpha\right) =
\left(-\frac{12}{13}, 0, \frac5{13}\right).
$$
The point $C$ and the unit vectors
$(\mathbf{u}, \mathbf{v}, \mathbf{n})$ therefore determine a
right-handed Cartesian coordinate system, in which a point with the
"usual" Cartesian coordinates $\mathbf{p} = (x, y, z)$ has the
"new" coordinates
$$
\left\langle u, v, w\right\rangle =
\left\langle
(\mathbf{p} - \mathbf{c})\cdot\mathbf{u}, \,
(\mathbf{p} - \mathbf{c})\cdot\mathbf{v}, \,
(\mathbf{p} - \mathbf{c})\cdot\mathbf{n}
\right\rangle.
$$
The circle of latitude is centred on the "new" origin $C,$ its
radius is $\sin\alpha,$ and it lies in the plane $w = 0.$ For
example, the point $M$ on the circle has the usual Cartesian
coordinates $\mathbf{m} = (1, 0, 0),$ therefore its "new"
coordinates are
\begin{multline*}
\mathbf{m'} = \left\langle 0, \,
(1 - \cos^2\alpha)(-\sin\alpha) +
(-\cos\alpha\sin\alpha)(\cos\alpha), \right. \\ \left.
(1 - \cos^2\alpha)(\cos\alpha) +
(-\cos\alpha\sin\alpha)(\sin\alpha)
\right\rangle = \left\langle 0, \, -\sin\alpha, \, 0 \right\rangle,
\end{multline*}
as one would expect. Similarly, the point $Q$ on the circle has the
usual Cartesian coordinates
$\mathbf{q} = (\cos2\alpha, 0, \sin2\alpha),$ therefore its "new"
coordinates are
\begin{multline*}
\mathbf{q'} = \left\langle 0, \,
(\cos2\alpha - \cos^2\alpha)(-\sin\alpha) +
(\sin2\alpha - \cos\alpha\sin\alpha)(\cos\alpha), \right. \\ \left.
(\cos2\alpha - \cos^2\alpha)(\cos\alpha) +
(\sin2\alpha - \cos\alpha\sin\alpha)(\sin\alpha)
\right\rangle = \left\langle 0, \, \sin\alpha, \, 0 \right\rangle,
\end{multline*}
which is also as expected.
An unexpectedly crucial role (not expected by me, anyway) is played
by the point $R$ where $MQ$ meets $OP.$ This point wasn't even marked
in the previous version of the diagram of the plane $OSNMCQRP.$ It is
now easily seen from that diagram that
$$
\|CR\| = \cos\alpha\cot\alpha = \frac{\cos^2\alpha}{\sin\alpha}.
$$
This gives another way to derive the coordinates of the points $K$
and $L$ in the $\left\langle u, v, w \right\rangle$ system.
We have a circle on a sphere. It is smaller than a great circle, so
that it has a well-defined "inside", i.e., the smaller of the two
connected components of its complement in the sphere. We have a
point $P$ inside the circle. (To ensure this, we require
$\alpha > \frac\pi4.$) A plane through $O$ and $P$ necessarily
intersects the circle in two points, $X$ and $Y,$ subdividing the
circle into two arcs.
With appropriate assumptions about orientation (I'm not going to
bother being explicit, and it would probably only be confusing to go
into detail), $X$ is the point of occurrence of dusk, and $Y$ is the
point of occurrence of dawn, on the imaginary planet's "tropic of
Cancer". The length of the day at that latitude (equal to the
planet's axial tilt), at this time of the year, is proportional to
the length of the clockwise arc of the circle of latitude going from
$X$ to $Y.$
Day and night are of equal length if and only if the plane of the
terminator, $OPXY,$ coincides with the plane $OSNMCQP,$ shown in the
first figure above. This is when either $X = M$ and $Y = Q$ (the
"Spring equinox" of the planet) or $X = Q$ and $Y = M$ (the
"Autumn equinox" of the planet). These are the cases
$\theta \equiv 0 \pmod{2\pi},$ and $\theta \equiv \pi \pmod{2\pi},$
respectively.
Let the plane through the polar (rotational) axis $SON$ normal to
the plane $OSNMCQP$ intersect the circle of latitude at points $K$
and $L.$ (Again, I'm assuming that it would be more confusing than
helpful to try to be explicit about orientation, and I trust that
the diagram suffices.)
The day is longest (this is the planet's "Summer solstice") when
$X = K$ and $Y = L,$ i.e., $\theta \equiv \frac\pi2 \pmod{2\pi}.$
The day is shortest (the "Winter solstice") when
$X = L$ and $Y = K,$ i.e., $\theta \equiv -\frac\pi2 \pmod{2\pi}.$
In the $\left\langle u, v, w\right\rangle$ coordinate system, the
coordinates of $K$ and $L$ respectively are (I omit the details
of the calculation):
\begin{align*}
\mathbf{k'} =
\left\langle
\frac{\sqrt{-\cos2\alpha}}{\sin\alpha}, \,
\frac{\cos^2\alpha}{\sin\alpha}, \,
0\right\rangle & = \left\langle
\frac{\sqrt{119}}{12}, \, \frac{25}{156}, \, 0\right\rangle, \\
\mathbf{l'} =
\left\langle
-\frac{\sqrt{-\cos2\alpha}}{\sin\alpha}, \,
\frac{\cos^2\alpha}{\sin\alpha}, \,
0\right\rangle & = \left\langle
-\frac{\sqrt{119}}{12}, \, \frac{25}{156}, \, 0\right\rangle.
\end{align*}
The length of the clockwise arc $LK,$ divided by the circumference
$2\pi\sin\alpha,$ is
$$
a_\text{max} = \frac12 + \frac1\pi\tan^{-1}\left(
\frac{\cos^2\alpha}{\sqrt{-\cos2\alpha}}\right) =
\frac12 + \frac1\pi\tan^{-1}\left(
\frac{25}{13\sqrt{119}}\right) \bumpeq 0.5555436,
$$
for the imaginary planet.
I wanted to check this result before going on to the more
complicated case of general $X$ and $Y.$ It ought to be at least
approximately valid for the Earth, even though the Earth's shape is
significantly non-spherical. The Earth's axial tilt at present is
$\tau \bumpeq 23.43662^\circ.$ Taking $\alpha = \frac\pi2 - \tau,$
we get
$$
a_\text{max} = \frac12 + \frac1\pi\tan^{-1}\left(
\frac{\sin^2\tau}{\sqrt{1 - 2\sin^2\tau}}\right)
\bumpeq 0.5601746,
$$
which works out at about 13 hours and 27 minutes. With (to me, at
least) surprising exactness, this figure is confirmed
here:

I neglected to prove the blindingly "obvious" fact that the
solstices occur just when
$$
\theta \equiv \pm\frac\pi2\pmod{2\pi}.
$$
Perhaps this is truly obvious. Nevertheless, it took me a while
to think of a proof: the lengths of the two arcs $XY$ are monotonic
functions of the length of the chord $XY,$ or alternatively its
distance from the centre $C,$ and, given that $XY$ passes through
the fixed point $R$ where $OP$ meets $MQ,$ the length of the chord
is minimised, and its distance from $C$ is maximised, when
$XY \perp MQ.$

It is now really obvious that we do not need to calculate the
coordinates of $X$ and $Y$ in the
$\left\langle u, v, w \right\rangle$ system, and it is enough just
to calculate the length $\|XY\|,$ which we can easily do in the old
$(x, y, z)$ system.
Recall \eqref{3766767:eq:1}:
$$
\cos\phi\cos\theta\cos\alpha + \sin\phi\sin\alpha = \cos\alpha.
$$
We may as well solve this in general terms, assuming only
$$
\frac\pi4 < \alpha \leqslant \frac\pi2.
$$
We know that $\phi$ satisfies the condition
$$
0 \leqslant \phi < \frac\pi2.
$$
Writing
$$
t = \tan\frac\phi2,
$$
we therefore have $0 \leqslant t < 1.$ The equation becomes
\begin{gather*}
(\cos\theta\cos\alpha)\frac{1 - t^2}{1 + t^2} +
(\sin\alpha)\frac{2t}{1 + t^2} = \cos\alpha, \\
\text{i.e.,} \quad
(\cos\alpha)(1 + \cos\theta)t^2 - 2(\sin\alpha)t
+ (\cos\alpha)(1 - \cos\theta) = 0.
\end{gather*}
When $\theta \equiv 0 \pmod{2\pi},$ the two solutions of the
quadratic equation are $0$ and $\tan\alpha > 1,$ so $t = 0.$
When $\theta \equiv \pi \pmod{2\pi},$ the equation is linear, with
the unique solution $t = \cot\alpha.$ Assume now that
$\theta \not\equiv 0 \pmod{2\pi}$ and
$\theta \not\equiv \pi \pmod{2\pi}.$ The solutions of the quadratic
equation are:
$$
t = \frac{\tan\alpha \pm \sqrt{\tan^2\alpha - \sin^2\theta}}
{1 + \cos\theta}.
$$
Both solutions are strictly positive. The larger of the two is at least:
$$
\frac{1 + \sqrt{1 - \sin^2\theta}}{1 + \cos\theta} =
\frac{1 + |\cos\theta|}{1 + \cos\theta}
\geqslant 1 > \tan\frac\phi2,
$$
therefore the only valid solution is
$$
\boxed{t_X = \frac{\tan\alpha - \sqrt{\tan^2\alpha - \sin^2\theta}}
{1 + \cos\theta},}
$$
where the subscript $X$ is used to distinguish this value from the
solution of the same equation with $\theta + \pi \pmod{2\pi}$ in
place of $\theta$, viz.:
$$
\boxed{t_Y = \frac{\tan\alpha - \sqrt{\tan^2\alpha - \sin^2\theta}}
{1 - \cos\theta}.}
$$
The Cartesian coordinates $(x, y, z)$ of the points $X$ and $Y$ are:
\begin{align*}
\mathbf{x} & = \left(
\frac{1 - t_X^2}{1 + t_X^2}\cos\theta, \,
\frac{1 - t_X^2}{1 + t_X^2}\sin\theta, \,
\frac{2t_X}{1 + t_X^2}
\right) \!, \\
\mathbf{y} & = \left(
\frac{1 - t_Y^2}{1 + t_Y^2}\cos\theta, \,
\frac{1 - t_Y^2}{1 + t_Y^2}\sin\theta, \,
\frac{2t_Y}{1 + t_Y^2}
\right) \!.
\end{align*}
After some heroic simplification, which I won't reproduce here, we get:
$$
\boxed{\|XY\| = \|\mathbf{x} - \mathbf{y}\| =
\frac{2(1 - t_Xt_Y)}{\sqrt{1 + t_X^2}\sqrt{1 + t_Y^2}}.}
$$
The relative simplicity of this result suggests that there is a simpler and more enlightening derivation than the one I found.
[There is indeed - see comment below.]
We check that it is valid in the two familiar
special cases, i.e., the equinoxes and solstices (even though the
latter were excluded during the above derivation).
When $\theta = 0,$ we have $t_X = 0$ and $t_Y = \cot\alpha,$
therefore $1 + t_Y^2 = 1/\sin^2\alpha,$ therefore
$\|XY\| = 2\sin\alpha = \|MQ\|,$ as expected.
When $\theta = \frac\pi2,$ we have $\phi_X = \phi_Y,$ so we can
drop the subscripts. Directly from \eqref{3766767:eq:1}, we have
$\sin\phi = \cot\alpha,$ whence:
$$
\|XY\| = 2\frac{1 - t^2}{1 + t^2} = 2\cos\phi =
2\sqrt{1 - \cot^2\alpha} = 2\frac{\sqrt{-\cos2\alpha}}{\sin\alpha} =
\|KL\|,
$$
which is also as expected.
The length of the clockwise arc $XY,$ expressed as a fraction of the
length of the circumference of the circle, is:
$$
\boxed{a = \begin{cases}
1 - \frac1\pi\sin^{-1}\frac{\|XY\|}{2\sin\alpha}
& (0 \leqslant \theta \leqslant \pi), \\
\frac1\pi\sin^{-1}\frac{\|XY\|}{2\sin\alpha}
& (\pi \leqslant \theta \leqslant 2\pi).
\end{cases}}
$$
This function is implemented in the Python code above. Here is a
log of the commands used to generate the graphs below:
>>> from math import pi, sin
>>> tilt = sin(23.43662*pi/180)
>>> tilt
0.39773438277624595
>>> from maths import diurnal
>>> earth = diurnal.planet(tilt=tilt)
>>> earth.amax
0.5601746469862512
>>> 60*(24*earth.amax - 13)
26.651491660201714
>>> earth.compare()
>>> zargon = diurnal.planet(tilt=3/5)
>>> zargon.amax
0.6901603684878477
>>> zargon.compare()
This graph is for the Earth's tropic of Cancer:

This graph is for the "tropic of Cancer" of an imaginary planet whose
axial tilt is $\sin^{-1}\frac35 \bumpeq 36.9^\circ$:
