%  This is the two transistor amplifier problem of E. Hairer, C. Lubich, 
%  and M. Roche, The Numerical Solution of Differential-Algebraic Systems
%  by Runge-Kutta Methods, Lecture Notes in Math. #1409, Springer, Berlin,
%  1989.  It is solved in the form M*u' = f(t,u) with a mass matrix that is
%  not diagonal.  The mass matrix is treated as a sparse matrix to test the
%  capability.  Fig. 9.4 of HLR shows the solution on [0 0.2], but here it
%  is computed on [0 0.05] because the computation is less expensive and the
%  nature of the solution is clearly visible on the shorter interval.

% Copyright 1999, The MathWorks, Inc.

%  Hairer and Wanner's RADAU5 requires consistent initial conditions
%  which they take to be
Ub = 6;
u0 = zeros(8,1);
u0(2) = Ub/2;
u0(3) = u0(2);
u0(4) = Ub;
u0(5) = Ub/2;
u0(6) = u0(5);
u0(7) = Ub;
u0(8) = 0;

options = odeset('Mass','M','MassSingular','yes');

[t,u] = ode15s('ex8ode',[0 0.05],u0,options);

Ue = 0.1*sin(200*pi*t);
plot(t,Ue,t,u(:,8))
legend('input ','output ',3)
title('Two Transistor Amplifier Problem')
axis([0 0.05 -5 1])
