%% Reduce DAE System by Removing Redundant Equations
% Simplify a system of five differential algebraic equations (DAEs) in four state variables to a system of two equations in two state variables.
% Create the following system of five DAEs in four state variables x1(t), x2(t), x3(t), and x4(t). The system also contains symbolic parameters a1, a2, a3, a4, b, c, and the function f(t) that are not state variables.

syms x1(t) x2(t) x3(t) x4(t) a1 a2 a3 a4 b c f(t)
eqs = [a1*diff(x1(t),t)+a2*diff(x2(t),t) == b*x4(t),
       a3*diff(x2(t),t)+a4*diff(x3(t),t) == c*x4(t),
       x1(t) == 2*x2(t),
       x4(t) == f(t),
       f(t) == sin(t)];
vars = [x1(t),x2(t),x3(t),x4(t)];

% Use reduceRedundancies to eliminate redundant equations and corresponding state variables.

[newEqs,newVars] = reduceRedundancies(eqs,vars)

%
% Copyright 2014 The MathWorks, Inc.