Optimal observation and control in linear systems