We consider two modelling problems, one arising in control theory (linear-quadratic regulator) and one arising in the modelling of queues (or buffers) under a continuous-time Markov model. The solution of both can be reduced to finding the invariant subspace of a suitable structured matrix, or equivalently solving a Riccati-like matrix equation. I will present linear algebra tools that can be used to solve them accurately; in particular: * a QR-like matrix factorization in which a tall skinny n x m matrix is factored as U*R, where R is m x m square invertible and U has a m x m identity submatrix and all its other entries bounded in modulus by 1. This factorization can be formulated as an optimization problem (maximum volume submatrix) or as finding a suitable set of basic variables in a tableau. * (if time allows) a numerical method for the Markov problem based on a technique (GTH method) to solve linear systems with a (possibly ill-conditioned) M-matrix without subtractions, obtaining high accuracy in both large and small entries of the solution.