Least squares view on the linear quadratic regulator

One day of a math-oriented programmer or how I read wiki

— Hi, my name is %username and I secretly disclose the brackets in sums expressed in sigma notation to understand what is happening.
— Hi %username!

I have few students who want to implement a segway-style two-wheeled balancing robot like the one I have shown few posts ago:

They thought to use a PID regulator, but failed to find good coefficients and came to ask for a help. I am not an expert in the control theory, however I saw a guy to mention that he failed with PID, but that LQR worked out for him. So I took my time to document me on the LQR, and I wanted to explain to you whait I learned. It is also a good opportunity to show you how I read math text, it is a major part of my work. This page does NOT explain how to build balancing bots, it is an introduction to LQR. I suppose that you have a basic understanding of least squares, for example, read this page.

Read the rest here.

My original post in Russian is available here.