Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a generic function: $g(s,u)$. Now I want to have a local approximation near the point $(s^{\star}, u^{\star})$ in the quadratic form $$s^{T} Q s + u^{T} R u$$ to apply an optimal control algorithm named LQR. I have to apply a second order Taylor expansion which will result in $$g(s^{\star}, u^{\star}) + g_s(s^{\star}, u^{\star})(x-x^{\star}) + g_u(s^{\star}, u^{\star})(u-u^{\star}) + \frac{1}{2} \left[g_{ss}(s^{\star}, u^{\star})(s-s^{\star})^2 + g_{su}(s^{\star}, u^{\star})2(s-s^{\star})(u-u^{\star}) + g_{uu}(s^{\star}, u^{\star})(u-u^{\star})^2 \right]$$

Now my question is which partial derivatives form the matrices $Q$ and $R$.

I know how to derive this matrices for an example with one variable, then $$\frac{1}{2} x^T Q x + x^T q + q_0$$ can be written as $$\begin{bmatrix}s \\ 1\end{bmatrix}^T \begin{bmatrix}Q & q \\ q^T & q_0\end{bmatrix} \begin{bmatrix}s \\ 1\end{bmatrix}$$ which is a quadratic form. But how to do this with two variables?

share|cite|improve this question
Rephrased the question here:… – Derk Sep 17 '12 at 16:14

What you're doing makes no sense. I assume that $g : \mathbb{R}^n \times \mathbb{R}^m \to \mathbb{R}$. The local approximation of $g$ at $(s^*,u^*)$ should not be a quadratic form

$$ g (s, u) \approx s^T Q s + u^T R u$$

but rather a quadratic polynomial, the 2nd order Taylor approximation of $g$, which is

$$g (s,u) \approx g (s^*, u^*) + q^T (s - s^*) + r^T (u - u^*) + (s - s^*)^T Q (s - s^*) + (u - u^*)^T R (u - u ^*)$$

If $g (s^*, u^*) = 0$, $q = 0_n$, and $r = 0_m$, then $(s^*, u^*)$ is a local minimum and you obtain a quadratic form as a local approximation

$$g (s,u) \approx (s - s^*)^T Q (s - s^*) + (u - u^*)^T R (u - u ^*)$$

share|cite|improve this answer
Thanks for your answer, but unfortunately I think this is not completely what I'm looking for. What I'm trying to do is implementing the iterative LQR algorithm as explained by Abbeel in his course on Advanced Robotics. He gives a derivation for the Q matrix by augmenting the state (see… at 19:50). Can you do the same for the R matrix or not? And if you can, where does the mixed derivative stay? – Derk Sep 12 '12 at 17:07
@Derk: what does the local approximation have to do with LQR? Or is your cost function $g$, and you're trying to obtain a quadratic approximation to use LQR? If that is the case, then $r$ and $s$ will contain the 1st order partial derivatives, and $R$ and $Q$ will contain the 2nd order partial derivatives. – Rod Carvalho Sep 12 '12 at 19:45
Yes, $g$ is my cost function for which I want to obtain a quadratic approximation. Is $Q$ equal to $g_{ss}$? And $R$ to $g_{uu}$? And what to do with $g_{su}$? – Derk Sep 13 '12 at 12:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.