% MATLAB file used in the solution of Example 36.1 of "A First Course on
% Kinetics and Reaction Engineering."
function Example_36_1
    % Known constants
    k = 0.5; % L/mol/min
    V = 25.; % L
    Vdot = 4.; % L/min
    CAfeed = 2.3; % mol/L
    
    % Define the functions to be integrated numerically
    agefun = @(x) 0.16*exp(-0.16*x);
    sfmfun = @(x) k*CAfeed*x./(1+k*CAfeed*x)*0.16.*exp(-0.16*x);
    
    % Check the normalization of the age function
    age_check = integral(agefun,0,Inf)
    
    % Calculate the conversion using the segregated flow model
    fA_SF = integral(sfmfun,0,Inf)
    
end % of Example_36_1

