% function to specify derivatives
% and algebraic equations
% for isothermal batch reactor
% with multiple reactions
function out = multibatch(t,y,k1,k2,k3,A0)
A = y(1);
B = y(2);
C = y(3);
D = y(4);
E = y(5);
F = y(6);
out(1) = -k1*A*B - k2*A*C - k3*A*D;
out(2) = -k1*A*B;
out(3) = k1*A*B - k2*A*C;
out(4) = k2*A*C - k3*A*D;
out(5) = E-(A0-A-C-2*D)/3;
out(6) = F-(A0-A);
out=out';

