function [V, INFO] = riccati(A,B,Q,R,TOL,MAXIT,V0) % % RICCATI solves a Riccati equation by iteration % % [V INFO] = riccati(A,B,Q,R,TOL,MAXIT,V0) solves a Riccati equation % by iteration starting from the positive semi-definite matrix V0. % See dlqrriccati for a description of (A,B,Q,R). % % Iteration is stopped at iteration n when either n=maxit or when % % norm{V(n) - V(n-1)} <= tol* norm{V(n)} % % where norm is the matrix one norm. % The 2x1 vector info returns the number of iterations performed % in info(1). If info(2) =1 then the algorithm halted because of % an attempted inversion of a singular matrix. If info(2)=0 then % no singular matrices were encountered. % % If the MEX file is not available then the MATLAB commands in this % M-file are executed. (Note that in this M-file, singular matrices % are not checked for.) % % REFERENCES: % E.W. Anderson, L.P. Hansen, E.R McGrattan and T.J Sargent(1996) % % WRITTEN BY: Evan Anderson Feb 15, 1995 % MODIFIED: EWA Jan 19, 1999 for i=1:MAXIT, V = Q + A' * (V0 - V0 * B * ((R +B'*V0 *B) \ (B'* V0))) * A; if norm(V-V0,1) < TOL; break; end V0 = V; end; INFO =[i;0];