%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                           %%
%%   Evaluate the solution of problem 7.28, acoustics in a pipe with the     %%
%%   left end closed and the right end open.                                 %%
%%                                                                           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function sum = p7_28u(x,t,a,l,fn,gn,nmax)

% initialize the sum to zero
sum=0*x;

% add the individual terms
for n=1:1:nmax
    rtlam=(2*n-1)*pi/(2*l);
    sum=sum+(fn(n)*cos(rtlam*a*t)+gn(n)/(rtlam*a)*sin(rtlam*a*t))*cos(rtlam*x);
end
