function [f,v] = dlqrschurg(a,b,q,r) % %DLQRSCHURG Discrete linear quadratic regulator solution % [f,v] = dlqschurg(a,b,q,r) solves the Riccati equation % associated with the real discrete time optimal linear regulator % problem of the form % % min sum {x'qx + u'ru} % st x(t+1) = ax(t) + bu(t) % % Returned are the matrices f and v such that the optimal decision rule % is -fx and the value function is x'vx % % ALGORITHM: Generalized Schur (without balancing) % REFERENCES: Anderson, Hansen, McGrattan and Sargent (1995) % Pappas, Laub and Sandel (1980) % PROGRAM WRITTEN BY: Evan W. Anderson December 1, 1994 %Get the ordered generalized schur decomposition of (L,N) tol = 1e-15; n=size(a,1); [U,LBAR,NBAR,alpha,beta,info] = schurg([eye(n) (b/r)*b'; zeros(n) a'], ... [a zeros(n); -q eye(n)],0,0,tol); %Calculate the solution to the Riccati equation and the optimal % decision rule. v = U(n+1:2*n,1:n)/U(1:n,1:n); f = (b'*v*b + r)\b'*v*a;