As we physically push an analog-trigger downwards from resting position to fully depressed, we expect to observe a continuously increasing input from 0 \rightarrow 1. If we are applying a sensitivity curve to our raw-input, we should make sure that our curve does not break this property. If we denote our curve by s: [0,1] \rightarrow [0,1], we want s to be continuous, surjective (onto), and monotone-increasing. In my recent post about analog inputs, I discuss how to define s by a cubic polynomial.
s(x) = c_3 x^3 + c_2 x^2 + c_1 x + c_0
Given that s is a polynomial, our constraints are equivalent to ensuring s(0)=0, s(1)=1, and that there are no local extrema in the interval [0,1]. We seek to describe the coefficients c_i that satisfy these constraints. In the post I simply stated the results. In this blurb we will perform the derivation.
Generally speaking, an n\mathtt{th} degree polynomial will uniquely fit n+1 given points. Since we are only specifying two points (0,0) and (1,1), we expect two degrees of freedom in our coefficients (constrained by monotonicity). Indeed, our fixed points imply
c_0 = 0 \\ c_3 + c_2 + c_1 = 1
As a matter of choice, we will take c_1 = 1- c_3 - c_2 and try to find the region in the c_3 c_2-plane that yields monotonicity. A curve takes on local extrema only when its slope is zero and its change in slope is nonzero, that is when s'(x) = 0 and s''(x) \neq 0. Plugging in c_1 and taking the derivatives we have
\newcommand{\uminus}{\raise.17ex\hbox{$\scriptstyle{-}$}} \begin{array}{lll} s(x) \; &= & \; c_3 \, x^3 + c_2 \, x^2 + (1-c_3-c_2) \, x \\ s'(x) \; &= & \; 3 c_3 \, x^2 + 2 c_2 \, x + (1 - c_3 - c_2) \\ s''(x) \; &= & \; 2 \, (3 c_3 \, x + c_2) \end{array}
\begin{align} s'(x) = 0 \quad \quad & \text{when} \quad \quad x_{\pm} := \frac{\uminus c_2 \pm \sqrt{c_2^2 + 3c_3c_2 + 3c_3\,(c_3-1)}}{3\,c_3} \\ \\ s''(x) = 0 \quad \quad & \text{when} \quad \quad x = \frac{\uminus c_2}{3\,c_3} \end{align}
Letting \theta denote the portion inside the \mathtt{sqrt}, that is \theta = c_2^2 - 3 c_3 c_1 , we notice that \theta = 0 gives us an inflection while \theta < 0 means s has no real stationary points (or extrema). So the region \theta \leq 0 is allowed and is shown below.
The blue region is bounded by \theta = 0, explicitly represented by two curves \gamma_\pm = \tfrac{1}{2} \left(\uminus 3c_3 \pm \sqrt{3c_3 ( 4- c_3)}\right), where \gamma_+ is shown in pink and \gamma_- is shown in yellow. These curves meet with vertical slope at (0,0) and (4,-6). Before we continue we realize that we must have a nonnegative slope at x=0 and x=1. This bounds the allowable c_2 c_3-region by the two lines shown below.
Indeed the \theta \leq 0 falls within such bounds. When \theta > 0 our curve s will have two extremum at x_\pm. Our coefficients c_2, c_3 are allowed when neither x_\pm lie within (0,1). This can be broken up into the following regions.
\begin{array}{llll} \mathtt{(i)} \quad & (c_3 < 0) \; \cap \; (x_- \leq 0) \\ \mathtt{(ii)} \quad & (c_3 < 0) \; \cap \; (x_+ \geq 1) \\ \mathtt{(iii)} \quad & (c_3 < 0) \; \cap \; (x_+ \leq 0) \; \cap \; (x_- \geq 1) \\ \mathtt{(iv)} \quad & (c_3 > 0) \; \cap \; (x_+ \leq 0) \\ \mathtt{(v)} \quad & (c_3 > 0) \; \cap \; (x_- \geq 1) \\ \mathtt{(vi)} \quad & (c_3 > 0) \; \cap \; (x_- \leq 0) \; \cap \; (x_+ \geq 1) \\ \end{array}
The regions \mathtt{(i)} = \mathtt{(ii)} = \mathtt{(vi)} = \emptyset. Putting this all together we have
I was interested in what the three dimensional region looks like for quartics. Even with a symbolic algebra manipulator the equations quickly became unwieldy (roots of a cubic are not so simple), so the following scatterplot is empirical. The resulting region in c_4 c_3 c_2-space looks like a twisted surfboard.
The approximate bounds are c_4 \in [\uminus 9,9], c_3 \in [\uminus 16.48,20.39], c_2 \in [\uminus 16.11, 9], c_1 \in [0,6]. The white specks are the projected "shadow" onto the graph's walls. The cross-sections c_4 = \alpha are shown below. The purple region c_4=0 is exactly what we had found for cubics. Because the coefficients c_i are related by the relation c_1 + c_2 + c_3 + c_4 = 1, we get similar contours for each.
No comments:
Post a Comment