You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: are.m
    path of file: ./repos/MataveControl/matave/+mc
    
    the code of the file until where you have to start completion: % Solve Algebraic Riccati Equation
% Input: sys(State space model for A,B,C,D), Q(Hermitian and same size as A), R(Hermitian and same size as columns of B)
% Input: S(Same rows as A and same columns as B), E(Hermitian and same size as A), G(Hermitian and continuo
    
function [value, isterminal, direction] = dare(t, X, A, B, Q, R, S, E)

  X = reshape(X, size(A)); % Vector -> Matrix
  value = A'*X*A - E'*X*E - (A'*X*B + S)*((B'*X*B + R)\(A'*X*B + S)') + Q; % Value is the derivative of X
  value = value(:); % Matrix -> Vector

  isterminal = 1;
  direction = 0;
end