lines 162-229 of file: xrst/algorithm.xrst {xrst_begin llsq_obj} Linear Least Squares Objective ############################## Function ******** .. math:: y(x) = \frac{1}{2} \sum_{i=0}^{n-1} \left( s_i - x_0 - x_1 t_i - x_2 t_i^2 - \cdots \right)^2 where *s* and *t* in :math:`{\bf R}^n` are given by: .. math:: t_i & = -1 + i * 2 / (n - 1) \\ s_i & = \mathrm{sign} ( t_i ) = \cases{ -1 & if $t_i < 0$ \\ 0 & if $t_i = 0$ \\ +1 & if $t_i > 0$ } Vector Operations ***************** The calculation of this objective can be vectorized with respect to the index *j* above. The intent is to enable AD packages that have vector operators to use them reduce memory and speed up the calculation of derivatives. option ****** This algorithm uses the ``n_arg`` and ``n_other`` options; see below: n_arg ===== This is the size of the vector *x* above . There is an assert checking that *n_arg* > 0. n_other ======= This is the size of the vector *t* above . There is an assert checking that *n_other* > 0. Implementation ************** :ref:`cpp_llsq_obj-name` , :ref:`py_llsq_obj-name` . Derivative ********** The partial derivative of :math:`y(x)` with respect to :math:`x_j` is .. math:: \frac{ \partial y(x)} { \partial x_j } = - \sum_{i=0}^{n-1} \left( s_i - x_0 - x_1 t_i - x_2 t_i^2 - \cdots \right) t_i^j {xrst_end llsq_obj}