I am exploring the math of smooth motion. I have everything sorted out for zero through four degrees of smoothness, but I'm stuck on some of the transition-time values for the fifth degree of smoothness.
Basic Setup
I am creating sets of piecewise polynomials describing an object's displacement-over-time $d_n(t)$ and derivatives thereof. For $n$ degrees of smoothness, there are $n + 1$ piecewise polynomials, each with $2^n + 1$ segments (counting the stationary segments before motion begins and after motion ends), thus giving $2^n$ transition times between segments.
For the five-smooth case, consider an object that starts stationary at the origin ($d = 0$), begins moving at time $t = T_{5,00}$, reaches some displacement $d = d_{max}$ from the origin at time $t = T_{5,31}$, and then becomes stationary once more. Constraints on the object's motion are:
- a maximum allowed velocity $v_{max}$ (first derivative of displacement);
- a maximum allowed absolute value of acceleration $a_{max}$ (second derivative of displacement);
- a maximum allowed absolute value of jerk $j_{max}$ (third derivative of displacement);
- a maximum allowed absolute value of snap $s_{max}$ (fourth derivative of displacement);
- a maximum allowed absolute value of crack $c_{max}$ (fifth derivative of displacement);
- $T_{5,31} − T_{5,00}$, the time taken to reach $d_{max}$ after motion begins, is minimized;
- the functions $d_5(t)$, $v_5(t)$, $a_5(t)$, $j_5(t)$, $s_5(t)$, and $c_5(t)$ are piecewise polynomials that transition between segments at times $t = T_{5,k}$ for integer $0 ≤ k ≤ 31$;
- the functions $v_5(t)$, $a_5(t)$, $j_5(t)$, $s_5(t)$, and $c_5(t)$ are all equal to zero for $t < T_{5,00}$ and $T_{5,31} < t$; and
- the functions $d_5(t)$, $v_5(t)$, $a_5(t)$, $j_5(t)$, and $s_5(t)$ are continuous
giving five degrees of smoothness to the motion (the graphs of displacement-over-time, velocity-over-time, acceleration-over-time, jerk-over-time, and snap-over-time are continuous, but the graph of crack-over-time is discontinuous).
All six motion functions are shown in the following image, with the displacement and velocity functions scaled vertically so they fit in the same view as the other four:
Helper Variables (and the Unknowns)
Given values for $c_{max}$, $s_{5,limit}$, $j_{5,limit}$, $a_{5,limit}$, $v_{5,limit}$, and $d_{max}$ (the "limit" variables are defined in the "Limit Values" section below), we define the following variables for future conciseness:
- $a := \frac{s_{5,limit}}{c_{max}}$
- $b := \frac{j_{5,limit}}{s_{5,limit}}$
- $c := \frac{a_{5,limit}}{j_{5,limit}}$
- $d := \frac{v_{5,limit}}{a_{5,limit}}$
- $e := \frac{d_{max}} {v_{5,limit}}$
From these we define the following width values:
- $α := a$
- $β := b − a$
- $γ := c − b − a$
- $δ := \begin{cases} α & : a + b + c ≤ d \\ ε + α & : \text{otherwise} \end{cases}$
- $ε := d − c − b − a$
- $W := \begin{cases} γ & : a + b + c + d ≤ e\\ ??? & : \text{otherwise} \end{cases}$
- $X := \begin{cases} α & : a + b + c + d ≤ e \\ ??? & : \text{otherwise} \end{cases}$
- $Y := \begin{cases} β & : a + b + c + d ≤ e \\ ??? & : \text{otherwise} \end{cases}$
- $Z := \begin{cases} e − d − c − b − a & : a + b + c + d ≤ e \\ ??? & : \text{otherwise} \end{cases}$
The unknown values which I'm stuck on are $W$, $X$, $Y$, and $Z$ when $e < a + b + c + d$.
What is Known About the Unknown Values
There are 31 coefficient functions (all defined in the "Polynomial Coefficient Functions" section below) with the final function, $f_{5,31}(n)$, being the most pertinent as it gives the values of the constant segments at the end of the object's motion — values which we already know from the constraints in the "Basic Setup" section.
Expanding the variables in that function as far as possible gives:
$$ \begin{align} f_{5,31}(n) = \frac{1}{n!} &× (\\ &+ (2×a + 2×b + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &− ( a + 2×b + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &− (2×a + b + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &+ ( a + b + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &− (2×a + 2×b − c + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &+ ( a + 2×b − c + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &+ (2×a + b − c + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &− ( a + b − c + 2×d + 2×W + 4×X + 2×Y + Z)^n\\ &− (2×a + 2×b + d + 2×W + 4×X + 2×Y + Z)^n\\ &+ ( a + 2×b + d + 2×W + 4×X + 2×Y + Z)^n\\ &+ (2×a + b + d + 2×W + 4×X + 2×Y + Z)^n\\ &− ( a + b + d + 2×W + 4×X + 2×Y + Z)^n\\ &+ ( a + b + d + W + 4×X + 2×Y + Z)^n\\ &− ( a + b + d + W + 3×X + 2×Y + Z)^n\\ &− ( a + b + d + W + 3×X + Y + Z)^n\\ &+ ( a + b + d + W + 2×X + Y + Z)^n\\ &− ( a + b + d + W + 2×X + Y)^n\\ &+ ( a + b + d + W + X + Y)^n\\ &+ ( a + b + d + W + X)^n\\ &− ( a + b + d + W)^n\\ &+ ( a + b + d)^n\\ &− ( b + d)^n\\ &− ( a + d)^n\\ &+ ( d)^n\\ &+ ( a + b + c)^n\\ &− ( b + c)^n\\ &− ( a + c)^n\\ &+ ( c)^n\\ &− ( a + b)^n\\ &+ ( b)^n\\ &+ ( a)^n\\ ) \end{align} $$
Based on the constraints established in the "Basic Setup" section above, and the equations in the "Motion Equations" section below, we know that $f_{5,31}(1)$, $f_{5,31}(2)$, $f_{5,31}(3)$, and $f_{5,31}(4)$ should all equal zero, while $f_{5,31}(5) × c_{max}$ should equal $d_{max}$. Rearranging that last one to also equal zero and to use our conciseness variables gives $f_{5,31}(5) − (a × b × c × d × e) = 0$.
It is not hard to check that $f_{5,31}(1) = f_{5,31}(2) = 0$ for all valid input values, so we get no information from those.
$f_{5,31}(3)$ expands into
$$ X × (X + Y) × (2 × X + Y + Z) − a × b × (a + b − 2 × c + 2 × W + 4 × X + 2 × Y + Z) $$
so we know we need to set that equal to zero.
$f_{5,31}(4)$ expands into $\left(a + b + d + W + 2×X + Y + \frac{Z}{2}\right) × f_{5,31}(3)$, which as far as I can tell gives us no useful information because the left term is being multiplied by something we know is equal to zero.
$f_{5,31}(5) − (a × b × c × d × e)$ expands into a very long expression which I haven't been able to simplify much:
$$ \frac{1}{12}\,×\,\left( \left(6 × \left(a + b + d + \frac{1}{2} × (2 × W + 4 × X + 2 × Y + Z)\right)^2 + \frac{1}{2} × (X^2 + (X + Y)^2 + (2 × X + Y + Z)^2) − 10 × a × b\right) × f_{5,31}(3) − a × b × (a + b − 2 × c) × \left(\frac{3}{2} × (2 × W + 4 × X + 2 × Y + Z)^2 − \frac{1}{2} × (X^2 + (X + Y)^2 + (2 × X + Y + Z)^2)\right) − a × b × \left(\frac{1}{2} × (2 × W + 4 × X + 2 × Y + Z)^3 - \frac{1}{2} × (2 × W + 4 × X + 2 × Y + Z) × (X^2 + (X + Y)^2 + (2 × X + Y + Z)^2) - 10 × X × (X + Y) × (2 × X + Y + Z)\right) − a × b × (2 × a^2 + 13 × a × b − 6 × a × c + 2 × b^2 − 6 × b × c + 6 × c^2 − 12 × c × d) × (2 × W + 4 × X + 2 × Y + Z) − a × b × (a + b)^3 + 4 × a × b × c × (a + b + c)^2 − 9 × a^2 × b^2 × (a + b − 2 × c) − 14 × a^2 × b^2 × c^2 × \left(\frac{1}{a} + \frac{1}{b}\right) + 12 × a × b × c × d × (a + b − c + d − e) \right) $$
It also contains a term that is multiplied by $f_{5,31}(3)$ and which thus should vanish, making the whole expression a bit shorter, but it's still a mess.
Taken all together, here are all the "knowns" I've been able to identify:
- $e < a + b + c + d$
- $T_{5,31} − T_{5,00} = 2 × (a + b + d) + 2 × W + 4 × X + 2 × Y + Z$ is minimized
- $f_{5,31}(3) = X × (X + Y) × (2 × X + Y + Z) − a × b × (a + b − 2 × c + 2 × W + 4 × X + 2 × Y + Z) = 0$
- $f_{5,31}(5) − (a × b × c × d × e) = \text{[long expression above]} = 0$
That's four "knowns", and we have four unknowns ($W$, $X$, $Y$, and $Z$), but I haven't been able to work out definitions for the unknowns given only two actual equations.
Do we have enough information to find exact definitions for $W$, $X$, $Y$, and $Z$? Are there any other "knowns" which might help that I've overlooked?
All the Background Details
Limit Values
For two or more degrees of smoothness, it is possible to have combinations of the "max" values where, for example, the distance to be covered is not high enough compared to the maximum allowed acceleration for the object to reach the full allowed velocity before it must begin decelerating to come to a smooth stop at the end of its trip. To account for this, we will define the function $\operatorname{Min}(n_1, n_2, ... n_k)$, which returns the input with the lowest value, and the function $\operatorname{Root}[f(x)]$, which returns the positive real solution to $f(x) = 0$, and with those functions we will define the following variables as the practical limits on their associated motion values:
(The roots are solvable with closed-form expressions, they just get very long very quickly, so I've omitted the full expressions for brevity.)
Transition Values
With the above helper variables, the transition $t$-values for each piecewise segment are as follows (with spacing added to highlight structure):
- $T_{5,01} := T_{5,00} + α$
- $T_{5,02} := T_{5,01} \quad \quad + β$
- $T_{5,03} := T_{5,02} + α$
- $T_{5,04} := T_{5,03} \quad \quad \quad \quad + γ$
- $T_{5,05} := T_{5,04} + α$
- $T_{5,06} := T_{5,05} \quad \quad + β$
- $T_{5,07} := T_{5,06} \quad \quad \quad \quad \quad \quad + δ$
- $T_{5,08} := T_{5,07} \quad \quad \quad \quad \quad \quad \quad \quad + |ε|$
- $T_{5,09} := T_{5,08} \quad \quad \quad \quad \quad \quad + δ$
- $T_{5,10} := T_{5,09} \quad \quad + β$
- $T_{5,11} := T_{5,10} + α$
- $T_{5,12} := T_{5,11} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + W$
- $T_{5,13} := T_{5,12} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + X$
- $T_{5,14} := T_{5,13} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + Y$
- $T_{5,15} := T_{5,14} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + X$
- $T_{5,16} := T_{5,15} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + Z$
- $T_{5,17} := T_{5,16} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + X$
- $T_{5,18} := T_{5,17} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + Y$
- $T_{5,19} := T_{5,18} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + X$
- $T_{5,20} := T_{5,19} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + W$
- $T_{5,21} := T_{5,20} + α$
- $T_{5,22} := T_{5,21} \quad \quad + β$
- $T_{5,23} := T_{5,22} \quad \quad \quad \quad \quad \quad + δ$
- $T_{5,24} := T_{5,23} \quad \quad \quad \quad \quad \quad \quad \quad + |ε|$
- $T_{5,25} := T_{5,24} \quad \quad \quad \quad \quad \quad + δ$
- $T_{5,26} := T_{5,25} \quad \quad + β$
- $T_{5,27} := T_{5,26} + α$
- $T_{5,28} := T_{5,27} \quad \quad \quad \quad + γ$
- $T_{5,29} := T_{5,28} + α$
- $T_{5,30} := T_{5,29} \quad \quad + β$
- $T_{5,31} := T_{5,30} + α$
Or, equivalently:
- $T_{5,01} := T_{5,00} + α$
- $T_{5,02} := T_{5,00} + α + β$
- $T_{5,03} := T_{5,00} + 2 α + β$
- $T_{5,04} := T_{5,00} + 2 α + β + γ$
- $T_{5,05} := T_{5,00} + 3 α + β + γ$
- $T_{5,06} := T_{5,00} + 3 α + 2 β + γ$
- $T_{5,07} := T_{5,00} + 3 α + 2 β + γ + δ$
- $T_{5,08} := T_{5,00} + 3 α + 2 β + γ + δ + |ε|$
- $T_{5,09} := T_{5,00} + 3 α + 2 β + γ + 2 δ + |ε|$
- $T_{5,10} := T_{5,00} + 3 α + 3 β + γ + 2 δ + |ε|$
- $T_{5,11} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε|$
- $T_{5,12} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W$
- $T_{5,13} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + X$
- $T_{5,14} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + X + Y$
- $T_{5,15} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + 2 X + Y$
- $T_{5,16} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + 2 X + Y + Z$
- $T_{5,17} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + 3 X + Y + Z$
- $T_{5,18} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + 3 X + 2 Y + Z$
- $T_{5,19} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + W + 4 X + 2 Y + Z$
- $T_{5,20} := T_{5,00} + 4 α + 3 β + γ + 2 δ + |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,21} := T_{5,00} + 5 α + 3 β + γ + 2 δ + |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,22} := T_{5,00} + 5 α + 4 β + γ + 2 δ + |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,23} := T_{5,00} + 5 α + 4 β + γ + 3 δ + |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,24} := T_{5,00} + 5 α + 4 β + γ + 3 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,25} := T_{5,00} + 5 α + 4 β + γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,26} := T_{5,00} + 5 α + 5 β + γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,27} := T_{5,00} + 6 α + 5 β + γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,28} := T_{5,00} + 6 α + 5 β + 2 γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,29} := T_{5,00} + 7 α + 5 β + 2 γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,30} := T_{5,00} + 7 α + 6 β + 2 γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
- $T_{5,31} := T_{5,00} + 8 α + 6 β + 2 γ + 4 δ + 2 |ε| + 2 W + 4 X + 2 Y + Z$
Polynomial Coefficient Functions
Using the transition times, we can define a set of functions $f_{5,k}(n)$ which give the $n$th coefficient in the $k$th polynomial segment (indexing from zero). Each function consists of differences of pairs of transition times, raised to the $n$th power, and added to or subtracted from the others in a pattern following the Thue–Morse sequence, all divided by $n$-factorial:
Motion Functions
Finally, with the transition times and the coefficients we can define the piecewise polynomials describing the object's motion:











